toArray可以转变为数组
toSql可以看当前查询语句
-
模型之读
App\User::all(); // 返回包含所有对象的集合 // 以下方法虽然返回的是对象,但是直接可以以数组方式(如:$a[0])取值 \App\User::where('name', 'John')->first(); // 返回第一条数据的对象 \App\User::where('id', 1)->value('name'); // 返回name字段的值(string) \App\User::find(3); // 返回主键等于 3 的对象 \App\User::find([1, 2]); // 返回主键等于 1 和 2 的对象的集合 \App\User::pluck('age'); // 返回包含字段值的对象的集合 \App\User::pluck('age', 'id'); // 返回关联对象的集合 id => age,pluck 最多 2 个参数 \App\User::count(); // 返回记录总数 \App\User::max('id'); // 返回数字,库没有任何记录返回 null \App\User::min('id'); // 返回数字,库没有任何记录返回 null \App\User::avg('age'); // 返回数字,库没有任何记录返回 null,同名 averge \App\User::sum('salary'); // 返回数字,库没有任何记录返回 0
-
where
where('votes', '=', 100) where('votes', 100) where('name', 'like', 'T%&