Imanol Posted September 7 Report Posted September 7 (edited) Hello, I would like to create two type of awards: Medals, given to pilots when they reach a certain number of flight hours and PIREPs, and events awards, manually given to pilots when they participate in a event. I need to show up theses awards in pilot profile divided into to groups: Medals and Events. Is there any piece of code I could use to do it? Thanks in advance. Edited September 9 by Imanol Topic solved Quote
DisposableHero Posted September 7 Report Posted September 7 10 hours ago, Imanol said: Hello, I would like to create two type of awards: Medals, given to pilots when they reach a certain number of flight hours and PIREPs, and events awards, manually given to pilots when they participate in a event. I need to show up theses awards in pilot profile divided into to groups: Medals and Events. Is there any piece of code I could use to do it? Thanks in advance. https://github.com/nabeelio/phpvms/blob/dev/modules/Awards/Awards/PilotFlightAwards.php You can check the default award classes to have a better understanding how it works, and then you can create your own classes as you wish. For displaying them separately in pilot profile you need to edit the blade file(s) of your theme as you wish. You can use some filtering within the loops or anything else matching your needs. https://github.com/nabeelio/phpvms/blob/dev/resources/views/layouts/default/profile/index.blade.php Good luck Quote
Imanol Posted September 7 Author Report Posted September 7 Hi @DisposableHero! I understand how award classes works but I don't know how to set them to be shown up in these two groups. I've edited the default skin but awards are show all together. This is the code of my profile/index.blade.php <h3 class="titles">Premios</h3> <hr> @if($user->awards) <div class="row row-cols-2 row-cols-md-4 row-cols-lg-6"> @foreach($user->awards as $award) <div class="col"> <div class="card mb-2"> <img class="img-mh150" src="{{ $award->image_url }}" alt="{{ $award->name }}" title="{{ $award->description }}"> </div> </div> @endforeach </div> @endif <br><br> @endsection Quote
DisposableHero Posted September 8 Report Posted September 8 You can use two different loops to display different awards according to your setup @Imanol @foreach($user->awards->whereIn('id', [1,2,4,5,7,90]) as $awards) https://laravel.com/docs/10.x/collections#available-methods may help Or you can use some basic php functions to check the name, like if it contains some specific words to separate then @if(str_contains($award->description, 'Medal')) Good luck Quote
Imanol Posted September 9 Author Report Posted September 9 Hi @DisposableHero, I really apreaciate your help. I could split awards into groups using this code: @if(str_contains($award->ref_model, 'Modules\Awards\Awards\PilotHoursAwards')) Thus I just have to change the award type in order to show all the awards which belong to the same category. Kind regards! 1 Quote
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.