title: Laravel 5.2 - edit the data from DB in the Model
body: <p>Can I check and edit data in Model, not in Controller?
  For example, now I get data from Model and work with it in Controller.</p>
  
  <pre><code>$user = User::select('name','privateflag','lastname')-&gt;get();
  //name = John, privateflag = 1, lastname = Smith
  if ($user-&gt;privateflag == 1) {$user-&gt;lastname = 'Private';}
  //Pass to View: name = John, lastname = Private
  </code></pre>
  
  <p>Can I check and edit data in Model and receive in Controller already updated data? Like this:</p>
  
  <pre><code>class User extends ... {
  ...
  //Get from DB: name = John, privateflag = 1, lastname = Smith
  if ($user-&gt;privateflag == 1) {$user-&gt;lastname = 'Private';}
  //Pass to Controller: name = John, lastname = Private
  }
  </code></pre>