| @@ 9-54 (lines=46) @@ | ||
| 6 | use Illuminate\Console\Command; |
|
| 7 | use Mockery\Exception; |
|
| 8 | ||
| 9 | class DestroyTaskCommand extends Command |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * The name and signature of the console command. |
|
| 13 | * |
|
| 14 | * @var string |
|
| 15 | */ |
|
| 16 | protected $signature = 'task:destroy {id? : The Task id}'; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * The console command description. |
|
| 20 | * |
|
| 21 | * @var string |
|
| 22 | */ |
|
| 23 | protected $description = 'This command is used to delete a Task.'; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Create a new command instance. |
|
| 27 | * |
|
| 28 | * @return void |
|
| 29 | */ |
|
| 30 | public function __construct() |
|
| 31 | { |
|
| 32 | parent::__construct(); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * Execute the console command. |
|
| 37 | * |
|
| 38 | * @return mixed |
|
| 39 | */ |
|
| 40 | public function handle() |
|
| 41 | { |
|
| 42 | try { |
|
| 43 | $id = $this->argument('id') ? $this->argument('id') : $this->ask('Event id?'); |
|
| 44 | $count = Task::destroy($id); |
|
| 45 | } catch (Exception $e) { |
|
| 46 | $this->error('error'.$e); |
|
| 47 | } |
|
| 48 | if ($count == 0) { |
|
| 49 | $this->alert('Task does not exist'); |
|
| 50 | } else { |
|
| 51 | $this->info('Task has been deleted to database succesfully'); |
|
| 52 | } |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 8-53 (lines=46) @@ | ||
| 5 | use App\User; |
|
| 6 | use Illuminate\Console\Command; |
|
| 7 | ||
| 8 | class DestroyUserCommand extends Command |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * The name and signature of the console command. |
|
| 12 | * |
|
| 13 | * @var string |
|
| 14 | */ |
|
| 15 | protected $signature = 'user:destroy {id? : The user id}'; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * The console command description. |
|
| 19 | * |
|
| 20 | * @var string |
|
| 21 | */ |
|
| 22 | protected $description = 'This command destroy an existing user by id'; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Create a new command instance. |
|
| 26 | * |
|
| 27 | * @return void |
|
| 28 | */ |
|
| 29 | public function __construct() |
|
| 30 | { |
|
| 31 | parent::__construct(); |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Execute the console command. |
|
| 36 | * |
|
| 37 | * @return mixed |
|
| 38 | */ |
|
| 39 | public function handle() |
|
| 40 | { |
|
| 41 | try { |
|
| 42 | $id = $this->argument('id') ? $this->argument('id') : $this->ask('User id?'); |
|
| 43 | $count = User::destroy($id); |
|
| 44 | } catch (Exception $e) { |
|
| 45 | $this->error('error'.$e); |
|
| 46 | } |
|
| 47 | if ($count == 0) { |
|
| 48 | $this->alert('User does not exist'); |
|
| 49 | } else { |
|
| 50 | $this->info('User has been deleted to database succesfully'); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | } |
|
| 54 | ||