LoginSignup
3
3

More than 5 years have passed since last update.

Cli で `php artisan tinker` とコマンドを実行してDBの内容をPHPArrayな形で出力する

Posted at

多分もっと簡単な方法あると思うけど、こんな感じで。

<?php

>>> \App\Service::orderBy('created_at', 'desc')->take(30)->get()->map(function($obj){ return $obj->toArray(); });
=> <Illuminate\Database\Eloquent\Collection #00000000407506fc000000004d667cc2> [
       [
           "id"         => 1,
           "user_id"    => 1,
           "name"       => "開発中なサービス",
           "created_at" => "2015-05-07 17:21:38",
           "updated_at" => "2015-05-07 17:21:38"
       ]
   ]
>>>

真中部分をコピペでDBSeederにとかとか。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3