title: relationship and blade in laravel
body: <p>I have 3 table as mentioned below.</p>
  
  <pre><code>Table 1(user): 
  id    username   password  Name Age
  
  Table 2(tasks):
  id  task_name  description
  
  Table 3(logs) 
  id user_id task_id date hours
  </code></pre>
  
  <p><strong>Table Relationships:</strong></p>
  
  <pre><code>user has_many logs
  task has_many logs
  
  logs belongs_to user 
  logs belongs_to  task
  </code></pre>
  
  <p>what i am trying to achieve is to get the logs with the user Name, task Name, date and hours.</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>return View::make('log.index')
              -&gt;with('logs',log::all());
  </code></pre>
  
  <p><strong>Blade template</strong></p>
  
  <pre><code>@foreach($logs as $log)
               &lt;tr&gt;
                  &lt;td&gt;{{$log-&gt;id}}&lt;/td&gt;
                  &lt;td&gt;{{$log-&gt;users()-&gt;name}}&lt;/td&gt;
                  &lt;td&gt;{{$log-&gt;tasks()-&gt;name}}&lt;/td&gt;
              &lt;tr&gt;
  @endforeach
  </code></pre>
  
  <p>but unable to fetch users Name and Tasks name from the respective table. any help is appreciated.</p>