I get the following error while trying to retrieve a array list which we use to load into the view to create a select list.
Error: Call to undefined method Illuminate\Database\Query\Builder::albums
In our controller we are using following:
$albums = \Auth::user()->albums->lists('name', 'id');
And in model Albums.php we are using:
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Albums
*
*/
class Albums extends Model
{
protected $table = 'albums';
}
In in our main file:
public function albums()
{
return $this->hasMany('App\Models\Albums', 'name', 'id');
}