database/factories/BrandFactory.php
Rama main · réplica de lectura del repositorio original.
<?php
/**
* Copyright (c) Since 2024 InnoShop - All Rights Reserved
*
* @link https://www.innoshop.com
* @author InnoShop <team@innoshop.com>
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use InnoShop\Common\Models\Brand;
/**
* @extends Factory<Brand>
*/
class BrandFactory extends Factory
{
protected $model = Brand::class;
public function definition(): array
{
$name = fake()->company();
return [
'name' => $name,
'slug' => Str::slug($name).'-'.Str::random(5),
'first' => strtoupper(substr($name, 0, 1)),
'logo' => '',
'position' => fake()->numberBetween(0, 100),
'active' => true,
];
}
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'active' => false,
]);
}
}