php - How to update insert data in laravel 5.2 -
i need if , else function insert record , again update same record in drop , down input. blade view
<input type="hidden" id="cid" name="cid" value="{{ $collaborator->user()->first()->id }}" /> <div class="form-group{{ $errors->has('status') ? ' has-error' : '' }}"> <label for="status" class="control-label">choose permission</label> <select name="status" id="status"> <option value="">choose status</option> <option value="3">view only</option> <option value="2">edit tasks</option> <option value="1">admin</option> </select>
my controller saving new record
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 collaborator successfully'); }
i need update function here
Comments
Post a Comment