分享 推播通知
目前身份: 訪客

就是用model::all(),就可以取得這個資料表的所有的資料

Controller

app\Http\Controllers\TodoController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Posts;

class TodoController extends Controller
{
    public function index()
    {
        $posts = Posts::all();

        dd($posts);

        return view('todo.index');
    }

    public function update(Request $request)
    {
        // $posts = new Posts();
        // $posts->post_name = $request->post_name;
        // $posts->save();

        // $obj = Posts::create([
        //     'post_name' => $request->post_name
        // ]);

        $obj = Posts::create($request->all());

        return $obj;
    }
}

dd() 就會列出來collection的資料

範例如下

 

 

 

 

 


 

2
人氣 3514
職場技能 發表在 留言 (0) 人氣 (3514)
Laravel 學習
分享給朋友
網址

想對外分享這則貼文嗎?運用網址更方便呦~

載入中...