Laravel Create Custom Artisan Command with Example
https://www.itsolutionstuff.com/post/laravel-5-create-custom-artisan-command-with-exampleexample.html
Laravel Create Custom Artisan Command with Example
php artisan admins:createphp artisan make:console AdminCommand --command=admins:createnamespace App\Console\Commands;use Illuminate\Console\Command;use Hash;use DB;class AdminCommand extends Command{ /** * The name and signature of the console command. * * @var string */ protected $signature = 'admins:create'; /** * The console command description. * * @var string */ protected $description = 'Command description'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return mixed */ public function handle() { $input['name'] = $this->ask('What is your name?'); $input['email'] = $this->ask('What is your email?'); $input['password'] = $this->secret('What is the password?'); $input['password'] = Hash::make($input['password']); DB::table('admins')->insert($input); $this->info('Admin Create Successfully.'); }}namespace App\Console;use Illuminate\Console\Scheduling\Schedule;use Illuminate\Foundation\Console\Kernel as ConsoleKernel;class Kernel extends ConsoleKernel{ /** * The Artisan commands provided by your application. * * @var array */ protected $commands = [ Commands\AdminCommand::class, ]; /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { }}php artisan listphp artisan admins:createPrevious=== START LARAVEL ADVANCE ===NextCreate Custom Route File, route frontend, route backend? (ok)
Last updated
