創(chuàng)建控制器
php artisan make:controller TestController //創(chuàng)建普通控制器
php artisan make:controller Admin\TestController //在admin下面創(chuàng)建控制器
php artisan make:controller TestController --resource (php artisan make:controller TestController --resource) //創(chuàng)建資源控制器
創(chuàng)建控制器同時(shí)創(chuàng)建模型
php artisan make::controller TestController --model=Test//創(chuàng)建控制器同時(shí)創(chuàng)建模型先創(chuàng)建模型,后創(chuàng)建控制器,并且控制器自動(dòng)引用模型
創(chuàng)建遷移文件
php artisan make:migration create_users_table
//--table 和 --create 選項(xiàng)可用來(lái)指定數(shù)據(jù)表的名稱儿惫,或是該遷移被執(zhí)行時(shí)是否將創(chuàng)建的新數(shù)據(jù)表。這些選項(xiàng)需在預(yù)生成遷移文件時(shí)填入指定的數(shù)據(jù)表:
php artisan make:migration create_users_table --create=users
php artisan make:migration add_votes_to_users_table --table=users
創(chuàng)建模型的同時(shí)創(chuàng)建遷移文件
php artisan make:model ModelName -m //-m表示創(chuàng)建遷移文件
執(zhí)行遷移命令
php artisan migrate
創(chuàng)建中間件
php artisan make:middleware MiddlewareName
路由
Route::resource("test","TestController");//資源路由(一般和資源控制器配合使用)
Route::resource("test","TestController")->only(['index','show']);//只使用這兩個(gè)方法
Route::resource("test","TestController")->except(['destroy']);//排除這兩個(gè)方法
添加驗(yàn)證規(guī)則
php artisan make:request NewsInput
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者