/** * Constructor function * * @param string|int $field * @param array|string $info * @param Eloquent $model */ public function __construct($field, $info, $model) { parent::__construct($field, $info, $model); $relationship = $model->{$field}(); $this->table = $relationship->table->from; $this->column = $relationship->table->wheres[0]['column']; }
/** * Constructor function * * @param string|int $field * @param array|string $info * @param ModelConfig $config */ public function __construct($field, $info, $config) { parent::__construct($field, $info, $config); //set up the model depending on what's passed in $model = is_a($config, 'Admin\\Libraries\\ModelConfig') ? $config->model : $config; $relationship = $model->{$field}(); $this->table = $relationship->table->from; $this->column = $relationship->table->wheres[0]['column']; }
/** * Constructor function * * @param string|int $field * @param array|string $info * @param Eloquent $model */ public function __construct($field, $info, $model) { parent::__construct($field, $info, $model); $relationship = $model->{$field}(); $table = $relationship->table->joins[0]; $related_model = $relationship->model; $this->table = $table->table; $this->column = $relationship->table->wheres[0]['column']; $this->column2 = $table->clauses[0]['column2']; $this->foreignKey = $related_model::$key; }
/** * Constructor function * * @param string|int $field * @param array|string $info * @param ModelConfig $config */ public function __construct($field, $info, $config) { parent::__construct($field, $info, $config); //set up the model depending on what's passed in $model = is_a($config, 'Admin\\Libraries\\ModelConfig') ? $config->model : $config; $relationship = $model->{$field}(); $table = $relationship->table->joins[0]; $related_model = $relationship->model; $this->table = $table->table; $this->column = $relationship->table->wheres[0]['column']; $this->column2 = $table->clauses[0]['column2']; $this->foreignKey = $related_model::$key; $this->sortField = array_get($info, 'sort_field', $this->sortField); }