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');
}
}