forked from illuminate/database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModelNotFoundException.php
executable file
·69 lines (59 loc) · 1.39 KB
/
ModelNotFoundException.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Illuminate\Database\Eloquent;
use Illuminate\Database\RecordsNotFoundException;
use Illuminate\Support\Arr;
/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class ModelNotFoundException extends RecordsNotFoundException
{
/**
* Name of the affected Eloquent model.
*
* @var class-string<TModel>
*/
protected $model;
/**
* The affected model IDs.
*
* @var array<int, int|string>
*/
protected $ids;
/**
* Set the affected Eloquent model and instance ids.
*
* @param class-string<TModel> $model
* @param array<int, int|string>|int|string $ids
* @return $this
*/
public function setModel($model, $ids = [])
{
$this->model = $model;
$this->ids = Arr::wrap($ids);
$this->message = "No query results for model [{$model}]";
if (count($this->ids) > 0) {
$this->message .= ' '.implode(', ', $this->ids);
} else {
$this->message .= '.';
}
return $this;
}
/**
* Get the affected Eloquent model.
*
* @return class-string<TModel>
*/
public function getModel()
{
return $this->model;
}
/**
* Get the affected Eloquent model IDs.
*
* @return array<int, int|string>
*/
public function getIds()
{
return $this->ids;
}
}