/** * Run the database seeds. * * @return void */ public function run() { DB::table('slides')->delete(); Slides::create(['id' => 1, 'struct_id' => 2, 'img_name' => 'slide-1.jpg']); Slides::create(['id' => 2, 'struct_id' => 2, 'img_name' => 'slide-2.jpg']); Slides::create(['id' => 3, 'struct_id' => 2, 'img_name' => 'slide-3.jpg']); }
/** * Remove the specified slide from db with all relations. * * @param int $id slide * @return \Illuminate\Http\Response */ public function getDestroy($id) { $slideObj = Slides::findOrFail((int) $id); $slideObj->slide_trl()->delete(); $fileName = public_path('images/slide_upload/' . $slideObj->img_name); @unlink($fileName); $slideObj->delete(); return redirect(action('Admin\\SlidesController@getIndex'))->with(['success_message' => 'Slide was deleted']); }
private function Slides() { return $this->fetchTable(Slides::all()); }