samedi 3 décembre 2016

how to validate data insert to table in Laravel 5.2

I am using addpermission function to save values in to permission table.

public function addPermission(Request $request, $id,  Permission $permission)
    {
         $this->validate($request, [
            'status'   => 'required'


        ]);

        $permission = new Permission;

        $permission->status = $request->input('status');
        $permission->project_id       = $id;
        $permission->collaborator_id =  $request->input('cid');
        $permission->save();
        return redirect()->back()->with('info','Permission has been added to your Collaborator successfully');
}

this is My permiisionadd form action

<form class="form-vertical" role="form" method="post" action="">

                    <input type="hidden" id="cid" name="cid" value="" />
                    <div class="form-group">
                    <label for="status" class="control-label">Choose Permission</label>
                    <select name="status" id="status">
                    <option value="">Choose a status</option>
                    <option value="3">View Only</option>
                    <option value="2">Edit Tasks</option>
                    <option value="1">Admin</option>
                    </select>
                    @if ($errors->has('status'))
                    <span class="help-block"></span>
                    @endif
                    </div>
                      <div class="form-group">
                        <button type="submit" class="btn btn-default">Create</button>
                      </div>
                      <input type="hidden" name="_token" value=""> 

now I need to validate this form if some user add new value to the existing row (generate some message)

how can I do this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire