Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @param  int  $groupId
  * @return Response
  */
 public function store(Request $request, $groupId)
 {
     $group = Group::findOrFail($groupId);
     //@TODO: Validate we are a judge for this event
     //
     //if (Gate::denies('create-group-score', $event, $group)) {
     //    abort(403);
     //}
     //
     $this->validate($request, ['name' => 'required|max:255', 'score' => 'required|numeric']);
     //@TODO: Delete previous scores from this judge to this group?
     //       Only those with the same score.name?
     $score = new Score($request->all());
     $score->judge()->associate(1);
     // @TODO get judge's member id from $user
     $score->group()->associate($groupId);
     $score->save();
     return response()->json($score);
 }