skip to Main Content

Route model binding select specific columns with relation – Laravel

Route: Route::get('/posts/{post}', [PostController::class, 'show']); Controller: public function show(Post $post){ $postData = $post->load(['author' => function($query){ $query->select('post_id', 'name'); }]) ->get(['title', 'desc', 'created_date']) ->toArray(); } This returns all the posts in the database, While I only want to get the selected post passed…

VIEW QUESTION

Undefined variable: image while update in laravel

public function update_room_detail(Request $request) { $request->validate([ 'room_type' => 'required', ]); if($images = $request->file('room_image')) { foreach($images as $item): $var = date_create(); $time = date_format($var, 'YmdHis'); $imageName = $time.'-'.$item->getClientOriginalName(); $item->move(public_path().'/assets/images/room', $imageName); $arr[] = $imageName; endforeach; $image = implode("|", $arr); } else {…

VIEW QUESTION
Back To Top
Search