title: Laravel - eloquent: prepare insert method in model
body: <p>I work with laravel 5.3 with eloquent relations engine.</p>
  
  <p>In my controllers I have methods that are inserting data to several related tables. This method is repeated in few places. </p>
  
  <pre><code>TradePartnerData::create([
      'trade_partner_data_type' =&gt; $dataType,
      'trade_partner_id' =&gt; $id,
      'value' =&gt; $value
  ]);
  </code></pre>
  
  <p>I wish to optimize that and I wonder If I could prepare method in my model that takes task of inserting data to database? </p>
  
  <pre><code>/*method in controller that I want*/
  $model = new TradePartnerData();
  $model-&gt;makeSpecialInsert($dataType, $id, $value)
  </code></pre>
  
  <p>Then in controller I only have to call the model method with proper parameters without writing any model's keys.</p>
  
  <p>For now, I just keep in my models eloquent's relations between tables.
  So the question is, how to prepare insert method in model so that I could use:</p>
  
  <p><code>$model-&gt;makeSpecialInsert($dataType, $id, $value)</code></p>
  
  <p>Thanks in advance!</p>