title: Laravel 5.2 save data to m:n table
body: <p>I have problem with saving data to m:n table layout in laravel 5. I have table appliances and table documentations, where pivot table is documentation_appliance.</p>
  
  <p>Models are:</p>
  
  <pre><code>   class Appliances extends Model
      {    
          public function documentations()
          {
              return $this-&gt;belongsToMany('documentations');
          }
  
      }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>class Documentation extends Model
  {
  public function appliances()
  {
      return $this-&gt;belongsToMany('appliances');
  }
  }
  </code></pre>
  
  <p>Now I try to save data to table in my Controller</p>
  
  <pre><code>public function store(Request $request)
  {
      $this-&gt;validate($request, [
          'name' =&gt; 'required|max:255',
          'file_name' =&gt; 'required',
      ]);
  
      if($request-&gt;hasFile('file_name') ) {
          $fname = $request-&gt;file('file_name')-&gt;getClientOriginalName();
          $request-&gt;file('file_name')-&gt;move(
              base_path() . '/public/files/documentation/', $fname
          );
      }
  
      $document = new Documentation();
      $document-&gt;name = $request-&gt;name;
      $document-&gt;filename = $fname;
  
  
      if($document-&gt;save()) {
          $doc_ids = $request-&gt;documentation_appliance;
          $document-&gt;appliances()-&gt;sync($doc_ids);
      }
  
      return view('backend.documentation.index', [
          'documentations' =&gt; $this-&gt;documents-&gt;getDocuments(),
      ]);
  }
  </code></pre>
  
  <p>Data to table documents are saved corectly, image is stored, but I have problem with saving data to pivot table. Screen displays me this error:</p>
  
  <pre><code>FatalErrorException in compiled.php line 10191:
  
  Class 'appliances' not found
  
  in compiled.php line 10191
  </code></pre>
  
  <p>nothing more, I guess I have bad use of class somewhere or am I doing bad something else? Thanks everyone for help.</p>