furkan bozkurt
furkan bozkurt

Reputation: 173

stripos() expects parameter 1 to be string, object given

This question has been asked many times before. But none of them helped me solve the problem.

This is the query I wrote:

    $this->data['model'] = OrderDetail::with('product')->groupBy(['service_id',function($q){
         return Carbon::parse($q->created_at)->format('Y');
    }]);

    $this->data['data'] = $this->data['model']->paginate(request()->get('limit', $this->data['limit']))->appends(request()->all());

When I perform Paginate operation, I encounter such an error

it gives the same error when I do dd($this->data)

the whole error message:enter image description here

Upvotes: 1

Views: 370

Answers (1)

Costel-Irinel Viziteu
Costel-Irinel Viziteu

Reputation: 46

Are you sure you declared right the variable $this->data['model'] before asigning a value? What is the declaration? Because, from Laravel point of view, the returning Object of OrderDetail is kind of StdClass. If you just redeclare the row like this:

$rowsSelected = OrderDetail::

The variable $rowsSelected will automatically be declared as the right Object. Otherwise you will ever get an error.

later edit, try this:

$this->data['model'] = new \stdClass();

Upvotes: 1

Related Questions