コード例 #1
0
 public function showprj($id)
 {
     $project = Projects::find($id);
     $image_array = [];
     $image_array["{$project->id}"] = explode(",", $project->imgpath);
     return view('main.project', ['model' => $project, 'images' => $image_array]);
 }
コード例 #2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $scenario = Scenarios::select('scenarios.*', 'context_scenario_ideal_way.context_name', 'context_scenario_ideal_way.full_name')->leftJoin('context_scenario_ideal_way', 'context_scenario_ideal_way.id', '=', 'scenarios.context_id')->where('scenarios.id', $id)->first();
     $project = Projects::find($scenario->project_id);
     $requirements = Requirements::leftJoin('users', 'users.id', '=', 'requirements.user_id')->select('requirements.*', 'users.name as created_by')->where('scenario_id', $id)->latest()->get();
     $breadcrumbs = array('Projects' => '/projects', 'Scenarios' => "/projects/{$scenario->project_id}");
     return view('scenarios.details', compact('scenario', 'project', 'requirements', 'breadcrumbs'));
 }
 public function delete(Request $request)
 {
     if (!ACL::hasPermission('projects', 'delete')) {
         return redirect(route('projects'))->withErrors(['You don\'t have permission for delete the projects.']);
     }
     //DELETE FOLDER BEFORE DELETE IN DATABASE
     $directory = $this->folder . $request->get('projectsId');
     File::deleteDirectory($directory);
     ProjectsGallery::deleteGalleryByProject($request->get('projectsId'));
     ProjectsMovie::deleteMoviesByProject($request->get('projectsId'));
     Projects::find($request->get('projectsId'))->delete();
     $success = "Project deleted successfully.";
     return redirect(route('projects'))->with(compact('success'));
 }
コード例 #4
0
 public function update($id, Request $request)
 {
     $this->validate($request, $this->rules);
     $project = Projects::find($id);
     $data = $request->all();
     $data['project_members'] = implode(',', $data['project_members']);
     $project->update($data);
     Session::flash('flash_message', 'Congratulations, Project updated successfully!');
     return redirect('projects');
 }
コード例 #5
0
 public function posteditportfolio(Request $request)
 {
     if (empty($request->input('updateid'))) {
         $model = new Projects();
         if ($request->hasFile('image')) {
             $files = $request->file('image');
             $medias = [];
             $errors = [];
             foreach ($files as $file) {
                 $destenition = public_path() . "/img/";
                 $extension = $file->getClientOriginalExtension();
                 $fileName = rand(11111, 99999) . '.' . $extension;
                 $file->move($destenition, $fileName);
                 array_push($medias, $fileName);
                 $images = implode(",", $medias);
             }
         }
         $model->name = $request->input('name');
         $model->description = $request->input('description');
         $model->additional_description = $request->input('additional_description');
         $model->url = $request->input('url');
         if (isset($images)) {
             $model->imgpath = $images;
         }
         if ($model->save()) {
             return redirect('/admin');
         }
     } else {
         $model = Projects::find($request->input('updateid'));
         if ($request->hasFile('image')) {
             $files = $request->file('image');
             $medias = [];
             foreach ($files as $file) {
                 $destenition = public_path() . "/img/";
                 $extension = $file->getClientOriginalExtension();
                 $fileName = rand(11111, 99999) . '.' . $extension;
                 $file->move($destenition, $fileName);
                 array_push($medias, $fileName);
                 $images = implode(",", $medias);
             }
         }
         $model->name = $request->input('name');
         $model->description = $request->input('description');
         $model->additional_description = $request->input('additional_description');
         $model->url = $request->input('url');
         if (isset($images)) {
             $model->imgpath = $images;
         }
         if ($model->save()) {
             return redirect('/admin');
         }
     }
 }
コード例 #6
0
 public function review(Request $request)
 {
     $requirement_id = $request->segment(2);
     $requirement = Requirements::find($requirement_id);
     $project = Projects::find($requirement->project_id);
     DB::enableQueryLog();
     $context = ContextScenarioUserAppInteraction::leftJoin('users', 'users.id', '=', 'context_scenario_user_app_interaction.user_id')->leftJoin('context_scenario_ideal_way AS context', 'context.id', '=', 'context_scenario_user_app_interaction.context_id')->leftJoin('context_ratings as CR', 'CR.context_id', '=', 'context_scenario_user_app_interaction.id')->select('context_scenario_user_app_interaction.*', 'users.name AS user_name', 'context.context_name', 'context.full_name', DB::raw('avg(CR.rating) AS avg_rating,
                     count(CR.id) AS rating_count'))->where('requirement_id', $requirement_id)->groupBy('context_scenario_user_app_interaction.id')->get()->toArray();
     $context_voting = ContextScenarioUserAppInteraction::leftJoin('ways_of_interaction_voting as WOIV', 'WOIV.context_id', '=', 'context_scenario_user_app_interaction.id')->select('context_scenario_user_app_interaction.id', DB::raw('sum(WOIV.accompanying) as accompanying_count,
                     sum(WOIV.intermittent) as intermittent_count,
                     sum(WOIV.interrupting) as interrupting_count'))->where('requirement_id', $requirement_id)->groupBy('context_scenario_user_app_interaction.id')->get()->toArray();
     foreach ($context as &$value1) {
         foreach ($context_voting as $value2) {
             if ($value1['id'] == $value2['id']) {
                 $value1 = array_merge($value1, $value2);
             }
         }
     }
     usort($context, function ($i, $j) {
         $a = $i['avg_rating'];
         $b = $j['avg_rating'];
         if ($a == $b) {
             return 0;
         } elseif ($a > $b) {
             return 1;
         } else {
             return -1;
         }
     });
     $context = array_reverse($context);
     $breadcrumbs = array('Projects' => '/projects', 'All Requirements' => "/projects/{$requirement->project_id}");
     return view('requirements.review', compact('requirement', 'context', 'project', 'breadcrumbs'));
 }