Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
#61 Add badges
Browse files Browse the repository at this point in the history
  • Loading branch information
Studio384 committed Apr 2, 2019
1 parent f235b14 commit 614c222
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 3 deletions.
9 changes: 9 additions & 0 deletions app/Helpers/UserHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

function getBadge( $badge ) {
if ($badge) {
?>
<span class="badge badge-<?php echo $badge[1] ?>"><i class="fal <?php echo $badge[0] ?>"></i></span>
<?php
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct()
* @return \Illuminate\Http\Response
*/
public function index(Request $request) {
$request->user()->authorizeRoles(['Admin', 'Insider', 'User']);
$request->user()->authorizeRoles(['Admin', 'Editor', 'Platinum Insider', 'Gold Insider', 'Silver Insider', 'Bronze Insider', 'User']);

return view('profile');
}
Expand All @@ -45,7 +45,7 @@ public function show($id) {
* @return \Illuminate\Http\Response
*/
public function edit(Request $request, $id) {
$request->user()->authorizeRoles(['Admin', 'Insider', 'User']);
$request->user()->authorizeRoles(['Admin', 'Editor', 'Platinum Insider', 'Gold Insider', 'Silver Insider', 'Bronze Insider', 'User']);

$user = User::find($id);

Expand Down
1 change: 1 addition & 0 deletions app/Providers/HelperServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ public function register()
require_once app_path('Helpers/RingHelper.php');
require_once app_path('Helpers/TileHelper.php');
require_once app_path('Helpers/BuildFeedHelper.php');
require_once app_path('Helpers/UserHelper.php');
}
}
12 changes: 12 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,16 @@ public function hasRole($role) {
public function getRoles() {
return $this->roles()->firstOrFail();
}

public function getBadge() {
switch ($this->getRoles()['name']) {
case 'Admin': return ['fa-user-crown', 'admin']; break;
case 'Editor': return ['fa-user-edit', 'editor']; break;
case 'Platinum Insider': return ['fa-crown', 'platinum']; break;
case 'Gold Insider': return ['fa-crown', 'gold']; break;
case 'Silver Insider': return ['fa-crown', 'silver']; break;
case 'Bronze Insider': return ['fa-crown', 'bronze']; break;
default: return null; break;
}
}
}
22 changes: 22 additions & 0 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -10197,6 +10197,28 @@ h3 {
background-color: #fad6cc;
}

.badge {
width: 2.5rem;
line-height: 1rem;
border-radius: 100px;
color: #fff;
}
.badge.badge-admin {
background-color: #ff4355 !important;
}
.badge.badge-platinum {
background-color: #bdcfd4 !important;
}
.badge.badge-gold {
background-color: #ffc000 !important;
}
.badge.badge-silver {
background-color: #9eacbd !important;
}
.badge.badge-bronze {
background-color: #cd7f32 !important;
}

.dropdown-menu {
border: none;
border-radius: 3px;
Expand Down
26 changes: 26 additions & 0 deletions resources/sass/_badge.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.badge {
width: 2.5rem;
line-height: 1rem;
border-radius: 100px;
color: #fff;

&.badge-admin {
background-color: $accent !important;
}

&.badge-platinum {
background-color: #bdcfd4 !important;
}

&.badge-gold {
background-color: $yellow !important;
}

&.badge-silver {
background-color: #9eacbd !important;
}

&.badge-bronze {
background-color: #cd7f32 !important;
}
}
1 change: 1 addition & 0 deletions resources/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@import 'jumbotron';
@import 'modal';
@import 'progress';
@import 'badge';
@import 'dropdown';

// ChangeWindows
Expand Down
2 changes: 1 addition & 1 deletion resources/views/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@section('hero')
<div class="jumbotron">
<div class="container">
<h2>Hello {{ Auth::user()->name }}</h2>
<h2>Hello {{ Auth::user()->name }} {{ getBadge(Auth::user()->getBadge()) }}</h2>
</div>
</div>
@endsection
Expand Down

0 comments on commit 614c222

Please sign in to comment.