2018-11-02 11:54:46 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2019-01-19 11:35:21 +01:00
|
|
|
use App\Filters\QueryFilters;
|
2018-11-02 11:54:46 +01:00
|
|
|
use Hashids\Hashids;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class BaseModel extends Model
|
|
|
|
{
|
2018-12-13 12:01:33 +01:00
|
|
|
public function __call($method, $params)
|
2018-11-02 11:54:46 +01:00
|
|
|
{
|
2018-12-13 12:01:33 +01:00
|
|
|
$entity = strtolower(class_basename($this));
|
2018-11-02 11:54:46 +01:00
|
|
|
|
2018-12-13 12:01:33 +01:00
|
|
|
if ($entity) {
|
|
|
|
$configPath = "modules.relations.$entity.$method";
|
|
|
|
|
|
|
|
if (config()->has($configPath)) {
|
|
|
|
$function = config()->get($configPath);
|
|
|
|
|
2018-12-15 14:04:46 +01:00
|
|
|
return call_user_func_array(array($this, $function[0]), $function[1]);
|
2018-12-13 12:01:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::__call($method, $params);
|
2018-11-02 11:54:46 +01:00
|
|
|
}
|
2019-01-19 11:35:21 +01:00
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
}
|