license: built full stack, test and documentation
This commit is contained in:
63
backend/database/factories/Lists/LicenseFactory.php
Normal file
63
backend/database/factories/Lists/LicenseFactory.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user