skip to Main Content

I am getting this error while want to update in the database – Laravel

Missing required parameter for [Route: blog.update] [URI: blog/{post}/update] [Missing parameter: post]. in routes : Route::put('/blog/{post}/update', [BlogController::class, 'update'])->name('blog.update'); in BlogController : ` public function update(Request $request,Post $post){ $request->validate([ 'title' => 'required', 'image' => 'required | image', 'body' => 'required' ]); $postId…

VIEW QUESTION

laravel count relation return Call to a member function addEagerConstraints() on int

I want to get relation: Package::whereIn('id', $cart_items)->with('course')->select('id', 'name')->get(); It return successfully as object, but now I need to count this relation, I did: function courses(){ return $this->hasMany('AppModelsCourse', 'package_id','id'); } public function getCourseCount() { return $this->courses()->count(); } And then: Package::whereIn('id', $cart_items)->with('getCourseCount')->select('id',…

VIEW QUESTION

How do I update data in the database in laravel?

This is the code I have written so far: Here is my Controller that contains the edit and update function: public function edit($id){ $post = Posts::find($id); return view('edit', compact('post')); } public function update(Request $request, $id){ $post = Posts::find($id); $validatedRequests =…

VIEW QUESTION

Auth – get model – Laravel

After using the IlluminateAuthAuthenticatable trait on a model, I can now do Auth::id() in places in my app (when the current auth-ed thing is that particular model). Is there a way to get the class / type of the auth-ed…

VIEW QUESTION
Back To Top
Search