使用资源丰富的控制器创建模型

Mig*_*ezv 2 rest laravel laravel-artisan

我知道我可以使用命令创建一个带有控制器的模型,php artisan make:model Task -c我也可以使用php artisan make:controller TasksController -r. 有没有办法用资源丰富的控制器创建模型?

cam*_*ase 5

是的,您可以在不使用包的情况下执行此操作。如果你运行php artisan make:model --help你会发现options你可以添加到命令中。

php artisan make:model --help

Options:
-c, --controller  Create a new controller for the model.
-r, --resource    Indicated if the generated controller should be a resource controller
Run Code Online (Sandbox Code Playgroud)

因此,如果您同时使用 thecrflag运行它,它将生成model,以及一个资源controller

php artisan make:model Task -c -r

注意:这适用于版本>=5.3