private function getType($type) { if ($type == 'LEC') { return CourseType::where('name', 'Lecture')->first(); } else { if ($type == 'TUT') { return CourseType::where('name', 'Tutorial')->first(); } else { if ($type == 'LAB') { return CourseType::where('name', 'Lab')->first(); } else { return CourseType::firstOrCreate(['name' => $type]); } } } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { CourseType::destroy($id); }
/** * Run the database seeds. * * @return void */ public function run() { CourseType::firstOrCreate(['name' => 'Lecture']); CourseType::firstOrCreate(['name' => 'Lab']); CourseType::firstOrCreate(['name' => 'Tutorial']); }