Files
landing-api/app/Policies/MediaPolicy.php
Josep Piguillem 3897113313 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>
2026-08-19 17:55:27 +02:00

34 lines
739 B
PHP

<?php
declare(strict_types=1);
namespace App\Policies;
use App\Models\User;
class MediaPolicy extends ResourcePolicy
{
protected function resource(): string
{
return 'media';
}
/**
* Files arrive by being uploaded on a record, not by being created here.
*/
public function create(User $user): bool
{
return false;
}
/**
* A file something still points at cannot be deleted from here: doing so
* would leave a broken image on the public site, which is precisely what
* the health check exists to complain about.
*/
public function delete(User $user, $model): bool
{
return parent::delete($user, $model) && ! $model->isReferenced();
}
}