Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Database\Eloquent;
4
 
5
use Illuminate\Database\RecordsNotFoundException;
6
use Illuminate\Support\Arr;
7
 
8
/**
9
 * @template TModel of \Illuminate\Database\Eloquent\Model
10
 */
11
class ModelNotFoundException extends RecordsNotFoundException
12
{
13
    /**
14
     * Name of the affected Eloquent model.
15
     *
16
     * @var class-string<TModel>
17
     */
18
    protected $model;
19
 
20
    /**
21
     * The affected model IDs.
22
     *
23
     * @var array<int, int|string>
24
     */
25
    protected $ids;
26
 
27
    /**
28
     * Set the affected Eloquent model and instance ids.
29
     *
30
     * @param  class-string<TModel>  $model
31
     * @param  array<int, int|string>|int|string  $ids
32
     * @return $this
33
     */
34
    public function setModel($model, $ids = [])
35
    {
36
        $this->model = $model;
37
        $this->ids = Arr::wrap($ids);
38
 
39
        $this->message = "No query results for model [{$model}]";
40
 
41
        if (count($this->ids) > 0) {
42
            $this->message .= ' '.implode(', ', $this->ids);
43
        } else {
44
            $this->message .= '.';
45
        }
46
 
47
        return $this;
48
    }
49
 
50
    /**
51
     * Get the affected Eloquent model.
52
     *
53
     * @return class-string<TModel>
54
     */
55
    public function getModel()
56
    {
57
        return $this->model;
58
    }
59
 
60
    /**
61
     * Get the affected Eloquent model IDs.
62
     *
63
     * @return array<int, int|string>
64
     */
65
    public function getIds()
66
    {
67
        return $this->ids;
68
    }
69
}