Laravel 中 offset,limit , skip,take 的使用

一、offset,limit (offset 表示设置从哪里开始,limit 表示设置想要查询多少条数据) $data['schools']=DB::table('zs_school')->offset($page)->limit($pageSize)->lists(); 二、skip,take (skip 跳过几条,take 取多少条数据) Model::skip(3)->take(3)->get();

read more..

Laravel中间件权限认证模块

先在app目录下面的Middleware目录新增Rightsvalidates.php文件 <?php namespace app\Http\Middleware; use Closure; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; class Rightsvalidates { public function handle($request, Closure $next) { $admin = Auth::guard('admin')->user(); $role =DB::table('admin_group')->where('gid',$ad...

read more..

laravel扩展方法的使用,数据库操作

在App/Http/Providers目录下面新增DbServiceProvider.php 完整代码如下: <?php namespace App\Providers; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Support\ServiceProvider; class DbServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { ...

read more..