0

In my local the return is as expected an object, but in our development box it's returning an array. What configs should I check as to why it's returning an array instead of an object?

The code is \App\Models\TheModel::find($id);

Is this perhaps a model specific problem? Since other calls are returning objects as intended but this specific model on this specific page is having this error.

The Model:

<?php

namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;

class TheModel extends MyBaseModel
{
    use SoftDeletes;

    public $dates         = ['deleted_at'];
}
9
  • Can you share your model class? Commented Sep 27, 2019 at 4:16
  • added it in, it's basically a bare bone model Commented Sep 27, 2019 at 4:24
  • Can you share the controller code where you're implementing \App\Models\TheModel::find($id);? Commented Sep 27, 2019 at 4:30
  • Also which Laravel Version you're using? Commented Sep 27, 2019 at 4:31
  • 1
    what do you get with $model = new TheModel(); dd($model->find($id)); ? Commented Sep 27, 2019 at 5:31

1 Answer 1

1

Maybe in your database.php file of your development box, within fetch you might be using

'fetch' => PDO::FETCH_ASSOC

Just change it to

'fetch' => PDO::FETCH_CLASS
Sign up to request clarification or add additional context in comments.

1 Comment

It's using fetch_class

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.