Laravel ORM 常用 Demo

select + where + with + orderBy + paginate

    Post::select('title', 'id')
            ->orderBy('updated_at', 'desc')
            ->with('user')
            ->paginate(20);

注意

1. order 是用orderBy,
2. select 很重要,不填就是相當於select *
3. with是 many to many, one to one, one to many 那種關系