-
Notifications
You must be signed in to change notification settings - Fork 2
/
ModifyTimeslotDuration.php
42 lines (34 loc) · 1.09 KB
/
ModifyTimeslotDuration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace App\Console\Commands;
use App\Models\Timeslot;
use Illuminate\Console\Command;
class ModifyTimeslotDuration extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:modify-timeslot-duration {currentDuration} {wantedDuration}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Modifies the duration of a specified type of timeslots';
/**
* Execute the console command.
*/
public function handle()
{
$currentDuration = $this->argument('currentDuration');
$wantedDuration = $this->argument('wantedDuration');
$timeslots = Timeslot::where('duration', $currentDuration);
if ($timeslots->count() == 0) {
$this->error('There are no timeslots with such duration');
return;
}
$timeslots->update(['duration'=>$wantedDuration]);
$this->info("You successfully updated all timeslots from duration of {$currentDuration} to {$wantedDuration}");
}
}