Skip to content
Kevin Upton edited this page Nov 30, 2017 · 1 revision

HasAutoHydration allows for the model to be automatically filled with the request inputs.

Example

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Kevupton\Ethereal\Traits\HasAutoHydration;

class Example extends Model
{
    use HasAutoHydration;
}

So that if I post that data:

{
  "name": "tester",
  "description": "hello"
}

The Example model will be automatically filled with the attributes name and description on create. Allowing me to simply go:

Example::create();
Clone this wiki locally