/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $backgrounds = ['home-bg1.jpg', 'home-bg2.jpg', 'home-bg3.jpg', 'home-bg4.jpg', 'home-bg5.jpg', 'home-bg6.jpg'];
     foreach ($backgrounds as $background) {
         $bg = Background::where('name', '=', $background)->first();
         if (!$bg) {
             Background::create(['name' => $background]);
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $background = Background::find($id);
     $filename = $background['name'];
     $default_backgrounds = ['home-bg1.jpg', 'home-bg2.jpg', 'home-bg3.jpg', 'home-bg4.jpg', 'home-bg5.jpg', 'home-bg6.jpg'];
     if (!in_array($filename, $default_backgrounds)) {
         $file_path = public_path("images/backgrounds/{$filename}");
         if (File::exists($file_path)) {
             File::delete($file_path);
         }
     }
     Background::destroy($id);
     return redirect('admin/backgrounds');
 }
 public function get_backgrounds()
 {
     $backgrounds = Background::all();
     return $backgrounds;
 }