agungsugiarto/codeigniter4-eloquent
Composer 安装命令:
composer require agungsugiarto/codeigniter4-eloquent
包简介
The Illuminate Database package for CodeIgniter 4
README 文档
README
Update from v1.x to 2.x
just simple publish config eloquent with command
php spark eloquent:publish
Instalation
Include this package via Composer:
composer require agungsugiarto/codeigniter4-eloquent
Publish config
php spark eloquent:publish
Costuming view pagination
The default view for pagination available with preset for bootstrap4 and basic html, if you want to costumize
just copy from \vendor\agungsugiarto\codeigniter4-eloquent\src\Views\Bootstrap4.php and modify with your style after that put on folder App\Views. Finnaly change your config in App\Config\Eloquent.php
Setup services eloquent
Open App\Controllers\BaseController.php
add service('eloquent'); on function initController
//-------------------------------------------------------------------- // Preload any models, libraries, etc, here. //-------------------------------------------------------------------- // E.g.: // $this->session = \Config\Services::session(); service('eloquent');
Usage
Example model
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Authors extends Model { protected $table = 'authors'; protected $primaryKey = 'id'; }
How to use in controller
<?php namespace App\Controllers; use App\Models\Authors; use Fluent\Models\DB; class Home extends BaseController { public function index() { return $this->response->setJSON([ 'data' => Authors::all(), 'sample' => DB::table('authors')->skip(1)->take(100)->get(), ]); } }
More info usefull link docs laravel
License
This package is free software distributed under the terms of the MIT license.
统计信息
- 总下载量: 4.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-04