48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Societe;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Http\UploadedFile;
|
|
|
|
class SocieteFactory extends Factory
|
|
{
|
|
|
|
/**
|
|
* The name of the factory's corresponding model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $model = Societe::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function definition()
|
|
{
|
|
$logo = new UploadedFile(
|
|
$this->faker->image(null, 450, 360, 'compagnies', true, true),
|
|
sprintf('logo-%d.png', rand(10000, 99999))
|
|
);
|
|
$companyName = $this->faker->unique()->company();
|
|
$colors = collect([
|
|
"primary" => "#1D1646",
|
|
"secondary" => "#F6BE00",
|
|
"color-background" => "#FFF"
|
|
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
|
])->mapWithKeys(function ($value, $key) {
|
|
return [$key => $this->faker->safeHexColor()];
|
|
});
|
|
|
|
return [
|
|
'name' => $companyName,
|
|
'phone' => $this->faker->unique()->phoneNumber(),
|
|
'address' => $this->faker->unique()->address(),
|
|
'logo' => Societe::saveLogo($logo, $companyName),
|
|
'colors' => \json_encode($colors->all())
|
|
];
|
|
}
|
|
}
|