Unable to maintain one to many relationship in Eloquent using laravel 5.3
<p>I am using laravel eloquent model so there are three tables tempsocials, tempusers and tempdevices. so one user can have multiple devices and multiple social acounts.
I created a models for three of above table and trying to maintain relationship in between like following</p>

<p><strong>This is my Tempuser model:</strong></p>

<pre><code>namespace App;

use Illuminate\Database\Eloquent\Model;

class Tempuser extends Model
{
    public function tempsocials(){
        return $this-&gt;hasMany('App\Tempsocial');
    }

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

<p><strong>This is my Tempdevice model:</strong></p>

<pre><code> namespace App;

use Illuminate\Database\Eloquent\Model;

class Tempdevice extends Model
{
    public function tempusers(){

        return $this-&gt;belongsTo('App\Tempuser');
    }
}
</code></pre>

<p><strong>And this one is last Tempsocial model:</strong></p>

<pre><code>namespace App;

use Illuminate\Database\Eloquent\Model;

class Tempsocial extends Model
{
    public function tempusers(){

        return $this-&gt;belongsTo('App\Tempuser');
    }
}
</code></pre>

<p><strong>Now this is my controller where i want to retrive all the devices and social accounts of particular user</strong></p>

<pre><code>    namespace App\Http\Controllers;

    use Illuminate\Http\Request;
    use Illuminate\Database\Eloquent\Collection;
    use App\Http\Requests;
    use App\tempLogin;
    use App\Tempdevice;
    use App\Tempuser;
    use App\Tempsocial;

    class loginController extends Controller
    {
        public function check_credentials(Request $request){

          $count=0;

          if($request-&gt;header('content-type')=='application/json'){


            $temp=new Tempuser;
            $devices = $temp-&gt;tempdevices();
            return $devices;

          }
       }
  }
</code></pre>

<p>But i got following error:</p>

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