1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Larapie\Actions\Concerns; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Arr; |
6
|
|
|
|
7
|
|
|
trait HasAttributes |
8
|
|
|
{ |
9
|
|
|
protected $attributes = []; |
10
|
|
|
|
11
|
1 |
|
public function setRawAttributes(array $attributes) |
12
|
|
|
{ |
13
|
1 |
|
$this->attributes = $attributes; |
14
|
|
|
|
15
|
1 |
|
return $this; |
16
|
|
|
} |
17
|
|
|
|
18
|
68 |
|
public function fill(array $attributes) |
19
|
|
|
{ |
20
|
68 |
|
$attributes = array_merge($attributes, $this->resolveAttributeCasting($attributes)); |
|
|
|
|
21
|
|
|
|
22
|
68 |
|
$attributes = array_merge($this->attributes, $attributes); |
23
|
|
|
|
24
|
68 |
|
$this->attributes = array_merge($this->resolveDefaults(), $attributes); |
|
|
|
|
25
|
|
|
|
26
|
68 |
|
return $this; |
27
|
|
|
} |
28
|
|
|
|
29
|
55 |
|
public function all() |
30
|
|
|
{ |
31
|
55 |
|
return $this->attributes; |
32
|
|
|
} |
33
|
|
|
|
34
|
1 |
|
public function only($keys) |
35
|
|
|
{ |
36
|
1 |
|
return Arr::only($this->attributes, is_array($keys) ? $keys : func_get_args()); |
37
|
|
|
} |
38
|
|
|
|
39
|
1 |
|
public function except($keys) |
40
|
|
|
{ |
41
|
1 |
|
return Arr::except($this->attributes, is_array($keys) ? $keys : func_get_args()); |
42
|
|
|
} |
43
|
|
|
|
44
|
7 |
|
public function has($key) |
45
|
|
|
{ |
46
|
7 |
|
return Arr::has($this->attributes, $key); |
47
|
|
|
} |
48
|
|
|
|
49
|
14 |
|
public function get($key, $default = null) |
50
|
|
|
{ |
51
|
14 |
|
return Arr::get($this->attributes, $key, $default); |
52
|
|
|
} |
53
|
|
|
|
54
|
1 |
|
public function set($key, $value) |
55
|
|
|
{ |
56
|
1 |
|
Arr::set($this->attributes, $key, $value); |
57
|
|
|
|
58
|
1 |
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
14 |
|
public function __get($key) |
62
|
|
|
{ |
63
|
14 |
|
return $this->get($key); |
64
|
|
|
} |
65
|
|
|
|
66
|
1 |
|
public function __set($key, $value) |
67
|
|
|
{ |
68
|
1 |
|
$this->set($key, $value); |
69
|
1 |
|
} |
70
|
|
|
} |
71
|
|
|
|