37 lines
1 KiB
PHP
37 lines
1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders\Mandatory;
|
|
|
|
use App\Lib\Helpers\FileStorageHelper;
|
|
use App\Models\Picto;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
class PictoSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
Schema::disableForeignKeyConstraints();
|
|
DB::table((new Picto())->getTable())->truncate();
|
|
Schema::enableForeignKeyConstraints();
|
|
|
|
File::deleteDirectory(\storage_path('app/public/modelfiles/' . (new Picto())->getTable()));
|
|
|
|
Picto::factory(10)->make()->each(function (Picto $picto) {
|
|
$picto->picture = FileStorageHelper::storeFile(
|
|
new Picto(),
|
|
new \SplFileInfo(
|
|
\resource_path('../database/factories/assets/pictos/default-picture-85x85.png')
|
|
)
|
|
);
|
|
$picto->saveQuietly();
|
|
});
|
|
}
|
|
}
|