Imanol Posted December 1, 2023 Report Share Posted December 1, 2023 Hello, Is it possible to group awards into two classes on the pilot profile page? One for the number of hours and reportes flights and another for awards in general. Thnkas in advance. Quote Link to comment Share on other sites More sharing options...
DisposableHero Posted December 2, 2023 Report Share Posted December 2, 2023 I think this can be done in blade... If you know the codes of awards for hours/pirep counts, then you can alter the foreach loop to show only them at top section (or left section) then the rest at bottom etc. (according to your placing wishes) Quote Link to comment Share on other sites More sharing options...
Imanol Posted December 22, 2023 Author Report Share Posted December 22, 2023 On 12/2/2023 at 4:16 AM, DisposableHero said: I think this can be done in blade... If you know the codes of awards for hours/pirep counts, then you can alter the foreach loop to show only them at top section (or left section) then the rest at bottom etc. (according to your placing wishes) Hi @DisposableHero! I modified the original code to show awards into a Bootstrap grid. I need two of this rows, one for hours/pireps awards and the other one for awards in general, but I don't know how to edit the foreach. Thanks. {{-- Show the user's award if they have any --}} @if (Auth::user()->awards) <div class="row"> <div class="col-sm-12"> @foreach(Auth::user()->awards->chunk(3) as $awards) <div class="row"> @foreach($awards as $award) <div class="col-md-4"> <div class="header header-primary text-center"> @if ($award->image_url) <div class="photo-container"> <img class="img-fluid" src="{{ $award->image_url }}" alt="{{ $award->description }}"> </div> @endif </div> </div> @endforeach </div> <div class="clearfix" style="height: 20px;"></div> @endforeach Quote Link to comment Share on other sites More sharing options...
DisposableHero Posted December 22, 2023 Report Share Posted December 22, 2023 @foreach($awards->whereIn('id', [1,2,3,4]) as $award) You need to know the id numbers of the awards you wish to group for this to work. more info at https://laravel.com/docs/10.x/collections#method-wherein you can use other available methods too. But there is a logical flaw in the code above, Auth always gives you the logged in user. So for example if you place this code to profile index page and then visit my profile, you will see your own awards Hope this helps, good luck Quote Link to comment Share on other sites More sharing options...
Imanol Posted December 28, 2023 Author Report Share Posted December 28, 2023 On 12/22/2023 at 12:56 PM, DisposableHero said: @foreach($awards->whereIn('id', [1,2,3,4]) as $award) You need to know the id numbers of the awards you wish to group for this to work. more info at https://laravel.com/docs/10.x/collections#method-wherein you can use other available methods too. But there is a logical flaw in the code above, Auth always gives you the logged in user. So for example if you place this code to profile index page and then visit my profile, you will see your own awards Hope this helps, good luck I appreciate it. Happy Holidays! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.