1 | <?php |
||
7 | class RouteKeyExists implements Rule |
||
8 | { |
||
9 | /** |
||
10 | * The model to validate. |
||
11 | * |
||
12 | * @var \Illuminate\Database\Eloquent\Model |
||
13 | */ |
||
14 | protected $model; |
||
15 | |||
16 | /** |
||
17 | * The attribute being validated. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $attribute; |
||
22 | |||
23 | /** |
||
24 | * Replace the route key in the request |
||
25 | * with the actual database value? |
||
26 | * |
||
27 | * @var bool |
||
28 | */ |
||
29 | protected $replaceAttribute = false; |
||
30 | |||
31 | /** |
||
32 | * Attribute with the actual database value |
||
33 | * to add to the request. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $addAttribute = null; |
||
38 | |||
39 | /** |
||
40 | * Create a new rule instance. |
||
41 | * |
||
42 | * @param string $model |
||
43 | * |
||
44 | * @return static |
||
45 | */ |
||
46 | 3 | public static function model($model) |
|
50 | |||
51 | /** |
||
52 | * Create a new rule instance. |
||
53 | * |
||
54 | * @param string $model |
||
55 | */ |
||
56 | 3 | public function __construct($model) |
|
60 | |||
61 | /** |
||
62 | * Replace the route key in the request |
||
63 | * with the actual database value. |
||
64 | * |
||
65 | * @return $this |
||
66 | */ |
||
67 | 1 | public function replace() |
|
73 | |||
74 | /** |
||
75 | * Add the given attribute with the actual |
||
76 | * database value to the request. |
||
77 | * |
||
78 | * @param string $attribute |
||
79 | * |
||
80 | * @return $this |
||
81 | */ |
||
82 | 1 | public function add($attribute) |
|
88 | |||
89 | /** |
||
90 | * Determine if the validation rule passes. |
||
91 | * |
||
92 | * @param string $attribute |
||
93 | * @param string $value |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | 3 | public function passes($attribute, $value) |
|
109 | |||
110 | /** |
||
111 | * Get the validation error message. |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | 1 | public function message() |
|
121 | |||
122 | /** |
||
123 | * Update the request attributes if needed. |
||
124 | * |
||
125 | * @param \Illuminate\Database\Eloquent\Model $model |
||
126 | * |
||
127 | * @return void |
||
128 | */ |
||
129 | 3 | protected function updateRequest($model) |
|
141 | |||
142 | /** |
||
143 | * Merge the request attributes with the given key / value pair. |
||
144 | * |
||
145 | * @param string $key |
||
146 | * @param mixed $value |
||
147 | * |
||
148 | * @return void |
||
149 | */ |
||
150 | 2 | protected function mergeRequest($key, $value) |
|
156 | } |
||
157 |