I want to show Users with most post and thats what i'm do.. I try this in my AppServiceProvider.php:
view()->composer('questions.side2', function($view){
$m = User::leftJoin('questions','users.id','=','questions.user_id')
->selectRaw('users.*, count(questions.user_id) AS total')
->groupBy('users.id')
->orderBy('total','DESC')
->skip(0)
->take(5)
->get();
$view->with('m', $users);
});
In My Side view :
@foreach($m as $user)
@endforeach
but i still have this error: Undefined variable: m (View: C:\wamp\www\qq\resources\views\questions\side.blade.php) (View: C:\wamp\www\qq\resources\views\questions\side.blade.php)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire