/** * Run the database seeds. * * @return void */ public function run() { // Suppression préalable des fichiers de upload par l'utilisation de la variable storage définie à l'aide de l'instruction public_path('upload') du fichier de configuration config\filesystem.php) $files = Storage::allFiles(); //retroune un tableau des images de storage foreach ($files as $file) { Storage::delete($file); } //Supprimer toutes les lignes de la talble Pictures // DB::table('pictures')-> // Récupération d'un faker opétationnel // $faker = Faker\Factory::create(); $products = Product::all(); foreach ($products as $product) { // Stokage de l'image et récupération de l'uri $uri = str_random(15) . '_370x235.jpg'; Storage::put($uri, file_get_contents('http://lorempixel.com/people/370/325/')); Picture::create(['product_id' => $product->id, 'uri' => $uri, 'title' => $this->faker->name]); } // DB::table('pictures')->insert( // [ // [ // 'product_id' => '2' , // 'uri' => $uri // ], // ] // ); }
public function run() { $files = Storage::allFiles(); foreach ($files as $file) { Storage::delete($file); } $test = Product::all(); foreach ($test as $value) { $uri = str_random(12) . '_370x235.jpg'; Storage::put($uri, file_get_contents('http://lorempixel.com/futurama/370/235')); Picture::create(['product_id' => $value->id, 'uri' => $uri, 'title' => $this->faker->name]); } }
public function run() { $files = Storage::allFiles(); foreach ($files as $file) { Storage::delete($file); } $products = App\Product::all(); foreach ($products as $product) { // pour importer de fichiers distants $uri = str_random(12) . '_370x235.jpg'; Storage::put($uri, file_get_contents('http://lorempixel.com/futurama/370/235/')); Picture::create(['product_id' => $product->id, 'uri' => $uri, 'title' => $this->faker->name]); } }
/** * Run the database seeds. * * @return void */ public function run() { // Eloquent::unguard(); DB::table('pictures')->delete(); DB::statement("ALTER TABLE pictures AUTO_INCREMENT=1"); $files = Storage::allFiles(); foreach ($files as $file) { Storage::delete($file); } $products = Product::all(); foreach ($products as $product) { $uri = str_random(12) . '_370x235.jpg'; Storage::put($uri, file_get_contents('http://lorempixel.com/futurama/370/235')); Picture::create(['product_id' => $product->id, 'uri' => $uri, 'title' => $this->facker->name, 'type' => 'jpg', 'size' => 200]); } }
public function run() { $files = Storage::allFiles(); foreach ($files as $file) { Storage::delete($file); //sert a vider le dossier upload si on relance un refresh //pour éviter de stocker 15 images + 15 images ect... } $products = Product::all(); //recupere tous les produits precedement creer dans un tableau foreach ($products as $product) { $uri = str_random(12) . '_370x235.jpg'; //str_random fait un chaine de caractere de 12 Storage::put($uri, file_get_contents('http://lorempixel.com/futurama/370/235/')); Picture::create(['product_id' => $product->id, 'uri' => $uri, 'title' => $this->faker->name]); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->insert([['name' => 'Tony', 'email' => '*****@*****.**', 'password' => Hash::make('Tony'), 'role' => 'administrator'], ['name' => 'Antoine', 'email' => '*****@*****.**', 'password' => Hash::make('Antoine'), 'role' => 'visitor'], ['name' => 'Romain', 'email' => '*****@*****.**', 'password' => Hash::make('Tony'), 'role' => 'visitor'], ['name' => 'yini', 'email' => '*****@*****.**', 'password' => Hash::make('Yini'), 'role' => 'visitor']]); factory(App\Customer::class, 4)->create(); // avatars DB::table('avatars')->delete(); DB::statement("ALTER TABLE avatars AUTO_INCREMENT=1"); $files = Storage::allFiles(env('UPLOADS_AVATARS', 'uploads')); foreach ($files as $file) { Storage::delete($file); } $users = User::all(); foreach ($users as $user) { $uri = str_random(12) . '_216x256.jpg'; $fileName = file_get_contents('http://lorempixel.com/216/256/animals'); $pathDirectory = env('UPLOADS_AVATARS', 'avatars') . DIRECTORY_SEPARATOR . $uri; Storage::put($pathDirectory, $fileName); $mime = mime_content_type(storage_path('app') . DIRECTORY_SEPARATOR . $pathDirectory); Avatar::create(['user_id' => $user->id, 'uri' => $uri, 'title' => $this->facker->name, 'mime' => $mime]); } }
| We need to illuminate PHP development, so let us turn on the lights. | This bootstraps the framework and gets it ready for use, then it | will load up this application so that we can run it and send | the responses back to the browser and delight our users. | */ $app = (require_once __DIR__ . '/application/bootstrap/app.php'); /* |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | | Once we have the application, we can handle the incoming request | through the kernel, and send the associated response back to | the client's browser allowing them to enjoy the creative | and wonderful application we have prepared for them. | */ $kernel = $app->make('Illuminate\\Contracts\\Http\\Kernel'); $response = $kernel->handle($request = Illuminate\Http\Request::capture()); #SYNTROPY: 2016-02-06: Die and Dump Settings #dd(App::make('Settings')); #$storagePath = Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix(); #$storagePath = base_path(); #$storagePath = Storage::disk('cryptoffice'); #dd($storagePath); $files = Storage::allFiles('application/storage/uploads/'); #$files = Storage::allFiles($storagePath); dd($files); $response->send(); $kernel->terminate($request, $response);