sudomabider/laravel-xeditable

This package is abandoned and no longer maintained. No replacement package was suggested.

x-editable integration with Laravel

0.1 2017-01-09 01:14 UTC

This package is not auto-updated.

Last update: 2020-08-21 20:40:51 UTC


README

Installation

composer require sudomabider/laravel-xeditable

That's it.

Instructions

  • Have your x-editable based requests extend Sudomabider\LaravelXEditable\XEditableRequest. This class will first validate the initial request to make sure it's a valid x-editable request, and then rearrange the request parameters into a normal form request, e.g. from {name: 'gender', value: 'male'} into {gender: 'male'}

  • You may restrict the names allowed from a request

    protected function allowedEditableNames()
    {
        return ['name', 'gender', 'email'];
    }

    This is particularly useful when multiple x-editable requests are grouped into a single class.

  • Define validation rules as you would in a normal form request:

    public function rules()
    {
        return [
            'email' => 'required|email'
        ];
    }

    You may want to return different rules depending on which parameter is present:

    public function rules()
    {
        if ($this->exists('email')) {
            return [
                'email' => 'required|email'
            ];
        }
        
        if ($this->exists('name')) {
            return [
                'name' => 'required|min:3'
            ];
        }
    }