定制 nabcellent/codeigniter4-eloquent 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nabcellent/codeigniter4-eloquent

最新稳定版本:v1.1.7

Composer 安装命令:

composer require nabcellent/codeigniter4-eloquent

包简介

The Illuminate/Eloquent package for CodeIgniter 4.

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

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

Installation

Include this package via Composer: Add -W to downgrade psr/container package as Illuminate/container needs that version.

composer require nabcellent/codeigniter4-eloquent -W

Publish config

publish the config file with following spark command

php spark eloquent:publish

Customizing view pagination

The 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

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

More info usefull link docs laravel

Security

If you discover any security related issues, please email nabcellent.dev@gmail.com instead of using the issue tracker.

License

This package is free software distributed under the terms of the MIT license.

统计信息

  • 总下载量: 365
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-18