Codeigniter Database package.
This started as a fork from agungsugiarto/codeigniter4-eloquent. Changes include:
- Support for PHP 7.4 and above.
- Updated illuminate/database to 8
- Updated illuminate/pagination to 8
Include this package via Composer: Add -W to downgrade psr/container package as Illuminate/container needs that version.
composer require nabcellent/codeigniter4-eloquent -Wpublish the config file with following spark command
php spark eloquent:publishThe default view for pagination available with preset for bootstrap4 and basic html, if you want to customize
just copy from \vendor\nabcellent\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
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');Example model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Authors extends Model
{
protected $table = 'authors';
protected $primaryKey = 'id';
}<?php
namespace App\Controllers;
use App\Models\Authors;
use Nabz\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(),
]);
}
}If you discover any security related issues, please email nabcellent.dev@gmail.com instead of using the issue tracker.
This package is free software distributed under the terms of the MIT license.