skip to Main Content

compact(): Argument #2 must be string or array of strings, IlluminateDatabaseEloquentCollection given – PHP

$maincategory = Category::all(['id', 'category']); $maintable = Category::orderBy('id', 'DESC')->get(); $subcategory = Subcategory::all(['id', 'subcategory']); $subtable = Subcategory::orderBy('id', 'DESC')->get(); return view('admin.news.create', compact('maincategory', $maincategory, 'maintable','subcategory',$subcategory,'subtable')); am getting error on this return view('admin.news.create', compact('maincategory', $maincategory, 'maintable','subcategory',$subcategory,'subtable')); how to solve it?

VIEW QUESTION

How to pass action to Laravel 8 routes?

I was using following Route declaration to pass language action to the routes. Route::get('/de', ['uses' => 'PageController@showHomepage', 'language' => 'de']); And in controller, I was able to get this value like this: $action = $request->route()->getAction(); // $action['language'] gives the given…

VIEW QUESTION

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
Back To Top
Search