mercredi 5 octobre 2016

How do I bind a Model Object while using resource controller in Laravel 5.1

What I'm looking for is something like this

public function store(Help $help)
{
    $help->save();

    return response
}

I have added the model class is Routes.php file like this

Route::model('help', 'App\Help');
Route::resource('api/help', 'HelpController');

And this is my Help.php file

class Help extends Model
{
    use SoftDeletes;

    protected $primaryKey = 'id';

    protected $table = 'help';

    protected $dates = ['deleted_at'];

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = array('name','description','deleted_at','created_at', 'updated_at');

}

Binding is happening to an extent, i.e, there is a new row in the table but the attributes "name" and "description" are empty.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire