Exemple #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $officer = new Officer();
     $officer->member_id = 1;
     $officer->title = 'President';
     $officer->term_id = 1;
     $officer->save();
 }
Exemple #2
0
 /**
  * Store a newly created officer in storage.
  *
  * @Post("/")
  * @Transaction(
  *     @Request({"member_id": 1, "title": "President"}),
  *     @Response(201, body={"id": 1, "member_id": 1, "term_id": 1,
  *                          "title": "President", "position": "president",
  *                          "email": "*****@*****.**", "url": "/officers/1"}),
  *     @Response(422, body={"member_id": {"The member id field is required."}})
  * )
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     // FIXME: Validate unique title for current term
     $this->validate($request, ['member_id' => 'required', 'title' => 'required']);
     // FIXME: Replace with internal route to /terms/current_term
     $term_id = 1;
     $officer = Officer::where(['title' => $request->input('title'), 'term_id' => $term_id]);
     if ($officer) {
         $officer->delete();
     }
     $officer = new Officer();
     $officer->member_id = $request->input('member_id');
     $officer->title = $request->input('title');
     $officer->term_id = $term_id;
     $officer->save();
     return new JsonResponse($officer, Response::HTTP_CREATED);
 }