/** * Run the database seeds. * * @return void */ public function run() { $types = ['S', 'C', 'T']; $teachTimes = ['T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'CN']; foreach ($types as $typeKey => $type) { foreach ($teachTimes as $key => $value) { $teachTime = TeachTime::create(['key' => $value, 'type' => $type, 'priority' => 0, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']); } } }
public function studentRegister() { $this->setMetadata('Đăng ký tìm gia sư'); $districts = District::where('is_publish', 1)->get(); $subjects = Subject::where('is_publish', 1)->orderBy('priority')->get(); $teachTimes = TeachTime::where('is_publish', 1)->orderBy('priority')->get(); return view('frontend.sites.studentRegister', ['districts' => $districts, 'subjects' => $subjects, 'teachTimes' => $teachTimes]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { DB::transaction(function () use($id) { $user = Auth::user(); $teachTime = TeachTime::findOrFail($id); $teachTime->updated_by = $user->name; $teachTime->deleted_by = $user->name; $teachTime->save(); // soft delete $teachTime->delete(); }); }