64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories\Lists;
|
|
|
|
use App\Enums\LicenseKind;
|
|
use App\Models\Lists\License;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<License>
|
|
*/
|
|
class LicenseFactory extends Factory
|
|
{
|
|
protected $model = License::class;
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'name' => ucfirst(fake()->unique()->words(3, true)),
|
|
'acronym' => strtoupper(fake()->unique()->bothify('??-#.#')),
|
|
'spdx_id' => null,
|
|
'kind' => LicenseKind::License,
|
|
'description' => fake()->sentence(),
|
|
'uri' => fake()->url(),
|
|
'file' => null,
|
|
'for_record' => false,
|
|
'for_media' => true,
|
|
'sort_order' => fake()->numberBetween(0, 100),
|
|
'active' => true,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Licenza aperta ammessa anche per i record.
|
|
*/
|
|
public function forRecord(): static
|
|
{
|
|
return $this->state(fn () => ['for_record' => true]);
|
|
}
|
|
|
|
/**
|
|
* Rights statement (nessun testo legale, nessun id SPDX).
|
|
*/
|
|
public function rightsStatement(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'kind' => LicenseKind::RightsStatement,
|
|
'spdx_id' => null,
|
|
'file' => null,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Licenza ritirata dagli admin (esclusa dalle select dei form).
|
|
*/
|
|
public function inactive(): static
|
|
{
|
|
return $this->state(fn () => ['active' => false]);
|
|
}
|
|
}
|