-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathFillableToOne.php
42 lines (36 loc) · 1.01 KB
/
FillableToOne.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/*
* Copyright 2024 Cloud Creativity Limited
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
declare(strict_types=1);
namespace LaravelJsonApi\Eloquent\Contracts;
use Illuminate\Database\Eloquent\Model;
use LaravelJsonApi\Validation\Fields\IsValidated;
interface FillableToOne extends IsReadOnly, IsValidated
{
/**
* Does the model need to exist in the database before the relation is filled?
*
* @return bool
*/
public function mustExist(): bool;
/**
* Fill the model with the value of the JSON:API to-one relation.
*
* @param Model $model
* @param mixed $identifier
*/
public function fill(Model $model, ?array $identifier): void;
/**
* Replace the relationship.
*
* @param Model $model
* @param array|null $identifier
* @return Model|null
*/
public function associate(Model $model, ?array $identifier): ?Model;
}