/**
  * 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]);
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request;
     $rules = ['file' => 'required'];
     $this->validate($data, $rules);
     $file = $request->file('file');
     if ($file !== null) {
         $filename_with_ex = $file->getClientOriginalName();
         $imagePath = rand(1, 1000) . '-' . $filename_with_ex;
         $image = $file->move($this->imagePath, $imagePath, File::get($file));
         if ($image) {
             $data['name'] = $imagePath;
         }
     }
     Background::create($data->all());
     return redirect('admin/backgrounds');
 }