Fix project edit and Site edit
This commit is contained in:
parent
d21dce0fff
commit
acb9bc9bbe
2 changed files with 30 additions and 4 deletions
|
|
@ -32,7 +32,18 @@ class Project extends Model
|
|||
'validate' => [
|
||||
'string',
|
||||
'max:255',
|
||||
'unique:sites,name'
|
||||
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
function ($attribute, $value, $fail) {
|
||||
$q = static::query();
|
||||
if (request()->project) {
|
||||
$q = $q->where('id', '!=', $this->id);
|
||||
}
|
||||
if ($q->where('name', $value)->exists()) {
|
||||
$fail(__(':attribute est déjà utilisé', [
|
||||
'attribute' => $attribute
|
||||
]));
|
||||
}
|
||||
}
|
||||
],
|
||||
'required' => true,
|
||||
'nullable' => false,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ class Site extends Model
|
|||
'description', 'todo'
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
'status' => '',
|
||||
];
|
||||
|
||||
public function __construct($attributes = [])
|
||||
{
|
||||
self::$editableProperties = [
|
||||
|
|
@ -36,7 +40,18 @@ class Site extends Model
|
|||
'validate' => [
|
||||
'string',
|
||||
'max:255',
|
||||
'unique:sites,name'
|
||||
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
function ($attribute, $value, $fail) {
|
||||
$q = static::query();
|
||||
if (request()->site) {
|
||||
$q = $q->where('id', '!=', $this->id);
|
||||
}
|
||||
if ($q->where('name', $value)->exists()) {
|
||||
$fail(__(':attribute est déjà utilisé', [
|
||||
'attribute' => $attribute
|
||||
]));
|
||||
}
|
||||
}
|
||||
],
|
||||
'required' => true,
|
||||
'nullable' => false,
|
||||
|
|
@ -54,8 +69,8 @@ class Site extends Model
|
|||
'string',
|
||||
'max:255'
|
||||
],
|
||||
'required' => true,
|
||||
'nullable' => false,
|
||||
'required' => false,
|
||||
'nullable' => true, // n'est pas vraiment nullable en base
|
||||
'actions' => [
|
||||
CrudAction::view(),
|
||||
CrudAction::create(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue