tinker 抽出、更新、削除

クラスを呼んでいる書き方だが、独特ですな。
[vagrant@localhost myblog]$ php artisan tinker
Psy Shell v0.9.8 (PHP 7.1.21 — cli) by Justin Hileman
>>> App\Post::find(3)->toArray();
=> [
“id” => 3,
“title” => “title 3”,
“body” => “body 3”,
“created_at” => “2018-09-08 23:32:01”,
“updated_at” => “2018-09-08 23:32:01”,
]

>>> App\Post::where(‘id’, ‘>’, 1)->orderBy(‘created_at’,’desc’)->get()->toArray();
=> [
[
“id” => 3,
“title” => “title 3”,
“body” => “body 3”,
“created_at” => “2018-09-08 23:32:01”,
“updated_at” => “2018-09-08 23:32:01”,
],
[
“id” => 2,
“title” => “title 2”,
“body” => “body 2”,
“created_at” => “2018-09-08 23:31:24”,
“updated_at” => “2018-09-08 23:31:24”,
],
]

update
>>> $post = App\Post::find(3);
=> App\Post {#2893
id: “3”,
title: “title 3”,
body: “body 3”,
created_at: “2018-09-08 23:32:01”,
updated_at: “2018-09-08 23:32:01”,
}
>>> $post->title = ‘title 3 updated’;
=> “title 3 updated”
>>> $post->save();
=> true

delete


>>> $post = App\Post::find(3);
=> App\Post {#2908
     id: "3",
     title: "title 3 updated",
     body: "body 3",
     created_at: "2018-09-08 23:32:01",
     updated_at: "2018-09-09 00:18:20",
   }
>>> $post->delete();
=> true
>>> App\Post::all()->toArray();
=> [
     [
       "id" => 1,
       "title" => "title 1",
       "body" => "body 1",
       "created_at" => "2018-09-08 23:21:01",
       "updated_at" => "2018-09-08 23:21:01",
     ],
     [
       "id" => 2,
       "title" => "title 2",
       "body" => "body 2",
       "created_at" => "2018-09-08 23:31:24",
       "updated_at" => "2018-09-08 23:31:24",
     ],
   ]