Answer the question
In order to leave comments, you need to log in
Why does __construct throw an error?
Good afternoon
Already broke my head, but I can’t understand the reason
There is a test method of the controller
public function testop() {
$toQuery = [
'skip' => 1,
'onPage' => 5,
'sort' => 'desc',
'sortField' => 'id',
'action' => 'miss',
'filter' => 'miss',
'deleteIds' => [],
];
$db = new Querydb('doc_table', $toQuery);
$db->test();
}
public function __construct($dbTableName, $serverParams) {
$this->table = $dbTableName;
$this->skip = $serverParams['skip'];
$this->onPage = $serverParams['onPage'];
$this->sort = $serverParams['sort'];
$this->sortField = $serverParams['sortField'];
$this->action = $serverParams['action'];
$this->filter = $serverParams['filter'];
$this->deleteIds = $serverParams['deleteIds'];
}
public function test() {
$dataDb = $this->where('status', 1)->orderBy($this->sortField, $this->sort)->skip(0)->take($this->onPage)->get();
echo '<pre>';
print_r($dataDb);
exit();
}
Answer the question
In order to leave comments, you need to log in
Your problem is precisely that you are inheriting from Model (Illuminate \ Database \ Eloquent)
And you are prompted with an error on line 392, if you open it, you can see that the creation of an instance is started and an array of attributes is passed to it, and you sharpened the constructor for yourself,
I think you are wrong Do you use Lara Models or Lara in general, can you hear the task itself that you are doing?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question