40 lines
930 B
PHP
Executable File
40 lines
930 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* BaseModel replaces the CodeIgniter Model and wires up the legacy builder
|
|
* and database utility that the existing models expect.
|
|
*/
|
|
class BaseModel extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public CiDatabase $db;
|
|
|
|
public function __construct(array $attributes = [])
|
|
{
|
|
parent::__construct($attributes);
|
|
$this->db = CiDatabase::instance();
|
|
}
|
|
|
|
/**
|
|
* Ensure our legacy builder is used so the old helper methods remain available.
|
|
*/
|
|
public function newEloquentBuilder($query)
|
|
{
|
|
return new CiModelBuilder($query);
|
|
}
|
|
|
|
/**
|
|
* Keep the familiar CodeIgniter helper available on the model itself.
|
|
*/
|
|
public function findAll($limit = 0, $offset = 0)
|
|
{
|
|
return $this->newModelQuery()->findAll($limit, $offset);
|
|
}
|
|
}
|