[Solved] How to print key value pair in Laravel using foreach loop [closed]

[ad_1] Your code is a mess. here is a cleaner version without using the models (since you did not say if they are in place) Controller Code public function show_friend_request() { $user_id = auth()->user()->id; $senderIds = DB::table(‘friendships’)->where(‘recipient_id’, $user_id)->where(‘status’, ‘pending’)->pluck(‘sender_id’)->toArray(); $activeRequests = DB::table(‘users’) ->whereIn(‘id’, $senderIds) ->get([‘first_name’,’last_name’]); return view(‘pages.friend_request’)->with(‘activeRequest’, $activeRequests); } Blade Code @foreach($activeRequest as $key => … Read more

[Solved] Printing key value pair in Laravel blade using for each loop [closed]

[ad_1] Your code is a mess. here is a cleaner version without using the models (since you did not say if they are in place) Controller Code public function show_friend_request() { $user_id = auth()->user()->id; $senderIds = DB::table(‘friendships’)->where(‘recipient_id’, $user_id)->where(‘status’, ‘pending’)->pluck(‘sender_id’)->toArray(); $activeRequests = DB::table(‘users’) ->whereIn(‘id’, $senderIds) ->get([‘first_name’,’last_name’]); return view(‘pages.friend_request’)->with(‘activeRequest’, $activeRequests); } Blade Code @foreach($activeRequest as $key => … Read more

[Solved] PHP regex to replace words starting with @ end ending with 2 spaces [closed]

[ad_1] Match a word beginning with a @, reset matching output, match more than one whitespace afterwards then do a replacement: preg_replace(‘~@\w+\K\s{2,}~’, ‘ ‘, $input_string); Regex explanation: @\w+ # Match a `@` fowlling a word \K # Reset matching process output \s{2,} # Match double or more whitespaces PHP live demo [ad_2] solved PHP regex … Read more

[Solved] .BLADE.PHP IS NOT WORKING IN MY LARAVEL PROJECT. .PHP IS WORKING FINE FOR MY VIEWS

[ad_1] All I can suggest on the information you provided is: Make sure when you put your views inside other folders you use dot syntax and not slashes like this: View::make(‘folder.view’); Instead of View::make(‘folder/view’); Folder Structure: |views| –|folder| —-view.blade.php 0 [ad_2] solved .BLADE.PHP IS NOT WORKING IN MY LARAVEL PROJECT. .PHP IS WORKING FINE FOR … Read more

[Solved] I want to see the product_name. Error is – Property [product_name] does not exist on this collection instance. (abc.blade.php)

[ad_1] I want to see the product_name. Error is – Property [product_name] does not exist on this collection instance. (abc.blade.php) [ad_2] solved I want to see the product_name. Error is – Property [product_name] does not exist on this collection instance. (abc.blade.php)