48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders\Development\Realistic;
|
|
|
|
use App\Lib\Helpers\FileStorageHelper;
|
|
use App\Models\Brand;
|
|
use App\Models\Font;
|
|
use App\Models\Range;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Str;
|
|
|
|
class RangeSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// * Solo range use case
|
|
$brand = Brand::query()->whereRaw("JSON_EXTRACT(name, '$.fr') = 'Los Pollos Hermanos'")->firstOrFail();
|
|
$font = Font::query()->where('font_name', Str::slug('Montserrat-Regular'))->firstOrFail();
|
|
$range = Range::factory()->makeOne();
|
|
$range->setRawAttributes([
|
|
'name' => \json_encode([
|
|
'fr' => 'Burritos',
|
|
'nl' => 'Burrito\'s',
|
|
'en' => 'Burritos',
|
|
])
|
|
]);
|
|
$range->fill([
|
|
'picture' => FileStorageHelper::storeFile(
|
|
new Range(),
|
|
new \SplFileInfo(
|
|
\resource_path("../database/factories/assets/ranges/burittos.jpg")
|
|
)
|
|
),
|
|
'color' => '#311e91',
|
|
'width' => 1,
|
|
'shelf' => true,
|
|
'status' => true
|
|
]);
|
|
$range->brand()->associate($brand);
|
|
$range->font()->associate($font);
|
|
$range->saveOrFail();
|
|
}
|
|
}
|