はじめに
laravelで用意されている簡易的なdebugツールddを紹介。
ddとは
dump and dieの略。処理はここでデータを全て吐き出してくれて、処理は止まる。
https://laravel.com/docs/master/helpers#method-dd
データベースの中身
以下のような状態だとする
routerの設定
1 2 3 |
<?php Route::get('/', 'PostsController@index'); |
Controllerの設定
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Post; class PostsController extends Controller { // public function index(){ $posts = Post::all(); dd($posts->toArray()); return view('posts.index'); } } |
結果