Initial commit: Pireon Admin — headless admin panel and public API
Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
57
database/factories/MediaFactory.php
Normal file
57
database/factories/MediaFactory.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Media;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Media>
|
||||
*/
|
||||
class MediaFactory extends Factory
|
||||
{
|
||||
protected $model = Media::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'disk' => (string) config('media.disk', 'public'),
|
||||
'path' => 'projects/'.fake()->unique()->uuid().'.jpg',
|
||||
'mime' => 'image/jpeg',
|
||||
'size' => fake()->numberBetween(50_000, 900_000),
|
||||
'width' => null,
|
||||
'height' => null,
|
||||
'variants' => null,
|
||||
'placeholder' => null,
|
||||
'processed_at' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* An image the processor has already been through.
|
||||
*/
|
||||
public function processed(int $width = 1600, int $height = 900): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'placeholder' => 'data:image/webp;base64,UklGRhoAAABXRUJQ',
|
||||
'variants' => collect([400, 800, 1200])
|
||||
->filter(fn (int $w) => $w < $width)
|
||||
->map(fn (int $w) => [
|
||||
'format' => 'webp',
|
||||
'width' => $w,
|
||||
'path' => str_replace('.jpg', "-{$w}.webp", $attributes['path']),
|
||||
'size' => $w * 100,
|
||||
])
|
||||
->values()
|
||||
->all(),
|
||||
'processed_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user