laravel5.8 eloquent

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 的优雅性,以后再写

猜你喜欢

转载自www.cnblogs.com/cbugs/p/11248377.html