@@ -28,27 +28,27 @@ discard block |
||
28 | 28 | trait SchedulerModelTrait |
29 | 29 | { |
30 | 30 | /** |
31 | - * Define a one-to-many relationship. |
|
32 | - * |
|
33 | - * @param string $related |
|
34 | - * @param string $foreignKey |
|
35 | - * @param string $localKey |
|
36 | - * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
37 | - */ |
|
38 | - abstract public function hasMany($related, $foreignKey = null, $localKey = null); |
|
31 | + * Define a one-to-many relationship. |
|
32 | + * |
|
33 | + * @param string $related |
|
34 | + * @param string $foreignKey |
|
35 | + * @param string $localKey |
|
36 | + * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
37 | + */ |
|
38 | + abstract public function hasMany($related, $foreignKey = null, $localKey = null); |
|
39 | 39 | |
40 | 40 | /** |
41 | - * Get the value of the model's primary key. |
|
42 | - * |
|
43 | - * @return mixed |
|
44 | - */ |
|
41 | + * Get the value of the model's primary key. |
|
42 | + * |
|
43 | + * @return mixed |
|
44 | + */ |
|
45 | 45 | abstract public function getKey(); |
46 | 46 | |
47 | 47 | /** |
48 | - * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait]. |
|
49 | - * |
|
50 | - * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
51 | - */ |
|
48 | + * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait]. |
|
49 | + * |
|
50 | + * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
51 | + */ |
|
52 | 52 | public function schedules() |
53 | 53 | { |
54 | 54 | return $this->hasMany(Config::get('scheduler.schedules_table'), 'model_id'); |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param int $duration Serve para facilitar na hora de buscar horários livres |
97 | 97 | * que precisem ter uma certa duração. |
98 | - * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
99 | - * Se for nulo, ele busca a referencia da config. |
|
98 | + * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
99 | + * Se for nulo, ele busca a referencia da config. |
|
100 | 100 | * @return array |
101 | 101 | */ |
102 | 102 | public function availableToday($duration = 0, $openingTime = null) |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @param string|\Carbon\Carbon $date Data para o qual ele irá fazer a busca. |
111 | 111 | * @param int $duration Serve para facilitar na hora de buscar horários livres |
112 | 112 | * que precisem ter uma certa duração. |
113 | - * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
114 | - * Se for nulo, ele busca a referencia da config. |
|
113 | + * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
114 | + * Se for nulo, ele busca a referencia da config. |
|
115 | 115 | * @return array |
116 | 116 | */ |
117 | 117 | public function availableOn($date, $duration = 0, $openingTime = null) |
@@ -35,21 +35,21 @@ discard block |
||
35 | 35 | * @param string $localKey |
36 | 36 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
37 | 37 | */ |
38 | - abstract public function hasMany($related, $foreignKey = null, $localKey = null); |
|
38 | + abstract public function hasMany ($related, $foreignKey = null, $localKey = null); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Get the value of the model's primary key. |
42 | 42 | * |
43 | 43 | * @return mixed |
44 | 44 | */ |
45 | - abstract public function getKey(); |
|
45 | + abstract public function getKey (); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait]. |
49 | 49 | * |
50 | 50 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
51 | 51 | */ |
52 | - public function schedules() |
|
52 | + public function schedules () |
|
53 | 53 | { |
54 | 54 | return $this->hasMany(Config::get('scheduler.schedules_table'), 'model_id'); |
55 | 55 | } |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | * @throws \H4ad\Scheduler\Exceptions\EndCantBeforeStart |
68 | 68 | * @throws \H4ad\Scheduler\Exceptions\CantAddWithSameStartAt |
69 | 69 | */ |
70 | - public function addSchedule($start_at, $end_at = null, $status = null) |
|
70 | + public function addSchedule ($start_at, $end_at = null, $status = null) |
|
71 | 71 | { |
72 | - if(!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at)) |
|
72 | + if (!Config::get('scheduler.enable_schedule_without_end') && is_null($end_at)) |
|
73 | 73 | throw new CantAddWithoutEnd; |
74 | 74 | |
75 | - $start_at = $this->parseToCarbon($start_at); |
|
75 | + $start_at = $this->parseToCarbon($start_at); |
|
76 | 76 | |
77 | - if(!is_null($end_at)) { |
|
77 | + if (!is_null($end_at)) { |
|
78 | 78 | $end_at = $this->parseToCarbon($end_at, $start_at); |
79 | 79 | |
80 | - if($start_at->greaterThan($end_at)) |
|
80 | + if ($start_at->greaterThan($end_at)) |
|
81 | 81 | throw new EndCantBeforeStart; |
82 | 82 | } |
83 | 83 | |
84 | - if(Scheduler::hasScheduleBetween(self::class, $start_at, $end_at ?? $start_at)) |
|
84 | + if (Scheduler::hasScheduleBetween(self::class, $start_at, $end_at ?? $start_at)) |
|
85 | 85 | throw new CantAddWithSameStartAt; |
86 | 86 | |
87 | 87 | $model_id = $this->getKey(); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * Se for nulo, ele busca a referencia da config. |
100 | 100 | * @return array |
101 | 101 | */ |
102 | - public function availableToday($duration = 0, $openingTime = null) |
|
102 | + public function availableToday ($duration = 0, $openingTime = null) |
|
103 | 103 | { |
104 | 104 | return Scheduler::availableToday(self::class, $duration, $openingTime); |
105 | 105 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * Se for nulo, ele busca a referencia da config. |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - public function availableOn($date, $duration = 0, $openingTime = null) |
|
117 | + public function availableOn ($date, $duration = 0, $openingTime = null) |
|
118 | 118 | { |
119 | 119 | return Scheduler::availableOn(self::class, $date, $duration, $openingTime); |
120 | 120 | } |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @throws \H4ad\Scheduler\Exceptions\IntInvalidArgument |
130 | 130 | */ |
131 | - public function parseToCarbon($date, $reference = null) |
|
131 | + public function parseToCarbon ($date, $reference = null) |
|
132 | 132 | { |
133 | - if($date instanceof Carbon) |
|
133 | + if ($date instanceof Carbon) |
|
134 | 134 | return $date; |
135 | 135 | |
136 | - if(is_string($date)) |
|
136 | + if (is_string($date)) |
|
137 | 137 | return Carbon::parse($date); |
138 | 138 | |
139 | - if(is_int($date) && !is_null($reference)) |
|
139 | + if (is_int($date) && !is_null($reference)) |
|
140 | 140 | return Carbon::parse($reference->toDateTimeString())->addMinutes($date); |
141 | 141 | |
142 | 142 | throw new IntInvalidArgument; |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @param \Carbon\Carbon|string|int $value Valor que representará a data ou o id a ser buscado. |
149 | 149 | * @return \H4ad\Scheduler\Models\Schedule|null |
150 | 150 | */ |
151 | - public function parseToSchedule($value) |
|
151 | + public function parseToSchedule ($value) |
|
152 | 152 | { |
153 | - if(is_int($value)) |
|
153 | + if (is_int($value)) |
|
154 | 154 | return Schedule::find($value); |
155 | 155 | |
156 | 156 | return Schedule::byStartAt($value)->first(); |
@@ -168,17 +168,17 @@ discard block |
||
168 | 168 | * @throws \H4ad\Scheduler\Exceptions\CantRemoveByDate |
169 | 169 | * @throws \H4ad\Scheduler\Exceptions\ModelNotFound |
170 | 170 | */ |
171 | - public function removeSchedule($schedule) |
|
171 | + public function removeSchedule ($schedule) |
|
172 | 172 | { |
173 | - if(!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule)) |
|
173 | + if (!Config::get('scheduler.enable_schedule_conflict') && !is_int($schedule)) |
|
174 | 174 | throw new CantRemoveByDate; |
175 | 175 | |
176 | 176 | $schedule = $this->parseToSchedule($schedule); |
177 | 177 | |
178 | - if(!($schedule instanceof Model)) |
|
178 | + if (!($schedule instanceof Model)) |
|
179 | 179 | throw (new ModelNotFound)->setValues(Schedule::class); |
180 | 180 | |
181 | - if($schedule->model_type != self::class || $schedule->model_id != $this->getKey()) |
|
181 | + if ($schedule->model_type != self::class || $schedule->model_id != $this->getKey()) |
|
182 | 182 | throw new DoesNotBelong; |
183 | 183 | |
184 | 184 | return $schedule->delete(); |
@@ -11,27 +11,27 @@ discard block |
||
11 | 11 | interface SchedulerModelInterface |
12 | 12 | { |
13 | 13 | /** |
14 | - * Define a one-to-many relationship. |
|
15 | - * |
|
16 | - * @param string $related |
|
17 | - * @param string $foreignKey |
|
18 | - * @param string $localKey |
|
19 | - * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
20 | - */ |
|
21 | - abstract public function hasMany($related, $foreignKey = null, $localKey = null); |
|
14 | + * Define a one-to-many relationship. |
|
15 | + * |
|
16 | + * @param string $related |
|
17 | + * @param string $foreignKey |
|
18 | + * @param string $localKey |
|
19 | + * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
20 | + */ |
|
21 | + abstract public function hasMany($related, $foreignKey = null, $localKey = null); |
|
22 | 22 | |
23 | 23 | /** |
24 | - * Get the value of the model's primary key. |
|
25 | - * |
|
26 | - * @return mixed |
|
27 | - */ |
|
24 | + * Get the value of the model's primary key. |
|
25 | + * |
|
26 | + * @return mixed |
|
27 | + */ |
|
28 | 28 | abstract public function getKey(); |
29 | 29 | |
30 | 30 | /** |
31 | - * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait]. |
|
32 | - * |
|
33 | - * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
34 | - */ |
|
31 | + * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait]. |
|
32 | + * |
|
33 | + * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
34 | + */ |
|
35 | 35 | public function schedules(); |
36 | 36 | |
37 | 37 | /** |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @param int $duration Serve para facilitar na hora de buscar horários livres |
56 | 56 | * que precisem ter uma certa duração. |
57 | - * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
58 | - * Se for nulo, ele busca a referencia da config. |
|
57 | + * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
58 | + * Se for nulo, ele busca a referencia da config. |
|
59 | 59 | * @return array |
60 | 60 | */ |
61 | 61 | public function availableToday($duration = 0, $openingTime = null); |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @param string|\Carbon\Carbon $date Data para o qual ele irá fazer a busca. |
67 | 67 | * @param int $duration Serve para facilitar na hora de buscar horários livres |
68 | 68 | * que precisem ter uma certa duração. |
69 | - * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
70 | - * Se for nulo, ele busca a referencia da config. |
|
69 | + * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
70 | + * Se for nulo, ele busca a referencia da config. |
|
71 | 71 | * @return array |
72 | 72 | */ |
73 | 73 | public function availableOn($date, $duration = 0, $openingTime = null); |
@@ -18,21 +18,21 @@ discard block |
||
18 | 18 | * @param string $localKey |
19 | 19 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
20 | 20 | */ |
21 | - abstract public function hasMany($related, $foreignKey = null, $localKey = null); |
|
21 | + abstract public function hasMany ($related, $foreignKey = null, $localKey = null); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Get the value of the model's primary key. |
25 | 25 | * |
26 | 26 | * @return mixed |
27 | 27 | */ |
28 | - abstract public function getKey(); |
|
28 | + abstract public function getKey (); |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait]. |
32 | 32 | * |
33 | 33 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
34 | 34 | */ |
35 | - public function schedules(); |
|
35 | + public function schedules (); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Agenda um horário para esta model. |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @throws \H4ad\Scheduler\Exceptions\CantAddWithSameStartAt |
48 | 48 | * @throws \H4ad\Scheduler\Exceptions\EndCantBeforeStart |
49 | 49 | */ |
50 | - public function addSchedule($start_at, $end_at = null, $status = null); |
|
50 | + public function addSchedule ($start_at, $end_at = null, $status = null); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Exibe uma lista dos horários do dia de hoje. |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * Se for nulo, ele busca a referencia da config. |
59 | 59 | * @return array |
60 | 60 | */ |
61 | - public function availableToday($duration = 0, $openingTime = null); |
|
61 | + public function availableToday ($duration = 0, $openingTime = null); |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Lista os horários livres em um determinado dia. |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * Se for nulo, ele busca a referencia da config. |
71 | 71 | * @return array |
72 | 72 | */ |
73 | - public function availableOn($date, $duration = 0, $openingTime = null); |
|
73 | + public function availableOn ($date, $duration = 0, $openingTime = null); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Faz um parse na data e retorna uma instância em Carbon. |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @throws \H4ad\Scheduler\Exceptions\IntInvalidArgument |
83 | 83 | */ |
84 | - public function parseToCarbon($date, $reference = null); |
|
84 | + public function parseToCarbon ($date, $reference = null); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Faz um parse e retorna um Schedule. |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @param \Carbon\Carbon|string|int $value Valor que representará a data ou o id a ser buscado. |
90 | 90 | * @return \H4ad\Scheduler\Models\Schedule|null |
91 | 91 | */ |
92 | - public function parseToSchedule($value); |
|
92 | + public function parseToSchedule ($value); |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Remove um horário agendado pelo seu ID ou pelo horário em que foi marcado. |
@@ -103,5 +103,5 @@ discard block |
||
103 | 103 | * @throws \H4ad\Scheduler\Exceptions\CantRemoveByDate |
104 | 104 | * @throws \H4ad\Scheduler\Exceptions\ModelNotFound |
105 | 105 | */ |
106 | - public function removeSchedule($schedule); |
|
106 | + public function removeSchedule ($schedule); |
|
107 | 107 | } |
108 | 108 | \ No newline at end of file |