Пример #1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $image = image::findOrFail($id);
     $files = [public_path() . "/images/products/" . $image->image, public_path() . "/images/products/med_" . $image->image, public_path() . "/images/products/tmb_" . $image->image];
     File::delete($files);
     image::destroy($image->id);
     return redirect()->back();
 }
Пример #2
0
 public function run()
 {
     DB::table('images')->truncate();
     $products = product::all()->lists('id');
     $faker = Factory::create();
     foreach ($products as $product) {
         image::create(['image' => $faker->randomElement(["hoody_01_white.jpg", "hoody_01_green.jpg"]), 'imageable_id' => $product, 'imageable_type' => 'App\\product']);
     }
 }