/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request, Pet $pet) { // $this->validate($request, ['content' => 'required']); $pet->records()->create(['content' => $request->content]); return redirect('/pet/' . $pet->id); }
public function getDoDelete($pets_id) { $pets = \App\Pet::find($pets_id); $pets->delete(); \Session::flash('flash_message', 'Your Pet has been deleted.'); return redirect('/profile'); }
public function getIndex(Request $request) { // Get all the books "owned" by the current logged in users // Sort in descending order by id $pets = \App\Pet::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get(); return view('profile.index')->with('pets', $pets); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function getProfile() { // get profile information $pets = \App\Pet::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get(); //return view('profile.index')->with ('pets', $pets); //echo ('pets', $pets); dump($pets->toArray()); }
public function show($id) { $pet = Pet::find($id); if (!$pet) { return response()->json(['error' => ['message' => 'Pet not found']], 404); } return response()->json(['data' => $this->transform($pet)], 200); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $client = Client::findOrFail($id); $pid = $client->id; $bairro = Bairro::where('id', $client->bairro)->get(); $pets = Pet::where('owner_id', $pid)->get(); $numbers = Number::where('clientid', $pid)->get(); return view('clients.show', compact('client', 'pets', 'bairro', 'numbers')); }
public function flyer($pet_id) { // Get this pet $pet = \App\Pet::find($pet_id); // Convert the photo to base64 $pet->photo = base64_encode(file_get_contents($pet->photo)); $pet->photo = "data:image/jpg;base64," . $pet->photo; // Generate the view, passing it `pet` and `user` $html = view('pdfs.missing')->with('pet', $pet)->with('user', \Auth::user())->render(); //return PDF::load($html)->show(); return $html; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function getIndex() { //You want it to get the pets with a certain status, so the query changes like this $pets = \App\Pet::where('status', '=', 1)->orderBy('id', 'DESC')->get(); return view('index')->with('pets', $pets); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // $pet = Pet::find($id); $pet->update($request->except('id')); return redirect('/pet'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update($id, $cid, CreatePetRequest $request) { $pet = Pet::findOrFail($cid); $pet->update($request->all()); }
/** * Get all of the pets for a given user. * * @param User $user * @return Collection */ public function forUser(User $user) { return Pet::where('user_id', $user->id)->orderBy('created_at', 'desc')->get(); }