Laravel5.4 使用 tinker 对文章模型的增删改查
1、创建文章模型:
php artisan make:model Art
2、打开 tinker
php artisan tinker
3、创建文章:
$art=new \App\Art(); App\Art {#706} $art->title ="this is art1"; "this is art1" $art->content="this is art1 content"; "this is art1 content" $art->save(); true
4、查询文章:
4.1根据id查询文章
\App\art::find(2);
4.1根据标题查询文章
\App\Art::where('title','this is title2')->first();
\App\Art::where('title','this is title2')->get();
5、文章删除:
$art = \App\Art::find(2); $art->delete();
文章评论(0)