コード例 #1
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'));
 }
コード例 #2
0
 public function getReq($city)
 {
     $areas = Areas::where('city', $city)->get();
     $data = [];
     $i = 0;
     foreach ($areas as $area) {
         $requirementsPerArea = Requirements::where('areaCode', $area->id)->get();
         foreach ($requirementsPerArea as $req) {
             $data[$i]['areaName'] = $area->area;
             $data[$i]['requirements'] = $req->requirement;
             $volunteer = Volunteers::where('id', $req->volunteerId)->first();
             $data[$i]['name'] = $volunteer->username;
             $data[$i]['contact'] = $volunteer->contact;
             $i++;
         }
     }
     return view('user.city')->with('data', $data);
 }
コード例 #3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $context = ContextScenarioUserAppInteraction::select('context_scenario_user_app_interaction.*', 'CSR.scene')->leftJoin('context_scene_relation as CSR', function ($join) {
         $join->on('CSR.context_id', '=', 'context_scenario_user_app_interaction.id');
         $join->where('CSR.user_id', '=', $this->user['id']);
     })->where('context_scenario_user_app_interaction.id', $id)->get();
     if (count($context)) {
         $context = $context[0];
     }
     $requirement_id = $context->requirement_id;
     //        if($context->user_id != $this->user['id']){
     //            Session::flash('flash_message_warning', 'Sorry, you do not have enough privilege to make this change!');
     //            return redirect("requirements/$requirement_id");
     //        }
     $requirement = Requirements::select('scenario_id')->where('id', $requirement_id)->first();
     $context_ideal_way = ContextScenarioIdealWay::getContextIdealWayKeyValue();
     $breadcrumbs = array('Projects' => "/projects", 'All Requirements' => "/scenarios/{$requirement->scenario_id}", 'All Context' => "requirements/{$requirement_id}");
     return view('context.edit', compact('context', 'requirement_id', 'context_ideal_way', 'breadcrumbs'));
 }
コード例 #4
0
 public function modifyRequirements(Request $request)
 {
     Requirements::where('requirement', $request->get('requirement'))->update(["quantity" => $request->get('quantity')]);
     return json_encode(["quantity" => $request->get('quantity')]);
 }
コード例 #5
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'));
 }