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

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 => $friend) … Read more

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

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 => $friend) … Read more

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

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 solved PHP regex to replace … Read more

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

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 solved .BLADE.PHP IS NOT WORKING IN MY LARAVEL PROJECT. .PHP IS WORKING FINE FOR MY VIEWS