title: Laravel 4 Eloquent ORM - Symfony \ Component \ Debug \ Exception \ FatalErrorException Cannot redeclare class WorkProcess
body: <p>Here's the scenario!!!  </p>
  
  <p>Schema for (<strong>work_processes</strong>)    </p>
  
  <pre><code>Schema::create('work_processes', function($table){
      $table-&gt;increments('id');
      $table-&gt;enum('wp_type',array('M','F','D')); //M =&gt; Maintenance, F =&gt; Field, D =&gt; Drilling 
      $table-&gt;string('wp_name',50);
      $table-&gt;integer('wp_owner_id');
      $table-&gt;integer('wp_editor_id');
      $table-&gt;text('wp_link');
      $table-&gt;enum('wp_frequency',array('B','M','Q')); //B =&gt; Bi-Monthly, M =&gt; Monthly, Q =&gt; Quarterly 
      $table-&gt;date('wp_startdate');
      $table-&gt;date('wp_enddate');
      $table-&gt;enum('wp_active',array('Y','N'));
      $table-&gt;timestamp('deleted_at')-&gt;nullable();
      $table-&gt;timestamps();
  });}
  </code></pre>
  
  <p>Schema for (<strong>wp_audit_questions</strong>)  </p>
  
  <pre><code>Schema::create('wp_audit_questions', function($table){
      $table-&gt;increments('id');
      $table-&gt;integer('wp_id');
      $table-&gt;text('wp_audit_question');
      $table-&gt;timestamps();
  });
  </code></pre>
  
  <p>Model 1 as (<strong>WorkProcess</strong>)  </p>
  
  <pre><code>class WorkProcess extends Eloquent
  {
      protected $table = 'work_processes';
      protected $guarded = array('id');
      protected $softDelete = true;
  
      public function wpauditquestions()
      {
          return $this-&gt;hasMany('WpAuditQuestion');
      }
  }
  </code></pre>
  
  <p>Model 2 as (<strong>WpAuditQuestion</strong>)  </p>
  
  <pre><code>class WpAuditQuestion extends Eloquent
  {
      protected $table = 'wp_audit_questions';
      public function workprocess()
      {
          return $this-&gt;belongsTo('WorkProcess', 'wp_id');
      }
  }
  </code></pre>
  
  <p>'Controller as (<strong>WorkProcessController</strong>)  </p>
  
  <pre><code>class WorkProcessController extends BaseController
  {
      public function ShowWpAuditQuestionEditForm($wpid)
      {
          $wp = WorkProcess::with(array('wpauditquestions' =&gt; function($query){
              $query-&gt;where('wp_id', $wpid);
          }))-&gt;get();
          return View::make('wpauditquestion')-&gt;with(array('edit_mode' =&gt; 1, 'wpauditquestion' =&gt; $wpauditquestion));
      }
  }
  </code></pre>
  
  <p>'Controller as (<strong>WpAuditQuestionController</strong>)  </p>
  
  <pre><code>class WpAuditQuestionController extends BaseController
  {
      public function ShowWPAuditQuestionForm()
      {
          $wpauditquestion = new WpAuditQuestion();
                  return View::make('wpauditquestion', compact('wpauditquestion'));
       }
  }
  </code></pre>
  
  <p><strong>Routes.php</strong>  </p>
  
  <pre><code>//model binding
  Route::model('workprocess', 'WorkProcess');
  Route::model('wpauditquestion', 'WpAuditQuestion');
  
  Route::get('wpauditquestion/edit/{wpid}', array('uses' =&gt; 'WorkProcessController@ShowWpAuditQuestionEditForm', 'as' =&gt; 'wpauditquestion.edit'));
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>This script generates this error message. e.g. MY_SERVER/wpauditquestion/edit/1  </p>
  
  <blockquote>
    <p><strong>Symfony \ Component \ Debug \ Exception \ FatalErrorException<br>
    Cannot redeclare class WorkProcess</strong>  </p>
  </blockquote>
  
  <p>however, when I don't use the get() or any other method like paginate(5) etc, it does dump some data.  </p>
  
  <p>I have also tried this but same result.  </p>
  
  <pre><code>$wp = WorkProcess::has('wpauditquestions')-&gt;get();  
  </code></pre>
  
  <p>can someone please guide me what wrong I'm doing. I'm using laravel 4.0.7 with WAMP.  </p>
  
  <p>Also please guide me how to save this model after editing it e.g. if I have a form like this.  </p>
  
  <pre><code>{{ Form::open(array('action' =&gt; 'WorkProcessController@PostWorkProcessEditForm', 'method' =&gt; 'put')) }}
  {{-- Work Process Name --}}
  {{ Form::hidden('wp_id') }}
  &lt;ol&gt;
  @for($i = 0; $i &lt; 5; $i++)
      &lt;p&gt;
          &lt;li&gt; 
              {{ Form::label('wp_audit_question', 'Audit Question') }}
              {{ Form::text('wp_audit_question', Input::old('wp_audit_question')) }}
      &lt;/p&gt;
  @endfor
  &lt;/ul&gt;
  &lt;p&gt;{{ Form::submit('Submit Form', array('id' =&gt; 'Submit_Form')) }}&lt;/p&gt;
  {{ Form::close() }}  
  </code></pre>
  
  <p>Thanks and Regards</p>