Laravel eloquent Mass assignment from multi-dimentional array
<p>I'm creating a Restful application, so I'm recieving a POST request that could seem like this</p>

<pre><code>$_POST = array (
'person' =&gt; array (
    'id' =&gt; '1',
    'name' =&gt; 'John Smith',
    'age' =&gt; '45',
    'city' =&gt; array (
        'id' =&gt; '45',
        'name' =&gt; 'London',
        'country' =&gt; 'England',
    ),
),
</code></pre>

<p>);</p>

<p>I would like to save my person model and set its <strong>city_id</strong>.</p>

<p>I know that the easiest way is to set it manually with <strong>$person->city_id = $request['city']['id];</strong> but this way isn't helping me....this code is only an example, in my real code, my model has 15 relationships</p>

<p>Is there any way to make it in a similar such as <strong>$person->fill($request);</strong>?</p>

<p>My models look like:</p>

<p><strong>City</strong></p>

<pre><code>class City extends Model {

    public $timestamps = false;
    public $guarded= ['id'];//Used in order to prevent filling from mass assignment

    public function people(){
        return $this-&gt;hasMany('App\Models\Person', 'city_id');
    }
</code></pre>

<p>}</p>

<p><strong>Person</strong></p>

<pre><code>class Person extends Model {

public $timestamps = false;
public $guarded= ['id'];//Used in order to prevent filling from mass assignment

public function city(){
    return $this-&gt;belongsTo('App\Models\City', 'city_id');
}
public static function savePerson($request){//Im sending a Request::all() from parameter
    $person = isset($request['id']) ? self::find($request['id']) : new self();
    $person-&gt;fill($request);//This won't work since my $request array is multi dimentional
    $person-&gt;save();
    return $person;
}
</code></pre>

<p>}</p>