PHP code example of agungsugiarto / codeigniter4-eloquent

1. Go to this page and download the library: Download agungsugiarto/codeigniter4-eloquent library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

agungsugiarto / codeigniter4-eloquent example snippets


php spark eloquent:publish

php spark eloquent:publish

//--------------------------------------------------------------------
// Preload any models, libraries, etc, here.
//--------------------------------------------------------------------
// E.g.:
// $this->session = \Config\Services::session();

service('eloquent');



namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Authors extends Model
{
    protected $table = 'authors';
    protected $primaryKey = 'id';
}


 

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(),
		]);
	}
}