Laravel hasMany method not working
<p>I have 2 tables, <code>users</code> and <code>websites</code>.  One user can have multiple websites assigned to it.</p>

<pre><code>public function websites() {
    return $this-&gt;hasMany('App\Models\Website');
}
</code></pre>

<p>The error I get is:</p>

<p><code>Object of class Illuminate\Database\Eloquent\Relations\HasMany could not be converted to string</code></p>

<p>If I try to output it as an array using <code>print_r</code> I get hundreds of lines of array which I'm assuming is caused by an error somewhere.</p>

<p>Also, why do I have to use <code>App\Models\Website</code> in the <code>hasMany</code> method if I specified at the top of <code>User</code> model <code>use App\Models\Website;</code>?</p>

<p>If I use just <code>Website</code> in the method, I get class not found error:</p>

<p><code>Class 'Website' not found</code></p>

<p>Not a big deal, but it would be much cleaner not to have to use the full namespace path.</p>

<p>The code in the controller:</p>

<pre><code>&lt;?php namespace App\Http\Controllers;

use DB;
use App\User;

class DashboardController extends Controller {

    /*------------------------------------------------------------------
        Dashboard page
    -------------------------------------------------------------------*/
    public function show() {

        //$user = auth()-&gt;user();
        $user = User::find(5);

        return $user-&gt;websites();

        //return view('dashboard');
    }

};
</code></pre>