mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Co-authored-by: Aditya Tripathi <aditya@climactic.co>
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\ImageScanGateMode;
|
|
use App\Enums\ImageScanOnError;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
/**
|
|
* Scan rules at one level (instance, team, server or application). A null field inherits.
|
|
* The instance row has `scope_type = null` and concrete values.
|
|
*/
|
|
class ImageScanPolicy extends BaseModel
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'scope_type',
|
|
'scope_id',
|
|
'gate_mode',
|
|
'on_scan_error',
|
|
'count_medium',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'gate_mode' => ImageScanGateMode::class,
|
|
'on_scan_error' => ImageScanOnError::class,
|
|
'count_medium' => 'boolean',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Rules for the editable fields of a policy. A null field inherits.
|
|
*
|
|
* @return array<string, list<mixed>>
|
|
*/
|
|
public static function validationRules(): array
|
|
{
|
|
return [
|
|
'gate_mode' => ['nullable', Rule::enum(ImageScanGateMode::class)],
|
|
'on_scan_error' => ['nullable', Rule::enum(ImageScanOnError::class)],
|
|
'count_medium' => ['nullable', 'boolean'],
|
|
];
|
|
}
|
|
|
|
public function scope(): MorphTo
|
|
{
|
|
return $this->morphTo('scope');
|
|
}
|
|
}
|