1 | <?php namespace Arcanedev\LaravelHtml\Traits; |
||
12 | trait FormAccessible |
||
13 | { |
||
14 | /* ------------------------------------------------------------------------------------------------ |
||
15 | | Properties |
||
16 | | ------------------------------------------------------------------------------------------------ |
||
17 | */ |
||
18 | /** |
||
19 | * A cached ReflectionClass instance for $this |
||
20 | * |
||
21 | * @var ReflectionClass |
||
22 | */ |
||
23 | protected $reflection; |
||
24 | |||
25 | /* ------------------------------------------------------------------------------------------------ |
||
26 | | Main Functions |
||
27 | | ------------------------------------------------------------------------------------------------ |
||
28 | */ |
||
29 | /** |
||
30 | * @param string $key |
||
31 | * |
||
32 | * @return mixed |
||
33 | */ |
||
34 | 8 | public function getFormValue($key) |
|
53 | |||
54 | /* ------------------------------------------------------------------------------------------------ |
||
55 | | Eloquent Functions |
||
56 | | ------------------------------------------------------------------------------------------------ |
||
57 | */ |
||
58 | /** |
||
59 | * Get an attribute from the $attributes array. |
||
60 | * |
||
61 | * @param string $key |
||
62 | * |
||
63 | * @return mixed |
||
64 | */ |
||
65 | abstract protected function getAttributeFromArray($key); |
||
66 | |||
67 | /** |
||
68 | * Get the attributes that should be converted to dates. |
||
69 | * |
||
70 | * @return array |
||
71 | */ |
||
72 | abstract public function getDates(); |
||
73 | |||
74 | /** |
||
75 | * Return a timestamp as DateTime object. |
||
76 | * |
||
77 | * @param mixed $value |
||
78 | * |
||
79 | * @return \Carbon\Carbon |
||
80 | */ |
||
81 | abstract protected function asDateTime($value); |
||
82 | |||
83 | /* ------------------------------------------------------------------------------------------------ |
||
84 | | Other Functions |
||
85 | | ------------------------------------------------------------------------------------------------ |
||
86 | */ |
||
87 | /** |
||
88 | * Check if has a form mutator. |
||
89 | * |
||
90 | * @param string $key |
||
91 | * |
||
92 | * @return bool |
||
93 | */ |
||
94 | 8 | protected function hasFormMutator($key) |
|
106 | |||
107 | /** |
||
108 | * Mutate the form attribute. |
||
109 | * |
||
110 | * @param string $key |
||
111 | * @param mixed $value |
||
112 | * |
||
113 | * @return mixed |
||
114 | */ |
||
115 | 8 | private function mutateFormAttribute($key, $value) |
|
119 | |||
120 | /** |
||
121 | * Get a ReflectionClass Instance |
||
122 | * |
||
123 | * @return ReflectionClass |
||
124 | */ |
||
125 | 8 | protected function getReflection() |
|
133 | } |
||
134 |