title: Laravel Property of non-object error
body: <p>I have met a small hitch in my attempt at understanding laravel and need some help.</p>
  
  <p>I have an "Appointments" model, controller and various views. </p>
  
  <p>Model:
      
  
  <pre><code>class Appointment extends Eloquent {
  
       protected $primaryKey = 'appointment_ID';
       protected $fillable = array('puser_ID', 'apt_date', 'apt_time', 'purpose');
       public $timestamps = false;
  
  
  }
  </code></pre>
  
  <p>Controller:
      
  
  <pre><code>class AppointmentsController extends BaseController{
  
      public $restful = true;
  
      public function getIndex(){
          return View::make('appointments.index')
          -&gt;with('title','Docket: Appointments &amp; Scheduling')
          -&gt;with('appointments', Appointment::OrderBy('apt_time')-&gt;get());
      }
  
      public function getView($appointment_ID){
          return View::make('appointments.view')
          -&gt;with('title', 'Appointment View')
          -&gt;with('appointment', Appointment::find($appointment_ID));
  
      }
      public function getNew(){
          return View::make('appointments.index')
          -&gt;with('title', 'Add A New Appointment');
      }
  }
  </code></pre>
  
  <p>"Add New Appointment" view code:</p>
  
  <pre><code>extends('layouts.default')
  
  @section('content')
      &lt;h1&gt;Add A New Appointment&lt;/h1&gt;
  
      {{ Form::open(array('url'=&gt;'appointments/create', 'method'=&gt;'post')) }}
  
  &lt;p&gt;
      {{Form::label('puserID', 'User ID')}}&lt;br/&gt;
      {{Form::text('puser_ID'}}
  &lt;/p&gt;
  
  &lt;p&gt;
      {{Form::label('aptDate', 'Appointment Date')}}&lt;br/&gt;
      {{Form::text('apt_date')}}
  &lt;/p&gt;        
  
  &lt;p&gt;
      {{Form::label('aptTime', 'Contact Number 1')}}&lt;br/&gt;
      {{Form::text('aptTime'}}
  &lt;/p&gt;
  
  &lt;p&gt; 
      {{Form::label('purpose', 'Purpose of Visit')}}&lt;br/&gt;
      {{Form::text('purpose'}}
  &lt;/p&gt;    
  
  &lt;p&gt; {{Form::submit('Add Appointment')}}&lt;/p&gt;
  
  {{ Form::close() }}
  
  @endsection
  </code></pre>
  
  <p>and my Routes.php file (UPDATED):</p>
  
  <pre><code>Route::get('appointments',array('as'=&gt;'appointments','uses'=&gt;'AppointmentsController@getIndex'));
  
  Route::get('appointments/{appointment_ID}',array('as'=&gt;'appointment','uses'=&gt;'AppointmentsController@getView'));
  
  Route::get('appointments/new',array('as'=&gt;'newAppointment','uses'=&gt;'AppointmentsController@getNew')    );
  </code></pre>
  
  <p>I am trying to go from the "Index" view (listing all appointments) to the "Add New Appointment" view using a button in the index view:</p>
  
  <pre><code>&lt;p&gt;{{ HTML::linkRoute('newAppointment', 'New Appointment') }}&lt;/p&gt;
  </code></pre>
  
  <p>but the code is throwing the "Trying to get property of non-object" Error when I press the "New Appointment" button from the index view.</p>
  
  <p>Please help.</p>
  
  <p>default/layout View as requested:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;{{$title}}&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      @if(Session::has('message'))
          &lt;p style="color: green;"&gt;{{ Session::get('message') }}&lt;/p&gt;
      @endif
  
      @yield('content')
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Error Message:</p>
  
  <pre><code>ErrorException
  Trying to get property of non-object
  open: /Library/WebServer/Documents/laravel-master/app/storage/views/5258152a378521b65c6fd9801aedd9fd
  &lt;?php $__env-&gt;startSection('content'); ?&gt;
  
      &lt;h1&gt;&lt;?php echo e($appointment-&gt;puser_ID); ?&gt;&lt;/h1&gt;
      &lt;p&gt;&lt;small&gt;&lt;?php echo e($appointment-&gt;apt_date); ?&gt;&lt;/small&gt;&lt;/p&gt;
      &lt;p&gt;&lt;small&gt;&lt;?php echo e($appointment-&gt;apt_time); ?&gt;&lt;/small&gt;&lt;/p&gt;
      &lt;p&gt;&lt;small&gt;&lt;?php echo e($appointment-&gt;purpose); ?&gt;&lt;/small&gt;&lt;/p&gt;
  </code></pre>