agungsugiarto/codeigniter4-eloquent

The Illuminate Database package for CodeIgniter 4
4,537 26
Install
composer require agungsugiarto/codeigniter4-eloquent
Latest Version:v2.0.1
PHP:^7.3|^8.0
License:MIT
Last Updated:Mar 22, 2022
Links: GitHub  ·  Packagist
Maintainer: agungsugiarto

The Illuminate Database package for CodeIgniter 4

Latest Stable Version Total Downloads Latest Unstable Version License

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.

Related Packages

bigsinoos/j-eloquent

Convert eloquent date attributes to jalali (Persian) dates on the fly. (support...

4,690 21
laravel/database

Get Laravel database for your non laravel projects. Built on top of illuminate/d...

36,331 90
illuminate/database

The Illuminate Database package.

57,971,266 2,773
t3v/t3v_datamapper

Brings the Database and Validation magic from Laravel to TYPO3.

3,378 3

Version History

Version Released PHP Laravel License
v2.0.1 ^7.3|^8.0 ^8.83 MIT
v2.0.0 ^7.2 ^7.25 MIT
v1.0.2 ^7.2 ^7.22 MIT
v1.0.1 ^7.2 ^7.22 MIT
v1.0.0 ^7.2 ^7.22 MIT
Pre-releases (2)
Version Released PHP Laravel License
v2.0.0-beta-1 ^7.2 ^7.25 MIT
v2.0.0-beta ^7.2 ^7.25 MIT