/** * 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); }
/** * Run the database seeds. * * @return void */ public function run() { $company_id = \App\Company::where('company_name', '=', 'ACME Corporation')->pluck('id'); $officer_id = \App\Officer::where('last_name', '=', 'Bale')->pluck('id'); DB::table('projects')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'new_employment_commit' => 200, 'award_percent' => 85, 'company_id' => $company_id, 'officer_id' => $officer_id]); $company_id = \App\Company::where('company_name', '=', 'The ABC Corporation')->pluck('id'); $officer_id = \App\Officer::where('last_name', '=', 'Ronaldo')->pluck('id'); DB::table('projects')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'new_employment_commit' => 200, 'award_percent' => 65, 'company_id' => $company_id, 'officer_id' => $officer_id]); $company_id = \App\Company::where('company_name', '=', 'YXZ Corporation')->pluck('id'); $officer_id = \App\Officer::where('last_name', '=', 'Chan')->pluck('id'); DB::table('projects')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'new_employment_commit' => 200, 'award_percent' => 50, 'company_id' => $company_id, 'officer_id' => $officer_id]); $company_id = \App\Company::where('company_name', '=', 'DIC Consulting Group')->pluck('id'); $officer_id = \App\Officer::where('last_name', '=', 'Guerrero')->pluck('id'); DB::table('projects')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'new_employment_commit' => 200, 'award_percent' => 80, 'company_id' => $company_id, 'officer_id' => $officer_id]); $company_id = \App\Company::where('company_name', '=', 'ACME Corporation')->pluck('id'); $officer_id = \App\Officer::where('last_name', '=', 'Bale')->pluck('id'); DB::table('projects')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'new_employment_commit' => 200, 'award_percent' => 75, 'company_id' => $company_id, 'officer_id' => $officer_id]); }