public function paper(Request $request) { $this->validate($request, ['id' => 'required', 'type' => 'required|in:1,-1']); $user = Auth::user(); $id = $request->input('id'); $value = $request->input('type'); $paper = Paper::find($id); $isLiked = $this->commit($user, $paper, $id, $value); return ['hasCallback' => 1, 'callback' => 'paper_liked', 'hasMsg' => 0, 'msg' => '', 'msgType' => '', 'returns' => ['num_like' => $paper->num_like, 'num_dislike' => $paper->num_dislike, 'is_liked' => $isLiked]]; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $paper = Paper::find($id); $invoice = \DB::table("invoicing")->where("job_paper_size", "=", $paper->name)->get(); if (count($invoice) > 0) { return response()->json("This Record cannot be deleted!<br>Bill Transactions is already existing against this site"); exit; } if ($paper->delete()) { Session::flash("success_message", "Record Successfully deleted"); echo "Paper Successfully Deleted"; exit; } }
public function updatePaper(Request $request) { Paper::find($request->input('pk'))->update([$request->input('name') => $request->input('value')]); }