ldc-portsalaries/database/factories/SocieteFactory.php

49 lines
1.3 KiB
PHP
Raw Normal View History

2021-05-08 06:50:19 +02:00
<?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();
2021-06-17 14:53:50 +02:00
$colors = collect([
"primary" => "#1D1646",
"secondary" => "#F6BE00",
"color-background" => "#FFF"
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
])->mapWithKeys(function ($value, $key) {
return [$key => $this->faker->safeHexColor()];
});
2021-05-08 06:50:19 +02:00
return [
'name' => $companyName,
'phone' => $this->faker->unique()->phoneNumber(),
'address' => $this->faker->unique()->address(),
2021-05-08 06:50:19 +02:00
'logo' => Societe::saveLogo($logo, $companyName),
2021-06-17 16:11:27 +02:00
'colors' => \json_encode($colors->all())
2021-05-08 06:50:19 +02:00
];
}
}