bug_x

导航

 

 

https://learnku.com/docs/laravel/5.8/eloquent/3931

示例1:

$flights = App\Flight::all();

foreach ($flights as $flight) {
    echo $flight->name;
}

函数源码参考: vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php


示例2: 

 

$flights = App\Flight::where('active', 1) ->orderBy('name', 'desc') ->take(10) ->get();

https://learnku.com/docs/laravel/5.8/queries/3926
函数源码参考:
vendor\laravel\framework\src\Illuminate\Database\Concerns\BuildsQueries.php
vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php

以上都是最基本的

eloquent 的优雅性,以后再写

posted on 2019-07-26 09:36  bug_x  阅读(218)  评论(0编辑  收藏  举报