Editing with X-editable & Laravel

Submitted by baqirfarooq - 7 years ago

X-editable allows you to create editable elements on your page. It can be used with any engine (bootstrap, jquery-ui, jquery only) and includes both popup and inline modes. Let's have a quick look at implementing this in Laravel apps.

Laravel PHP Code
public function updateField(Request $request)
        $this->school->find($request->get('pk'))->update([$request->get('name') => $request->get('value')]);
        return response()->json(['success'=>true)]);

Laravel Blade Code
<a href="#" class="apply_xeditable" data-type="select" data-name="type" data-value="old value" data-pk="1" data-url="{{route('update_field')}}" data-title="Status"></a>

jquery code