skip to Main Content

Pass variable to view via controller in Laravel

I need help with passing the variable I have initialized using __construct() to view in Laravel. Here is my controller code protected $profileInfo; public function __construct(){ $this->profileInfo = Profile::with('address')->where('id', '=', '1')->get(); } public function index(){ $this->profileInfo; return view('admin_pages.profile', compact('profileInfo')); }…

VIEW QUESTION

laravel leftjoin on json

I have Raw query running as select meeting.id, GROUP_CONCAT(users.name separator " | ") AS present_user_id from `meeting` left join `users` on JSON_CONTAINS(meeting.present_user_id, JSON_ARRAY(users.id), '$') group by `meeting`.`id` Which provide proper result, I tried to convert same in Laravel 8 like…

VIEW QUESTION

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