/** * reads Project table by unique index * - if not found, emit a not found message. * - if found return the $project record to the caller. * * @param [in] $text * @return record. */ public static function checkIfExists($text) { $workType = WorkType::where('type', '=', $text)->first(); if (!is_null($workType)) { appGlobals::existsMessage(appGlobals::getWorkTypeTableName(), $workType->type, $workType->id); } return $workType; }
/** * Showing all Works for certain WorkType. * @param $slug * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index($slug) { $workType = \App\WorkType::where(['slug' => $slug])->firstOrFail(); $works = $workType->works; return view('admin.works.index', ['works' => $works]); }
// get $project->id $project = Project::where('name', '=', 'Magento Development')->first(); // get $project->id $workType = WorkType::where('type', '=', 'Atlassian Ticket')->first(); $work = new Work(); $work->work_type_description = $description; $work->project_id = $project->id; $work->work_type_id = $workType->id; $work->save(); } $description = 'A new landing page is required to support Fall 2016 GNO.'; if (is_null($work = Work::checkIfExists($description))) { // get $project->id $project = Project::where('name', '=', 'Magento Development')->first(); // get $project->id $workType = WorkType::where('type', '=', 'Feature')->first(); $work = new Work(); $work->work_type_description = $description; $work->project_id = $project->id; $work->work_type_id = $workType->id; $work->save(); } /******************************************************************************************************************* * time_card insert(s) ******************************************************************************************************************/ // get $work->id $work = Work::where('work_type_description', '=', 'The catalog view is performing too slowly.')->first(); // get $timeCardFormat->id $timeCardFormat = TimeCardFormat::where('description', '=', 'Day of week starts on SAT and ends on SUN')->first(); $timeCard = new TimeCard(); $timeCard->work_id = $work->id;
/** * Returns view for work listing with all required info. If does not exist return 404. * @param $slug */ public function showWorksPage($slug) { $workType = \App\WorkType::where(['slug' => $slug])->firstOrFail(); }