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

Laravel Undefined array key 1 php artisan serve – PHP Versions

Undefined array key 1 at D:App-PHPxampp_php_8htdocstest-projectvendorlaravelframeworksrcIlluminateFoundationConsoleServeCommand.php:289 285▕ protected function getDateFromLine($line) 286▕ { 287▕ preg_match('/^[([^]]+)]/', $line, $matches); 288▕ ➜ 289▕ return Carbon::createFromFormat('D M d H:i:s Y', $matches[1]); 290▕ } 291▕ 292▕ /** 293▕ * Get the request port from the given…

VIEW QUESTION
Back To Top
Search