1. Go to this page and download the library: Download ngocnm/laravel_helpers 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/ */
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Ngocnm\LaravelHelpers\eloquent\BaseModel; // add line
class UserLog extends Model
{
use HasFactory,BaseModel;// add line
protected $table = 'user_logs';
}
// Filter request
function getUserBy Api(){
$model = UserLog::baseQueryBuilder(UserLog::class);//add line
...
return $model->get();
}
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Ngocnm\LaravelHelpers\eloquent\BaseModel;
class UserLog extends Model
{
use HasFactory,BaseModel;
protected $table = 'user_logs';
const relationship_device_fields = ['id','name','ip']; // add line
public function device(){ // add function
return $this->belongsTo(Device::class, 'device_id','id');
}
}