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 | * Get form value from the eloquent model. |
||
31 | * |
||
32 | * @param string $key |
||
33 | * |
||
34 | * @return mixed |
||
35 | */ |
||
36 | 8 | public function getFormValue($key) |
|
50 | |||
51 | /* ------------------------------------------------------------------------------------------------ |
||
52 | | Eloquent Functions |
||
53 | | ------------------------------------------------------------------------------------------------ |
||
54 | */ |
||
55 | /** |
||
56 | * Get an attribute from the $attributes array. |
||
57 | * |
||
58 | * @param string $key |
||
59 | * |
||
60 | * @return mixed |
||
61 | */ |
||
62 | abstract protected function getAttributeFromArray($key); |
||
63 | |||
64 | /** |
||
65 | * Get the attributes that should be converted to dates. |
||
66 | * |
||
67 | * @return array |
||
68 | */ |
||
69 | abstract public function getDates(); |
||
70 | |||
71 | /** |
||
72 | * Return a timestamp as DateTime object. |
||
73 | * |
||
74 | * @param mixed $value |
||
75 | * |
||
76 | * @return \Carbon\Carbon |
||
77 | */ |
||
78 | abstract protected function asDateTime($value); |
||
79 | |||
80 | /* ------------------------------------------------------------------------------------------------ |
||
81 | | Other Functions |
||
82 | | ------------------------------------------------------------------------------------------------ |
||
83 | */ |
||
84 | /** |
||
85 | * Check if has a form mutator. |
||
86 | * |
||
87 | * @param string $key |
||
88 | * |
||
89 | * @return bool |
||
90 | */ |
||
91 | 8 | protected function hasFormMutator($key) |
|
104 | |||
105 | /** |
||
106 | * Mutate the form attribute. |
||
107 | * |
||
108 | * @param string $key |
||
109 | * @param mixed $value |
||
110 | * |
||
111 | * @return mixed |
||
112 | */ |
||
113 | 8 | private function mutateFormAttribute($key, $value) |
|
117 | |||
118 | /** |
||
119 | * Get the mutate form method name. |
||
120 | * |
||
121 | * @param string $key |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | 8 | private function getMutateFromMethodName($key) |
|
129 | |||
130 | /** |
||
131 | * Get a ReflectionClass Instance. |
||
132 | * |
||
133 | * @return ReflectionClass |
||
134 | */ |
||
135 | 8 | protected function getReflection() |
|
143 | } |
||
144 |