jeudi 13 septembre 2018

Laravel scout algolia non object

I'm creating a crud application using laravel and using scout with algolia to perform the search functions. However, when I perform scout:import "App\Majors" it throws a "trying to get property of non-object" error. Below is my model.

class Major extends Model
{
    use Searchable;

    protected $fillable = ['title', 'album', 'lyrics', 'youtube_link'];

    public function toSearchableArray()
    {
        $genres = array_map(function($item) {
            return trim($item);
        }, explode(',', $this->college->genres));

        return array_merge( $this->toArray(), ['college' => $this->college->name, 'photo' => $this->college->photo, 'genres' => $genres]);
    }

    public function college()
    {
        return $this->belongsTo('App\College');
    }
}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2OiXF1a
via IFTTT

Aucun commentaire:

Enregistrer un commentaire