-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathFillableToMany.php
55 lines (48 loc) · 1.57 KB
/
FillableToMany.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
43
44
45
46
47
48
49
50
51
52
53
54
55
<?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\Collection as EloquentCollection;
use Illuminate\Database\Eloquent\Model;
use LaravelJsonApi\Eloquent\Polymorphism\MorphMany;
use LaravelJsonApi\Validation\Fields\IsValidated;
interface FillableToMany extends IsReadOnly, IsValidated
{
/**
* Fill the model with the value of the JSON:API to-many relation.
*
* @param Model $model
* @param array $identifiers
*/
public function fill(Model $model, array $identifiers): void;
/**
* Completely replace every member of the relationship with the specified members.
*
* @param Model $model
* @param array $identifiers
* @return EloquentCollection|MorphMany
*/
public function sync(Model $model, array $identifiers): iterable;
/**
* Add the specified members to the relationship unless they are already present.
*
* @param Model $model
* @param array $identifiers
* @return EloquentCollection|MorphMany
*/
public function attach(Model $model, array $identifiers): iterable;
/**
* Remove the specified members from the relationship.
*
* @param Model $model
* @param array $identifiers
* @return EloquentCollection|MorphMany
*/
public function detach(Model $model, array $identifiers): iterable;
}