/** * Store a newly created resource in storage. * * @param int $meetingId * @return static */ public function showImage($meetingId) { $meeting = Meeting::findOrFail($meetingId); $this->authorize($meeting); $ret = self::getImg($meeting); $blank = storage_path('img/meetings.jpg'); if ($ret === false) { return (new Response(file_get_contents($blank), 200))->header('Content-Type', 'image/jpeg'); } return (new Response($ret, 200))->header('Content-Type', 'image/jpeg'); }
public function testSimpleModel() { if (!$this->doConsole()) { return; } //create data ob_start(); $status = \Artisan::call('db:seed', ['--class' => 'OptimisationDemoSeeder', '--force' => true]); ob_end_clean(); $this->assertEquals(0, $status); //get company $company = \plunner\Company::all()->last(); //optimise $status = \Artisan::call('optimise:meetings', ['companyId' => $company->id]); $this->assertEquals(0, $status); //check if the meetings are correctly optimised looking the users number that attend to them $meetingShort = \plunner\Meeting::whereIn('group_id', $company->groups->pluck('id'))->where('duration', config('app.timeslots.duration'))->firstOrfail(); $meetingLong = \plunner\Meeting::whereIn('group_id', $company->groups->pluck('id'))->where('duration', config('app.timeslots.duration') * 3)->firstOrfail(); $this->assertEquals(1, $meetingShort->employees->count()); $this->assertEquals(2, $meetingLong->employees->count()); }
/** * Remove the specified resource from storage. * * @param int $groupId * @param int $meetingId * @param int $timeslotId * @return mixed */ public function destroy($groupId, $meetingId, $timeslotId) { $group = Group::findOrFail($groupId); $this->authorize($group); $meeting = Meeting::findOrFail($meetingId); $this->authorize($meeting); if ($meeting->start_time != NULL) { return Response::json(['error' => 'the meeting is already planned'], 422); } $timeslot = MeetingTimeslot::findOrFail($timeslotId); $this->authorize($timeslot); if ($meeting->group_id == $groupId && $timeslot->meeting_id == $meetingId) { $timeslot->delete(); return $timeslot; } return Response::json(['error' => 'meeting->group_id <> groupId || timeslot->meeting_id <> meetingId'], 403); }
/** * @param Solver $solver */ private function saveMeetings(Solver $solver) { $meetings = $solver->getYResults(); foreach ($meetings as $id => $meeting) { $meetingO = \plunner\Meeting::findOrFail($id); //TODO catch error $meetingO->start_time = $this->toDateTime(array_search('1', $meeting)); $meetingO->save(); } }
private function getNonExistingMeetingId() { $test_meeting = \plunner\Meeting::orderBy('id', 'desc')->first(); $non_existing_meeting_id = $test_meeting->id + 1; return $non_existing_meeting_id; }
/** * Remove the specified resource from storage. * * @param int $groupId * @param int $meetingId * @return mixed */ public function destroy($groupId, $meetingId) { $group = Group::findOrFail($groupId); $this->authorize($group); $meeting = Meeting::findOrFail($meetingId); $this->authorize($meeting); $meeting->delete(); return $meeting; }