title: Laravel mass assignment to model in Update method in abstract class using foreach loops to fill keys with values
body: <p>How can I be able to create a generic method of the update() function that belongs to an abstract class. To be precise I want it to be able to generate the array $keys and link with the updated $values dynamically, so that different repositories can use this function from this abstract class.</p>
  
  <pre><code>public function update($id, array $data)
  {
  
      $related              = $this-&gt;modelClassInstance-&gt;find($id);
      $related-&gt;name        = $data['name'];
      $related-&gt;description = $data['description'];
      $related-&gt;started_at  = $data['started_at'];
      $related-&gt;ended_at    = $data['ended_at'];
  
      if($related-&gt;save()) {
  
        $response = MyResponse::error(201, true, 'Event sucessfully updated');
  
        return $response;
      } 
      else {
        $response = MyResponse::error(200, false, 'Event unsucessfully updated');
  
        return $response;
      }
  }
  </code></pre>
  
  <p>I need something like this </p>
  
  <pre><code>$data = array(1,2,3,4,5,6,7,8,9);
  
  foreach($data as $key=&gt;$value)
  {
     .....
  }
  </code></pre>
  
  <p>My keys are the name, description, started_at and ended_at, but that means this function is specific to a model . I want this keys to be generated dynamicaly and to get their new values from the data passed. So that any model with any keys can use it.</p>