# laravel command https://blog.johnsonlu.org/laravel-artisan/ https://www.youtube.com/watch?v=-r3WnYy7g48 ## 用命令跑所有想跑的class https://www.youtube.com/watch?v=aZahY16mKpY ## 主要註冊 make:command --command如果沒有打還是可以去$signature更改 基本上都會跑handle 所以會都在這邊使用service ``` <?php namespace App\Console\Commands; use App\Services\Admin\Banner\BannerService; use Illuminate\Console\Command; class BannerStatusValid extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'banner:valid'; /** * The console command description. * * @var string */ protected $description = '變更banner上架狀態'; /** * BannerService. * * @var BannerService */ private $bannerService; /** * Create a new command instance. */ public function __construct(BannerService $bannerService) { parent::__construct(); $this->bannerService = $bannerService; } /** * Execute the console command. * * @return mixed */ public function handle() { $this->bannerService->validStatus(); } } ``` ## 輸入參數 $this->argument()   可以選擇輸入 沒輸入就 ?? Str::random(20)之類的 那如果要讓他mull呢 -- =   獲取參數    ## 進度條 https://www.youtube.com/watch?v=H4mxFUlR1vc&ab_channel=Laratips createProgressBar()  先創立 然後start 再跌代裡面用 advance 結束在用 finish ###### tags: `Laravel`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up