@@ -15,29 +15,29 @@ |
||
15 | 15 | |
16 | 16 | class CreateScheduleStatusTable extends Migration |
17 | 17 | { |
18 | - /** |
|
19 | - * Run the migrations. |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function up() |
|
24 | - { |
|
25 | - Schema::create(Config::get('scheduler.schedule_status_table'), function (Blueprint $table) { |
|
26 | - $table->increments('id'); |
|
27 | - $table->string('name')->unique(); |
|
28 | - $table->text('description')->nullable(); |
|
29 | - $table->timestamps(); |
|
30 | - $table->softDeletes(); |
|
31 | - }); |
|
32 | - } |
|
18 | + /** |
|
19 | + * Run the migrations. |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function up() |
|
24 | + { |
|
25 | + Schema::create(Config::get('scheduler.schedule_status_table'), function (Blueprint $table) { |
|
26 | + $table->increments('id'); |
|
27 | + $table->string('name')->unique(); |
|
28 | + $table->text('description')->nullable(); |
|
29 | + $table->timestamps(); |
|
30 | + $table->softDeletes(); |
|
31 | + }); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Reverse the migrations. |
|
36 | - * |
|
37 | - * @return void |
|
38 | - */ |
|
39 | - public function down() |
|
40 | - { |
|
41 | - Schema::drop(Config::get('scheduler.schedule_status_table')); |
|
42 | - } |
|
34 | + /** |
|
35 | + * Reverse the migrations. |
|
36 | + * |
|
37 | + * @return void |
|
38 | + */ |
|
39 | + public function down() |
|
40 | + { |
|
41 | + Schema::drop(Config::get('scheduler.schedule_status_table')); |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -15,32 +15,32 @@ |
||
15 | 15 | |
16 | 16 | class CreateSchedulesTable extends Migration |
17 | 17 | { |
18 | - /** |
|
19 | - * Run the migrations. |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function up() |
|
24 | - { |
|
25 | - Schema::create(Config::get('scheduler.schedules_table'), function (Blueprint $table) { |
|
26 | - $table->increments('id'); |
|
27 | - $table->string('model_type'); |
|
28 | - $table->integer('model_id'); |
|
29 | - $table->timestamp('start_at'); |
|
30 | - $table->timestamp('end_at')->nullable(); |
|
31 | - $table->integer('status')->nullable(); |
|
32 | - $table->timestamps(); |
|
33 | - $table->softDeletes(); |
|
34 | - }); |
|
35 | - } |
|
18 | + /** |
|
19 | + * Run the migrations. |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function up() |
|
24 | + { |
|
25 | + Schema::create(Config::get('scheduler.schedules_table'), function (Blueprint $table) { |
|
26 | + $table->increments('id'); |
|
27 | + $table->string('model_type'); |
|
28 | + $table->integer('model_id'); |
|
29 | + $table->timestamp('start_at'); |
|
30 | + $table->timestamp('end_at')->nullable(); |
|
31 | + $table->integer('status')->nullable(); |
|
32 | + $table->timestamps(); |
|
33 | + $table->softDeletes(); |
|
34 | + }); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Reverse the migrations. |
|
39 | - * |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function down() |
|
43 | - { |
|
44 | - Schema::drop(Config::get('scheduler.schedules_table')); |
|
45 | - } |
|
37 | + /** |
|
38 | + * Reverse the migrations. |
|
39 | + * |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function down() |
|
43 | + { |
|
44 | + Schema::drop(Config::get('scheduler.schedules_table')); |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -12,50 +12,50 @@ |
||
12 | 12 | |
13 | 13 | class SchedulerServiceProvider extends ServiceProvider |
14 | 14 | { |
15 | - /** |
|
16 | - * Perform post-registration booting of services. |
|
17 | - * |
|
18 | - * @return void |
|
19 | - */ |
|
20 | - public function boot() |
|
21 | - { |
|
22 | - $this->publishes([ |
|
23 | - __DIR__.'/../config/config.php' => config_path('scheduler.php'), |
|
24 | - ]); |
|
25 | - |
|
26 | - $this->loadMigrationsFrom(__DIR__.'/Migrations'); |
|
27 | - $this->loadTranslationsFrom(__DIR__.'/Translations', 'scheduler'); |
|
28 | - |
|
29 | - $this->publishes([ |
|
30 | - __DIR__.'/Translations' => resource_path('lang/vendor/scheduler'), |
|
31 | - ]); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Register the application services. |
|
36 | - * |
|
37 | - * @return void |
|
38 | - */ |
|
39 | - public function register() |
|
40 | - { |
|
41 | - $this->app->singleton(Scheduler::class, function ($app) { |
|
42 | - return new Scheduler($app); |
|
43 | - }); |
|
44 | - |
|
45 | - $this->app->alias(Scheduler::class, 'scheduler'); |
|
46 | - |
|
47 | - $this->mergeConfig(); |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Mescla configurações do usuário com as configurações do Scheduler. |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - private function mergeConfig() |
|
56 | - { |
|
57 | - $this->mergeConfigFrom( |
|
58 | - __DIR__.'/../config/config.php', 'scheduler' |
|
59 | - ); |
|
60 | - } |
|
15 | + /** |
|
16 | + * Perform post-registration booting of services. |
|
17 | + * |
|
18 | + * @return void |
|
19 | + */ |
|
20 | + public function boot() |
|
21 | + { |
|
22 | + $this->publishes([ |
|
23 | + __DIR__.'/../config/config.php' => config_path('scheduler.php'), |
|
24 | + ]); |
|
25 | + |
|
26 | + $this->loadMigrationsFrom(__DIR__.'/Migrations'); |
|
27 | + $this->loadTranslationsFrom(__DIR__.'/Translations', 'scheduler'); |
|
28 | + |
|
29 | + $this->publishes([ |
|
30 | + __DIR__.'/Translations' => resource_path('lang/vendor/scheduler'), |
|
31 | + ]); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Register the application services. |
|
36 | + * |
|
37 | + * @return void |
|
38 | + */ |
|
39 | + public function register() |
|
40 | + { |
|
41 | + $this->app->singleton(Scheduler::class, function ($app) { |
|
42 | + return new Scheduler($app); |
|
43 | + }); |
|
44 | + |
|
45 | + $this->app->alias(Scheduler::class, 'scheduler'); |
|
46 | + |
|
47 | + $this->mergeConfig(); |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Mescla configurações do usuário com as configurações do Scheduler. |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + private function mergeConfig() |
|
56 | + { |
|
57 | + $this->mergeConfigFrom( |
|
58 | + __DIR__.'/../config/config.php', 'scheduler' |
|
59 | + ); |
|
60 | + } |
|
61 | 61 | } |
62 | 62 | \ No newline at end of file |
@@ -14,33 +14,33 @@ |
||
14 | 14 | |
15 | 15 | class ScheduleStatus extends Model |
16 | 16 | { |
17 | - use SoftDeletes; |
|
17 | + use SoftDeletes; |
|
18 | 18 | |
19 | 19 | /** |
20 | - * Os atributos que podem ser atribuíveis em massa. |
|
21 | - * |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $fillable = [ |
|
25 | - 'name', 'description' |
|
26 | - ]; |
|
20 | + * Os atributos que podem ser atribuíveis em massa. |
|
21 | + * |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $fillable = [ |
|
25 | + 'name', 'description' |
|
26 | + ]; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Os atributos que devem ser transformados para data. |
|
30 | - * |
|
31 | - * @var array |
|
32 | - */ |
|
33 | - protected $dates = [ |
|
34 | - 'deleted_at' |
|
35 | - ]; |
|
28 | + /** |
|
29 | + * Os atributos que devem ser transformados para data. |
|
30 | + * |
|
31 | + * @var array |
|
32 | + */ |
|
33 | + protected $dates = [ |
|
34 | + 'deleted_at' |
|
35 | + ]; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Construtor para inicilizar a váriavel table. |
|
39 | - */ |
|
40 | - public function __construct(array $attributes = []) |
|
41 | - { |
|
42 | - parent::__construct($attributes); |
|
37 | + /** |
|
38 | + * Construtor para inicilizar a váriavel table. |
|
39 | + */ |
|
40 | + public function __construct(array $attributes = []) |
|
41 | + { |
|
42 | + parent::__construct($attributes); |
|
43 | 43 | |
44 | - $this->table = Config::get('scheduler.schedule_status_table'); |
|
45 | - } |
|
44 | + $this->table = Config::get('scheduler.schedule_status_table'); |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -19,13 +19,13 @@ |
||
19 | 19 | */ |
20 | 20 | class Scheduler extends Facade |
21 | 21 | { |
22 | - /** |
|
23 | - * Get the registered name of the component. |
|
24 | - * |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - protected static function getFacadeAccessor() |
|
28 | - { |
|
29 | - return 'scheduler'; |
|
30 | - } |
|
22 | + /** |
|
23 | + * Get the registered name of the component. |
|
24 | + * |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + protected static function getFacadeAccessor() |
|
28 | + { |
|
29 | + return 'scheduler'; |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -10,124 +10,124 @@ |
||
10 | 10 | |
11 | 11 | class CustomException extends \Exception |
12 | 12 | { |
13 | - /** |
|
14 | - * Model que não pertence ao usuário |
|
15 | - * |
|
16 | - * @var mixed |
|
17 | - */ |
|
18 | - protected $model; |
|
19 | - |
|
20 | - /** |
|
21 | - * Key para o arquivo de tradução de exceções. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $trans; |
|
26 | - |
|
27 | - /** |
|
28 | - * HTTP Status Code |
|
29 | - * |
|
30 | - * @var int |
|
31 | - */ |
|
32 | - protected $statusCode; |
|
33 | - |
|
34 | - /** |
|
35 | - * Atributo usado como key para substituir por um texto. |
|
36 | - * |
|
37 | - * @var array|string |
|
38 | - */ |
|
39 | - protected $attributes = 'model'; |
|
40 | - |
|
41 | - /** |
|
42 | - * Diz se o alias será no singular ou no plural. |
|
43 | - * |
|
44 | - * @var string |
|
45 | - */ |
|
46 | - protected $aliastype = 'singular'; |
|
47 | - |
|
48 | - /** |
|
49 | - * Valor passado para o atributo |
|
50 | - * |
|
51 | - * @var array|string|null |
|
52 | - */ |
|
53 | - protected $values = null; |
|
54 | - |
|
55 | - /** |
|
56 | - * Indica se a model será printada com lower case. |
|
57 | - * |
|
58 | - * @var boolean |
|
59 | - */ |
|
60 | - protected $lowercase = false; |
|
61 | - |
|
62 | - /** |
|
63 | - * Construtor da exceção |
|
64 | - * |
|
65 | - * @param mixed $model |
|
66 | - */ |
|
67 | - public function __construct($model = 'foo') |
|
68 | - { |
|
69 | - $this->model = $model; |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * Render the exception as an HTTP response. |
|
74 | - * |
|
75 | - * @return \Illuminate\Http\JsonResponse |
|
76 | - */ |
|
77 | - public function render() |
|
78 | - { |
|
79 | - return response()-> |
|
80 | - /** @scrutinizer ignore-call */ |
|
81 | - json([ |
|
82 | - 'messages' => trans('scheduler::exceptions.'. $this->trans, $this->parseValues()) |
|
83 | - ], $this->statusCode); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Dá parse nos valores para a string de tradução. |
|
88 | - * |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - protected function parseValues() |
|
92 | - { |
|
93 | - if(is_array($this->attributes) && is_array($this->values)) |
|
94 | - return collect($this->attributes)->combine($this->values)->all(); |
|
95 | - |
|
96 | - return [ $this->attributes => $this->values ?? $this->isLower() ]; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Verifica se é lowercase e retorna de acordo. |
|
101 | - * |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - protected function isLower() |
|
105 | - { |
|
106 | - return $this->lowercase ? strtolower($this->getAlias()) : $this->getAlias(); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Retorna o alias da model. |
|
111 | - * |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - protected function getAlias() |
|
115 | - { |
|
116 | - if(is_object($this->model)) |
|
117 | - $this->model = get_class($this->model); |
|
118 | - |
|
119 | - return collect(trans('scheduler::exceptions.aliases.'. $this->aliastype))->search($this->model) ?: 'Recurso'; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Seta os valores. |
|
124 | - * |
|
125 | - * @param mixed $values |
|
126 | - */ |
|
127 | - public function setValues($values) |
|
128 | - { |
|
129 | - $this->values = $values; |
|
130 | - |
|
131 | - return $this; |
|
132 | - } |
|
13 | + /** |
|
14 | + * Model que não pertence ao usuário |
|
15 | + * |
|
16 | + * @var mixed |
|
17 | + */ |
|
18 | + protected $model; |
|
19 | + |
|
20 | + /** |
|
21 | + * Key para o arquivo de tradução de exceções. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $trans; |
|
26 | + |
|
27 | + /** |
|
28 | + * HTTP Status Code |
|
29 | + * |
|
30 | + * @var int |
|
31 | + */ |
|
32 | + protected $statusCode; |
|
33 | + |
|
34 | + /** |
|
35 | + * Atributo usado como key para substituir por um texto. |
|
36 | + * |
|
37 | + * @var array|string |
|
38 | + */ |
|
39 | + protected $attributes = 'model'; |
|
40 | + |
|
41 | + /** |
|
42 | + * Diz se o alias será no singular ou no plural. |
|
43 | + * |
|
44 | + * @var string |
|
45 | + */ |
|
46 | + protected $aliastype = 'singular'; |
|
47 | + |
|
48 | + /** |
|
49 | + * Valor passado para o atributo |
|
50 | + * |
|
51 | + * @var array|string|null |
|
52 | + */ |
|
53 | + protected $values = null; |
|
54 | + |
|
55 | + /** |
|
56 | + * Indica se a model será printada com lower case. |
|
57 | + * |
|
58 | + * @var boolean |
|
59 | + */ |
|
60 | + protected $lowercase = false; |
|
61 | + |
|
62 | + /** |
|
63 | + * Construtor da exceção |
|
64 | + * |
|
65 | + * @param mixed $model |
|
66 | + */ |
|
67 | + public function __construct($model = 'foo') |
|
68 | + { |
|
69 | + $this->model = $model; |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * Render the exception as an HTTP response. |
|
74 | + * |
|
75 | + * @return \Illuminate\Http\JsonResponse |
|
76 | + */ |
|
77 | + public function render() |
|
78 | + { |
|
79 | + return response()-> |
|
80 | + /** @scrutinizer ignore-call */ |
|
81 | + json([ |
|
82 | + 'messages' => trans('scheduler::exceptions.'. $this->trans, $this->parseValues()) |
|
83 | + ], $this->statusCode); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Dá parse nos valores para a string de tradução. |
|
88 | + * |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + protected function parseValues() |
|
92 | + { |
|
93 | + if(is_array($this->attributes) && is_array($this->values)) |
|
94 | + return collect($this->attributes)->combine($this->values)->all(); |
|
95 | + |
|
96 | + return [ $this->attributes => $this->values ?? $this->isLower() ]; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Verifica se é lowercase e retorna de acordo. |
|
101 | + * |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + protected function isLower() |
|
105 | + { |
|
106 | + return $this->lowercase ? strtolower($this->getAlias()) : $this->getAlias(); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Retorna o alias da model. |
|
111 | + * |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + protected function getAlias() |
|
115 | + { |
|
116 | + if(is_object($this->model)) |
|
117 | + $this->model = get_class($this->model); |
|
118 | + |
|
119 | + return collect(trans('scheduler::exceptions.aliases.'. $this->aliastype))->search($this->model) ?: 'Recurso'; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Seta os valores. |
|
124 | + * |
|
125 | + * @param mixed $values |
|
126 | + */ |
|
127 | + public function setValues($values) |
|
128 | + { |
|
129 | + $this->values = $values; |
|
130 | + |
|
131 | + return $this; |
|
132 | + } |
|
133 | 133 | } |
@@ -11,28 +11,28 @@ discard block |
||
11 | 11 | interface SchedulerModelInterface |
12 | 12 | { |
13 | 13 | /** |
14 | - * Define an inverse one-to-one or many relationship. |
|
15 | - * |
|
16 | - * @param string $related |
|
17 | - * @param string $foreignKey |
|
18 | - * @param string $ownerKey |
|
19 | - * @param string $relation |
|
20 | - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
21 | - */ |
|
14 | + * Define an inverse one-to-one or many relationship. |
|
15 | + * |
|
16 | + * @param string $related |
|
17 | + * @param string $foreignKey |
|
18 | + * @param string $ownerKey |
|
19 | + * @param string $relation |
|
20 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
21 | + */ |
|
22 | 22 | abstract public function belongsTo($related, $foreignKey = null, $ownerKey = null, $relation = null); |
23 | 23 | |
24 | 24 | /** |
25 | - * Get the value of the model's primary key. |
|
26 | - * |
|
27 | - * @return mixed |
|
28 | - */ |
|
25 | + * Get the value of the model's primary key. |
|
26 | + * |
|
27 | + * @return mixed |
|
28 | + */ |
|
29 | 29 | abstract public function getKey(); |
30 | 30 | |
31 | 31 | /** |
32 | - * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait]. |
|
33 | - * |
|
34 | - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
35 | - */ |
|
32 | + * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait]. |
|
33 | + * |
|
34 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
35 | + */ |
|
36 | 36 | public function schedules(); |
37 | 37 | |
38 | 38 | /** |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param int $duration Serve para facilitar na hora de buscar horários livres |
57 | 57 | * que precisem ter uma certa duração. |
58 | - * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
59 | - * Se for nulo, ele busca a referencia da config. |
|
58 | + * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
59 | + * Se for nulo, ele busca a referencia da config. |
|
60 | 60 | * @return array |
61 | 61 | */ |
62 | 62 | public function availableToday($duration = 0, $openingTime = null); |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * @param string|\Carbon\Carbon $date Data para o qual ele irá fazer a busca. |
68 | 68 | * @param int $duration Serve para facilitar na hora de buscar horários livres |
69 | 69 | * que precisem ter uma certa duração. |
70 | - * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
71 | - * Se for nulo, ele busca a referencia da config. |
|
70 | + * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
71 | + * Se for nulo, ele busca a referencia da config. |
|
72 | 72 | * @return array |
73 | 73 | */ |
74 | 74 | public function availableOn($date, $duration = 0, $openingTime = null); |
@@ -28,28 +28,28 @@ discard block |
||
28 | 28 | trait SchedulerModelTrait |
29 | 29 | { |
30 | 30 | /** |
31 | - * Define an inverse one-to-one or many relationship. |
|
32 | - * |
|
33 | - * @param string $related |
|
34 | - * @param string $foreignKey |
|
35 | - * @param string $ownerKey |
|
36 | - * @param string $relation |
|
37 | - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
38 | - */ |
|
31 | + * Define an inverse one-to-one or many relationship. |
|
32 | + * |
|
33 | + * @param string $related |
|
34 | + * @param string $foreignKey |
|
35 | + * @param string $ownerKey |
|
36 | + * @param string $relation |
|
37 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
38 | + */ |
|
39 | 39 | abstract public function belongsTo($related, $foreignKey = null, $ownerKey = null, $relation = null); |
40 | 40 | |
41 | 41 | /** |
42 | - * Get the value of the model's primary key. |
|
43 | - * |
|
44 | - * @return mixed |
|
45 | - */ |
|
42 | + * Get the value of the model's primary key. |
|
43 | + * |
|
44 | + * @return mixed |
|
45 | + */ |
|
46 | 46 | abstract public function getKey(); |
47 | 47 | |
48 | 48 | /** |
49 | - * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait]. |
|
50 | - * |
|
51 | - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
52 | - */ |
|
49 | + * Retorna apenas os horários que possuem o mesmo [model_type] do [parent] dessa [trait]. |
|
50 | + * |
|
51 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
52 | + */ |
|
53 | 53 | public function schedules() |
54 | 54 | { |
55 | 55 | return $this->belongsTo(Config::get('scheduler.schedules_table'), 'model_id'); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param int $duration Serve para facilitar na hora de buscar horários livres |
98 | 98 | * que precisem ter uma certa duração. |
99 | - * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
100 | - * Se for nulo, ele busca a referencia da config. |
|
99 | + * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
100 | + * Se for nulo, ele busca a referencia da config. |
|
101 | 101 | * @return array |
102 | 102 | */ |
103 | 103 | public function availableToday($duration = 0, $openingTime = null) |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @param string|\Carbon\Carbon $date Data para o qual ele irá fazer a busca. |
112 | 112 | * @param int $duration Serve para facilitar na hora de buscar horários livres |
113 | 113 | * que precisem ter uma certa duração. |
114 | - * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
115 | - * Se for nulo, ele busca a referencia da config. |
|
114 | + * @param \Carbon\Carbon|null $openingTime Serve como referencia para buscar horários livres. |
|
115 | + * Se for nulo, ele busca a referencia da config. |
|
116 | 116 | * @return array |
117 | 117 | */ |
118 | 118 | public function availableOn($date, $duration = 0, $openingTime = null) |
@@ -19,64 +19,64 @@ |
||
19 | 19 | */ |
20 | 20 | class Schedule extends Model |
21 | 21 | { |
22 | - use SoftDeletes; |
|
22 | + use SoftDeletes; |
|
23 | 23 | |
24 | 24 | /** |
25 | - * Os atributos que podem ser atribuíveis em massa. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $fillable = [ |
|
30 | - 'model_type', 'model_id', 'start_at', 'end_at', 'status' |
|
31 | - ]; |
|
25 | + * Os atributos que podem ser atribuíveis em massa. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $fillable = [ |
|
30 | + 'model_type', 'model_id', 'start_at', 'end_at', 'status' |
|
31 | + ]; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Os atributos que devem ser transformados para data. |
|
35 | - * |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - protected $dates = [ |
|
39 | - 'start_at', 'end_at', 'deleted_at' |
|
40 | - ]; |
|
33 | + /** |
|
34 | + * Os atributos que devem ser transformados para data. |
|
35 | + * |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + protected $dates = [ |
|
39 | + 'start_at', 'end_at', 'deleted_at' |
|
40 | + ]; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Seta um status para o horário agendado. |
|
44 | - * |
|
45 | - * @param int|string $status Pode ser passado o ID do status ou seu nome para seta-lo no horário. |
|
46 | - */ |
|
47 | - public function setStatus($name) |
|
48 | - { |
|
49 | - $this->fill($this->parseStatusKey($name))->save(); |
|
50 | - } |
|
42 | + /** |
|
43 | + * Seta um status para o horário agendado. |
|
44 | + * |
|
45 | + * @param int|string $status Pode ser passado o ID do status ou seu nome para seta-lo no horário. |
|
46 | + */ |
|
47 | + public function setStatus($name) |
|
48 | + { |
|
49 | + $this->fill($this->parseStatusKey($name))->save(); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Retorna o ID do status caso passem o nome do status. |
|
54 | - * |
|
55 | - * @param int|string $key ID ou o nome do status. |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function parseStatusKey($key) |
|
59 | - { |
|
60 | - if(is_int($key)) |
|
61 | - return ['status' => $key]; |
|
52 | + /** |
|
53 | + * Retorna o ID do status caso passem o nome do status. |
|
54 | + * |
|
55 | + * @param int|string $key ID ou o nome do status. |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function parseStatusKey($key) |
|
59 | + { |
|
60 | + if(is_int($key)) |
|
61 | + return ['status' => $key]; |
|
62 | 62 | |
63 | - $status = ScheduleStatus::where('name', $key)->first(); |
|
63 | + $status = ScheduleStatus::where('name', $key)->first(); |
|
64 | 64 | |
65 | - if(is_null($status)) |
|
66 | - throw (new ModelNotFound)->setValues(ScheduleStatus::class); |
|
65 | + if(is_null($status)) |
|
66 | + throw (new ModelNotFound)->setValues(ScheduleStatus::class); |
|
67 | 67 | |
68 | - return ['status' => $status->id]; |
|
69 | - } |
|
68 | + return ['status' => $status->id]; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Escopo de uma consulta que busca horarios pela data de início. |
|
73 | - * |
|
74 | - * @param \Illuminate\Database\Eloquent\Builder $query |
|
75 | - * @param \Carbon\Carbon|string $start_at |
|
76 | - * @return \Illuminate\Database\Eloquent\Builder |
|
77 | - */ |
|
78 | - public function scopeByStartAt($query, $start_at) |
|
79 | - { |
|
80 | - return $query->where('start_at', $start_at); |
|
81 | - } |
|
71 | + /** |
|
72 | + * Escopo de uma consulta que busca horarios pela data de início. |
|
73 | + * |
|
74 | + * @param \Illuminate\Database\Eloquent\Builder $query |
|
75 | + * @param \Carbon\Carbon|string $start_at |
|
76 | + * @return \Illuminate\Database\Eloquent\Builder |
|
77 | + */ |
|
78 | + public function scopeByStartAt($query, $start_at) |
|
79 | + { |
|
80 | + return $query->where('start_at', $start_at); |
|
81 | + } |
|
82 | 82 | } |
83 | 83 | \ No newline at end of file |