48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders\Development\Realistic;
|
|
|
|
use App\Models\Brand;
|
|
use App\Models\Font;
|
|
use App\Models\Range;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Str;
|
|
use Uwil\LaravelCommon\Helpers\FileHelper;
|
|
|
|
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->setTranslations('name', [
|
|
'fr' => 'Burritos',
|
|
'nl' => 'Burrito\'s',
|
|
'en' => 'Burritos',
|
|
'es' => 'Burritos',
|
|
'de' => 'Burritos',
|
|
]);
|
|
$range->fill([
|
|
'picture' => FileHelper::storeFile(
|
|
new Range(),
|
|
new \SplFileInfo(
|
|
\resource_path("../database/factories/assets/ranges/burittos.jpg")
|
|
),
|
|
prefix: $range->tenant_id
|
|
),
|
|
'color' => '#311e91',
|
|
'width' => 1,
|
|
'status' => true
|
|
]);
|
|
$range->brand()->associate($brand);
|
|
$range->font()->associate($font);
|
|
$range->saveOrFail();
|
|
}
|
|
}
|