From 3612b5718e7cf4709d54ee29a390030eb18cf25c Mon Sep 17 00:00:00 2001 From: Zlimon Date: Thu, 24 Dec 2020 15:52:32 +0100 Subject: [PATCH 01/39] Random icon for user seed --- database/seeds/UserSeeder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/database/seeds/UserSeeder.php b/database/seeds/UserSeeder.php index 73c52786..08147b5d 100644 --- a/database/seeds/UserSeeder.php +++ b/database/seeds/UserSeeder.php @@ -16,6 +16,7 @@ public function run() 'name' => 'Simon', 'email' => 'simon@runemanager.com', 'password' => bcrypt('runemanager1234'), + 'icon_id' => Helper::randomItemId(true), ]); } } From 5ccfcb15ed34df1dfc652c6477c6b90419d15df2 Mon Sep 17 00:00:00 2001 From: Zlimon Date: Thu, 24 Dec 2020 15:54:36 +0100 Subject: [PATCH 02/39] Notification Category --- app/NotificationCategory.php | 12 ++++++ ...7_create_notification_categories_table.php | 40 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 app/NotificationCategory.php create mode 100644 database/migrations/2020_12_24_135237_create_notification_categories_table.php diff --git a/app/NotificationCategory.php b/app/NotificationCategory.php new file mode 100644 index 00000000..0c880885 --- /dev/null +++ b/app/NotificationCategory.php @@ -0,0 +1,12 @@ +hasMany(Notification::class); + } +} diff --git a/database/migrations/2020_12_24_135237_create_notification_categories_table.php b/database/migrations/2020_12_24_135237_create_notification_categories_table.php new file mode 100644 index 00000000..9fb0eec9 --- /dev/null +++ b/database/migrations/2020_12_24_135237_create_notification_categories_table.php @@ -0,0 +1,40 @@ +id(); + $table->string('category'); + }); + + DB::table('notification_categories')->insert( + [ + ["category" => "skill"], + ["category" => "boss"], + ["category" => "raid"], + ["category" => "account"], + ] + ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('notification_categories'); + } +} From 8981b8ac475b0fe5ccf104a4af9ebc3faba75f12 Mon Sep 17 00:00:00 2001 From: Zlimon Date: Sun, 27 Dec 2020 02:21:39 +0100 Subject: [PATCH 03/39] Notification rework - Account based notifications - Home page notifications - Separated between account based and overall notifications - Notification alert redesign --- app/Account.php | 4 ++ app/Events/AccountKill.php | 7 +- app/Events/AccountLevelUp.php | 7 +- app/Events/AccountNewUnique.php | 7 +- app/Events/All.php | 40 +++++++++++ .../Controllers/Api/AccountLootController.php | 42 ++++++++--- .../Api/AccountSkillController.php | 32 ++++++--- .../Api/NotificationController.php | 29 ++++++++ app/Notification.php | 20 +++++- ...1_04_105532_create_notifications_table.php | 6 +- resources/js/app.js | 2 + .../js/components/AccountNotification.vue | 59 ++++++++++++++++ resources/js/components/AllNotification.vue | 37 ++++++++++ resources/js/components/Notification.vue | 47 +++++-------- resources/views/account/show.blade.php | 10 ++- resources/views/home.blade.php | 69 ++++++++++--------- resources/views/layouts/layout.blade.php | 2 +- routes/api.php | 5 ++ 18 files changed, 332 insertions(+), 93 deletions(-) create mode 100644 app/Events/All.php create mode 100644 app/Http/Controllers/Api/NotificationController.php create mode 100644 resources/js/components/AccountNotification.vue create mode 100644 resources/js/components/AllNotification.vue diff --git a/app/Account.php b/app/Account.php index 0d404db0..24c4dc13 100644 --- a/app/Account.php +++ b/app/Account.php @@ -18,4 +18,8 @@ class Account extends Model public function user() { return $this->belongsTo(User::class); } + + public function notification() { + return $this->hasMany(Notification::class); + } } diff --git a/app/Events/AccountKill.php b/app/Events/AccountKill.php index 6dfd1a83..894cf680 100644 --- a/app/Events/AccountKill.php +++ b/app/Events/AccountKill.php @@ -10,6 +10,9 @@ use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; +use App\Account; +use App\Notification; + class AccountKill implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; @@ -21,9 +24,9 @@ class AccountKill implements ShouldBroadcast * * @return void */ - public function __construct($notification) + public function __construct(Account $account, Notification $notification) { - $this->notification = $notification; + $this->notification = $notification::with('category')->where('account_id', $account->id)->orderBy('id', 'DESC')->first(); } /** diff --git a/app/Events/AccountLevelUp.php b/app/Events/AccountLevelUp.php index ce3c3f1c..3ef0bafe 100644 --- a/app/Events/AccountLevelUp.php +++ b/app/Events/AccountLevelUp.php @@ -10,6 +10,9 @@ use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; +use App\Account; +use App\Notification; + class AccountLevelUp implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; @@ -21,9 +24,9 @@ class AccountLevelUp implements ShouldBroadcast * * @return void */ - public function __construct($notification) + public function __construct(Account $account, Notification $notification) { - $this->notification = $notification; + $this->notification = $notification::with('category')->where('account_id', $account->id)->orderBy('id', 'DESC')->first(); } /** diff --git a/app/Events/AccountNewUnique.php b/app/Events/AccountNewUnique.php index a57c7dda..e5d91d76 100644 --- a/app/Events/AccountNewUnique.php +++ b/app/Events/AccountNewUnique.php @@ -10,6 +10,9 @@ use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; +use App\Account; +use App\Notification; + class AccountNewUnique implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; @@ -21,9 +24,9 @@ class AccountNewUnique implements ShouldBroadcast * * @return void */ - public function __construct($notification) + public function __construct(Account $account, Notification $notification) { - $this->notification = $notification; + $this->notification = $notification::with('category')->where('account_id', $account->id)->orderBy('id', 'DESC')->first(); } /** diff --git a/app/Events/All.php b/app/Events/All.php new file mode 100644 index 00000000..c1d949fc --- /dev/null +++ b/app/Events/All.php @@ -0,0 +1,40 @@ +notification = $notification::with('category')->orderBy('id', 'DESC')->first(); + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new Channel('all'); + } +} diff --git a/app/Http/Controllers/Api/AccountLootController.php b/app/Http/Controllers/Api/AccountLootController.php index 3e3f68fd..3db32856 100644 --- a/app/Http/Controllers/Api/AccountLootController.php +++ b/app/Http/Controllers/Api/AccountLootController.php @@ -7,7 +7,9 @@ use App\Account; use App\Collection; +use App\Notification; +use App\Events\All; use App\Events\AccountNewUnique; use App\Events\AccountKill; @@ -41,14 +43,24 @@ public function update($accountUsername, $collectionName, Request $request) { if ($oldValues[$lootType] == 0) { $uniques++; + $dataJson = '{"loot":'.json_encode([$lootType => 0]).'}'; + + $data = json_decode($dataJson, true); + $notificationData = [ - "category" => "boss", - "name" => $collectionName, - "loot" => [$lootType => 0], - "message" => $accountUsername." unlocked a new unique!" + "user_id" => auth()->user()->id, + "account_id" => $account->id, + "category_id" => 2, + "icon" => $collectionName, + "message" => $accountUsername." unlocked a new unique!", + "data" => $data ]; - AccountNewUnique::dispatch($notificationData); + $notification = Notification::create($notificationData); + + All::dispatch($notification); + + AccountNewUnique::dispatch($account, $notification); } $sums[$lootType] = (isset($newValues[$lootType]) ? $newValues[$lootType] : 0) + (isset($oldValues) ? $oldValues[$lootType] : 0); @@ -61,14 +73,24 @@ public function update($accountUsername, $collectionName, Request $request) { $loot = array_diff_key($sums, ["id" => 0, "account_id" => 0, "kill_count" => 0, "rank" => 0, "obtained" => 0, "created_at" => 0, "updated_at" => 0]); + $dataJson = '{"loot":'.json_encode($loot).'}'; + + $data = json_decode($dataJson, true); + $notificationData = [ - "category" => "boss", - "name" => $collectionName, - "loot" => $loot, - "message" => $accountUsername." defeated ".$collectionName."" + "user_id" => auth()->user()->id, + "account_id" => $account->id, + "category_id" => 2, + "icon" => $collectionName, + "message" => $accountUsername." defeated ".$collection->alias."", + "data" => $data ]; - AccountKill::dispatch($notificationData); + $notification = Notification::create($notificationData); + + All::dispatch($notification); + + AccountKill::dispatch($account, $notification); return response()->json($collectionLog, 200); } else { diff --git a/app/Http/Controllers/Api/AccountSkillController.php b/app/Http/Controllers/Api/AccountSkillController.php index a7face5b..e5fe897e 100644 --- a/app/Http/Controllers/Api/AccountSkillController.php +++ b/app/Http/Controllers/Api/AccountSkillController.php @@ -7,6 +7,8 @@ use Illuminate\Support\Facades\DB; use App\Account; +use App\Notification; +use App\Events\All; use App\Events\AccountLevelUp; class AccountSkillController extends Controller @@ -14,19 +16,29 @@ class AccountSkillController extends Controller public function update($accountUsername, $skillName, Request $request) { $account = Account::where('user_id', auth()->user()->id)->where('username', $accountUsername)->first(); - DB::table($skillName)->where('account_id', $account->id)->increment('level', 1/*, ["xp" => $request->xp]*/); + if ($account) { + DB::table($skillName)->where('account_id', $account->id)->increment('level', 1/*, ["xp" => $request->xp]*/); - $skill = DB::table($skillName)->where('account_id', $account->id)->first(); + $skill = DB::table($skillName)->where('account_id', $account->id)->first(); - $notificationData = [ - "category" => "skill", - "name" => $skillName, - "loot" => [], - "message" => $accountUsername." just achieved level ".$skill->level." ".ucfirst($skillName)."!".($skill->level === 92 ? " Half way there :)" : "") - ]; + $notificationData = [ + "user_id" => auth()->user()->id, + "account_id" => $account->id, + "category_id" => 1, + "icon" => $skillName, + "message" => $accountUsername." just achieved level ".$skill->level." ".ucfirst($skillName)."!".($skill->level === 92 ? " Half way there!" : ""), + "data" => null + ]; - AccountLevelUp::dispatch($notificationData); + $notification = Notification::create($notificationData); - return response()->json($skill, 200); + All::dispatch($notification); + + AccountLevelUp::dispatch($account, $notification); + + return response()->json($skill, 200); + } else { + return response("This account is not authenticated with " . auth()->user()->name, 401); + } } } diff --git a/app/Http/Controllers/Api/NotificationController.php b/app/Http/Controllers/Api/NotificationController.php new file mode 100644 index 00000000..66003e43 --- /dev/null +++ b/app/Http/Controllers/Api/NotificationController.php @@ -0,0 +1,29 @@ +orderBy('id', 'DESC')->limit(5)->get(); + + return response()->json($notifications, 200); + } + + public function show($accountUsername) { + $account = Account::where('username', $accountUsername)->pluck('user_id')->first(); + + $notifications = Notification::with('category')->where('account_id', $account)->orderBy('id', 'DESC')->paginate(10); + + return response()->json($notifications, 200); + } +} diff --git a/app/Notification.php b/app/Notification.php index 107f0ad1..ef5b1cdb 100644 --- a/app/Notification.php +++ b/app/Notification.php @@ -6,5 +6,23 @@ class Notification extends Model { - // + protected $fillable = [ + 'user_id', 'account_id', 'category_id', 'icon', 'message', 'data' + ]; + + protected $casts = [ + 'data' => 'array' + ]; + + public function user() { + return $this->belongsTo(User::class); + } + + public function account() { + return $this->belongsTo(Account::class); + } + + public function category() { + return $this->belongsTo(NotificationCategory::class); + } } diff --git a/database/migrations/2020_11_04_105532_create_notifications_table.php b/database/migrations/2020_11_04_105532_create_notifications_table.php index 278a5529..35bafa4b 100644 --- a/database/migrations/2020_11_04_105532_create_notifications_table.php +++ b/database/migrations/2020_11_04_105532_create_notifications_table.php @@ -15,10 +15,12 @@ public function up() { Schema::create('notifications', function (Blueprint $table) { $table->id(); + $table->integer('user_id')->unsigned(); $table->integer('account_id')->unsigned(); - $table->enum('category', ['boss', 'skill']); - $table->json('data'); + $table->integer('category_id')->unsigned(); + $table->string('icon'); $table->string('message'); + $table->text('data')->nullable(); $table->timestamps(); }); } diff --git a/resources/js/app.js b/resources/js/app.js index 58a8d6f1..754737ce 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -28,6 +28,8 @@ Vue.component('bosshiscore', require('./components/BossHiscore.vue').default); Vue.component('accounthiscore', require('./components/AccountHiscore.vue').default); Vue.component('accountskillhiscore', require('./components/AccountSkillHiscore.vue').default); Vue.component('accountbosshiscore', require('./components/AccountBossHiscore.vue').default); +Vue.component('allnotification', require('./components/AllNotification.vue').default); +Vue.component('accountnotification', require('./components/AccountNotification.vue').default); Vue.component('notification', require('./components/Notification.vue').default); Vue.component( diff --git a/resources/js/components/AccountNotification.vue b/resources/js/components/AccountNotification.vue new file mode 100644 index 00000000..389f11c7 --- /dev/null +++ b/resources/js/components/AccountNotification.vue @@ -0,0 +1,59 @@ + + + \ No newline at end of file diff --git a/resources/js/components/AllNotification.vue b/resources/js/components/AllNotification.vue new file mode 100644 index 00000000..7ec0a9ee --- /dev/null +++ b/resources/js/components/AllNotification.vue @@ -0,0 +1,37 @@ + + + \ No newline at end of file diff --git a/resources/js/components/Notification.vue b/resources/js/components/Notification.vue index b1967236..d0b80567 100644 --- a/resources/js/components/Notification.vue +++ b/resources/js/components/Notification.vue @@ -2,23 +2,23 @@
-
-
-
-
- -
+
+
+
+ +
-
-

{{ notification.message }}

-
+
+

{{ notification.message }}

+
-
-

Received loot:

-
-
- +
+
+

Received loot:

+
+
+
@@ -36,23 +36,8 @@ \ No newline at end of file diff --git a/resources/views/account/show.blade.php b/resources/views/account/show.blade.php index e0e0999a..36c24530 100644 --- a/resources/views/account/show.blade.php +++ b/resources/views/account/show.blade.php @@ -11,7 +11,15 @@ Profile icon
- +
+
+ +
+ +
+ +
+
@else
Sad face diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 6a83179a..e7e879cf 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -7,15 +7,8 @@ @section('content')
-
-
- Profile icon -
- Edit profile -
-
- -
+
+ Profile icon

Welcome, {{ Auth::user()->name }}

Joined: {{ \Carbon\Carbon::parse($user->created_at)->format('d. M Y') }}

@@ -33,42 +26,56 @@ Ignore icon Private @endif + +

Edit profile

-
-

Accounts

+
+
+
+

Accounts

-
+
- @foreach ($user->account as $account) -
-
-

@if ($account->account_type != "normal")Account type icon@endif{{ $account->username }}

-
+ @foreach ($user->account as $account) +
+
+

@if ($account->account_type != "normal")Account type icon@endif{{ $account->username }}

+
-
- Total level: -
- {{ $account->level }} -
-
+
+ Total level: +
+ {{ $account->level }} +
+
-
- @endforeach +
+ @endforeach -
@foreach ($user->account as $account)
- +
+
+ +
+ +
+ +
+
@endforeach
@endsection \ No newline at end of file diff --git a/resources/views/layouts/layout.blade.php b/resources/views/layouts/layout.blade.php index 67d5ba69..9b02a4b0 100644 --- a/resources/views/layouts/layout.blade.php +++ b/resources/views/layouts/layout.blade.php @@ -89,7 +89,7 @@

Notifications

- +
diff --git a/routes/api.php b/routes/api.php index a6c689b1..178832e2 100644 --- a/routes/api.php +++ b/routes/api.php @@ -44,4 +44,9 @@ Route::prefix('/collection')->group(function() { Route::get('/{collectionType}', 'CollectionController@list'); +}); + +Route::prefix('/notification')->group(function() { + Route::get('/all', 'Api\NotificationController@index')->name('notification-show-all'); + Route::get('/account/{accountUsername}', 'Api\NotificationController@show')->name('notification-account-show'); }); \ No newline at end of file From 0e1d3a98f43a230605c10716a9b1848a8fd7d482 Mon Sep 17 00:00:00 2001 From: Zlimon Date: Sun, 27 Dec 2020 02:33:34 +0100 Subject: [PATCH 04/39] Icon fix and if not null check fix --- resources/js/components/Notification.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/js/components/Notification.vue b/resources/js/components/Notification.vue index d0b80567..3f7cd89e 100644 --- a/resources/js/components/Notification.vue +++ b/resources/js/components/Notification.vue @@ -5,7 +5,7 @@
- +
@@ -13,12 +13,12 @@
-
+

Received loot:

- +
From 226e0b001dbec0bf3842f20eec51ff5cdbc76d03 Mon Sep 17 00:00:00 2001 From: Zlimon Date: Sun, 27 Dec 2020 10:16:16 +0100 Subject: [PATCH 05/39] Correct account notification fix - Added AccountAll notification channel --- app/Events/AccountAll.php | 41 +++++++++++++++++++ .../Controllers/Api/AccountLootController.php | 5 +++ .../Api/AccountSkillController.php | 3 ++ .../Api/NotificationController.php | 2 +- .../js/components/AccountNotification.vue | 14 +------ 5 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 app/Events/AccountAll.php diff --git a/app/Events/AccountAll.php b/app/Events/AccountAll.php new file mode 100644 index 00000000..e2a68a94 --- /dev/null +++ b/app/Events/AccountAll.php @@ -0,0 +1,41 @@ +notification = $notification::with('category')->where('account_id', $account->id)->orderBy('id', 'DESC')->first(); + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new Channel('account-all'); + } +} diff --git a/app/Http/Controllers/Api/AccountLootController.php b/app/Http/Controllers/Api/AccountLootController.php index 3db32856..5bce8cce 100644 --- a/app/Http/Controllers/Api/AccountLootController.php +++ b/app/Http/Controllers/Api/AccountLootController.php @@ -10,6 +10,7 @@ use App\Notification; use App\Events\All; +use App\Events\AccountAll; use App\Events\AccountNewUnique; use App\Events\AccountKill; @@ -60,6 +61,8 @@ public function update($accountUsername, $collectionName, Request $request) { All::dispatch($notification); + AccountAll::dispatch($account, $notification); + AccountNewUnique::dispatch($account, $notification); } @@ -90,6 +93,8 @@ public function update($accountUsername, $collectionName, Request $request) { All::dispatch($notification); + AccountAll::dispatch($account, $notification); + AccountKill::dispatch($account, $notification); return response()->json($collectionLog, 200); diff --git a/app/Http/Controllers/Api/AccountSkillController.php b/app/Http/Controllers/Api/AccountSkillController.php index e5fe897e..5d666230 100644 --- a/app/Http/Controllers/Api/AccountSkillController.php +++ b/app/Http/Controllers/Api/AccountSkillController.php @@ -9,6 +9,7 @@ use App\Account; use App\Notification; use App\Events\All; +use App\Events\AccountAll; use App\Events\AccountLevelUp; class AccountSkillController extends Controller @@ -34,6 +35,8 @@ public function update($accountUsername, $skillName, Request $request) { All::dispatch($notification); + AccountAll::dispatch($account, $notification); + AccountLevelUp::dispatch($account, $notification); return response()->json($skill, 200); diff --git a/app/Http/Controllers/Api/NotificationController.php b/app/Http/Controllers/Api/NotificationController.php index 66003e43..d8c8f390 100644 --- a/app/Http/Controllers/Api/NotificationController.php +++ b/app/Http/Controllers/Api/NotificationController.php @@ -20,7 +20,7 @@ public function index() { } public function show($accountUsername) { - $account = Account::where('username', $accountUsername)->pluck('user_id')->first(); + $account = Account::where('username', $accountUsername)->pluck('id')->first(); $notifications = Notification::with('category')->where('account_id', $account)->orderBy('id', 'DESC')->paginate(10); diff --git a/resources/js/components/AccountNotification.vue b/resources/js/components/AccountNotification.vue index 389f11c7..e5e511b3 100644 --- a/resources/js/components/AccountNotification.vue +++ b/resources/js/components/AccountNotification.vue @@ -38,18 +38,8 @@ }, created() { - window.Echo.channel('account') - .listen('AccountKill', (e) => { - if (this.checkAccount(e.notification.account_id)) { - this.notificationsData.unshift(e.notification); - } - }) - .listen('AccountNewUnique', (e) => { - if (this.checkAccount(e.notification.account_id)) { - this.notificationsData.unshift(e.notification); - } - }) - .listen('AccountLevelUp', (e) => { + window.Echo.channel('account-all') + .listen('AccountAll', (e) => { if (this.checkAccount(e.notification.account_id)) { this.notificationsData.unshift(e.notification); } From 232cb07f6ebd36640502b4d8c8b6e424e3019c29 Mon Sep 17 00:00:00 2001 From: Zlimon Date: Sun, 27 Dec 2020 10:32:08 +0100 Subject: [PATCH 06/39] Changing from user username to "Profile" --- resources/views/layouts/layout.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/layouts/layout.blade.php b/resources/views/layouts/layout.blade.php index 9b02a4b0..ded806cf 100644 --- a/resources/views/layouts/layout.blade.php +++ b/resources/views/layouts/layout.blade.php @@ -64,7 +64,7 @@ @endif @else
@@ -25,7 +25,7 @@ class="icon" Bosses icon + title="Click here to see the boss hiscores">
Bosses
From f8c50504fd95979793de7a26a79fc734a9a60805 Mon Sep 17 00:00:00 2001 From: Zlimon Date: Tue, 29 Dec 2020 18:51:29 +0100 Subject: [PATCH 31/39] Icon radio box hover texture --- public/css/style.css | 45 +++++++++++++++++++----- resources/views/account/create.blade.php | 6 ++-- resources/views/account/index.blade.php | 2 +- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index 2544bfa0..89d290f9 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -265,8 +265,6 @@ table th right, bottom, center; - - image-rendering: pixelated; } .background-world-map:hover @@ -359,15 +357,44 @@ table th .icon-radio [type=radio] + img:hover { - border-radius: 5px; - background: #99855d; + background: url('/resource-packs/pack-osrs-dark/button/world_map_metal_corner_top_left.png') no-repeat, /* top left */ + url('/resource-packs/pack-osrs-dark/button/world_map_metal_corner_top_right.png') no-repeat, /* top right */ + url('/resource-packs/pack-osrs-dark/button/world_map_metal_corner_bottom_left.png') no-repeat, /* bottom left */ + url('/resource-packs/pack-osrs-dark/button/world_map_metal_corner_bottom_right.png') no-repeat, /* bottom right */ + url('/resource-packs/pack-osrs-dark/button/world_map_edge_top.png') repeat-x, /* top */ + url('/resource-packs/pack-osrs-dark/button/world_map_edge_left.png') repeat-y, /* left */ + url('/resource-packs/pack-osrs-dark/button/world_map_edge_right.png') repeat-y, /* right */ + url('/resource-packs/pack-osrs-dark/button/world_map_edge_bottom.png') repeat-x, /* bottom */ + url('/resource-packs/pack-osrs-dark/dialog/background.png'); /* body */ + background-position: top left, + top right, + bottom left, + bottom right, + top 0 left, + left 0 top 10px, + right, + bottom, + center; } .icon-radio [type=radio]:checked + img { - padding: 5px 5px 5px 5px; - - border: solid #755b41 3px; - border-radius: 5px; - background: #99855d; + background: url('/resource-packs/pack-osrs-dark/button/world_map_metal_corner_top_left.png') no-repeat, /* top left */ + url('/resource-packs/pack-osrs-dark/button/world_map_metal_corner_top_right.png') no-repeat, /* top right */ + url('/resource-packs/pack-osrs-dark/button/world_map_metal_corner_bottom_left.png') no-repeat, /* bottom left */ + url('/resource-packs/pack-osrs-dark/button/world_map_metal_corner_bottom_right.png') no-repeat, /* bottom right */ + url('/resource-packs/pack-osrs-dark/button/world_map_edge_top.png') repeat-x, /* top */ + url('/resource-packs/pack-osrs-dark/button/world_map_edge_left.png') repeat-y, /* left */ + url('/resource-packs/pack-osrs-dark/button/world_map_edge_right.png') repeat-y, /* right */ + url('/resource-packs/pack-osrs-dark/button/world_map_edge_bottom.png') repeat-x, /* bottom */ + url('/resource-packs/pack-osrs-dark/dialog/background_brighter.png'); /* body */ + background-position: top left, + top right, + bottom left, + bottom right, + top 0 left, + left 0 top 10px, + right, + bottom, + center; } diff --git a/resources/views/account/create.blade.php b/resources/views/account/create.blade.php index bcf65f99..f5b1aaf3 100644 --- a/resources/views/account/create.blade.php +++ b/resources/views/account/create.blade.php @@ -32,12 +32,12 @@ @endif From 08d34e93e78e101f9e931d04898210b00945e728 Mon Sep 17 00:00:00 2001 From: Zlimon Date: Tue, 29 Dec 2020 19:53:36 +0100 Subject: [PATCH 32/39] Display nothing when no news are posted --- resources/views/index.blade.php | 104 +++++++++++++++++--------------- 1 file changed, 55 insertions(+), 49 deletions(-) diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 9124e45a..25dd52a4 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -34,13 +34,11 @@ @else
- @if (Auth::user()->icon_id) - Profile icon - @endif + Profile icon {{ Auth::user()->name }}
@@ -113,50 +111,58 @@ class="pixel icon"
-
-

Latest news and updates

- - @forelse ($recentPosts as $post) -
-
-
-
- - '{{ $post->title }}' news post image - -
-
-
- -
-

{{ $post->user->name }} | {{ $post->category->category }}

+ @if ($recentPosts->isNotEmpty()) +
+

Latest news and updates

+ + @foreach ($recentPosts as $post) +
+
+
+
+ + '{{ $post->title }}' news post image + +
-
- {{ $post->shortstory }} -

Read more

+
+ +
+

{{ $post->user->name }} | {{ $post->category->category }}

+
+
+ {{ $post->shortstory }} +

+ + + Read more + + +

+
-
-
-
- {{ \Carbon\Carbon::parse($post->created_at)->format('M') }} -
- {{ \Carbon\Carbon::parse($post->created_at)->format('d') }} +
+
+ {{ \Carbon\Carbon::parse($post->created_at)->format('M') }} +
+ {{ \Carbon\Carbon::parse($post->created_at)->format('d') }} +
-
-
- @empty -

test

- @endforelse - - @if (!empty($recentPosts)) - Read more - @endif -
+
+ + @if ($loop->last) + + Read more + + @endif + @endforeach +
+ @endif @endsection From 9ace95c0a7f6e2e1217238e8e4fed817556b8cd6 Mon Sep 17 00:00:00 2001 From: Zlimon Date: Tue, 29 Dec 2020 21:14:18 +0100 Subject: [PATCH 33/39] Helper cleanup --- app/Helpers/Helper.php | 98 ++++++------------------------------------ 1 file changed, 14 insertions(+), 84 deletions(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 6681d230..a45003bb 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -2,12 +2,8 @@ namespace App\Helpers; -use App\Account; use App\Collection; -use Carbon\Carbon; use DateTime; -use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\DB; class Helper { @@ -26,6 +22,11 @@ public static function roundToNextHour() return $nextHour; } + public static function collectionAttribute($collection, $attribute) + { + return Collection::where('name', $collection)->value($attribute); + } + /** * Generates a valid random item ID. * @@ -33,7 +34,7 @@ public static function roundToNextHour() */ public static function randomItemId($verify = false) { - $randomItemId = rand(0, 25000); + $randomItemId = rand(0, 25317); if ($verify) { if (self::verifyItem($randomItemId)) { @@ -88,7 +89,7 @@ public static function verifyUrl($url) /* If the document has loaded successfully without any redirection or error */ if ($httpCode >= 200 && $httpCode < 300) { - return true; + return $response; } else { return false; } @@ -110,75 +111,6 @@ public static function itemData($itemId, $attribute) return $itemData[0][$attribute]; } - /** - * Returns the account ID for currently logged in user. - * - * @return - */ - public static function sessionAccountId() - { - return Auth::user()->member->first()->user_id; - } - - public static function listClueScrollTiers() - { - return ["all", "beginner", "easy", "medium", "hard", "elite", "master"]; - } - - public static function listBosses() - { - return Collection::pluck('name')->toArray(); - // return ["abyssal sire", "alchemical hydra", "barrows chests", "bryophyta", "callisto", "cerberus", "chambers of xeric", "chambers of xeric challenge mode", "chaos elemental", "chaos fanatic", "commander zilyana", "corporeal beast", "crazy archaeologist", "dagannoth kings", "dagannoth prime", "dagannoth rex", "dagannoth supreme", "deranged archaeologist", "general graardor", "giant mole","grotesque guardians", "hespori", "kalphite queen", "king black dragon", "kraken", "kreearra", "kril tsutsaroth", "mimic", "the nightmare", "obor", "sarachnis", "scorpia", "skotizo", "the gauntlet", "the corrupted gauntlet", "theatre of blood", "thermonuclear smoke devil", "tzkal zuk", "tztok jad", "venenatis", "vetion", "vorkath", "wintertodt", "zalcano", "zulrah"]; - } - - public static function collectionAttribute($collection, $attribute) - { - return Collection::where('name', $collection)->value($attribute); - } - - public static function registerAccount($accountName) - { - $playerDataUrl = 'https://secure.runescape.com/m=hiscore_oldschool/index_lite.ws?player=' . $accountName; - - if (self::verifyUrl($playerDataUrl)) { - // Get the $playerDataUrl file content. - $getPlayerData = file_get_contents($playerDataUrl); - - // Fetch the content from $playerDataUrl. - $playerStats = explode("\n", $getPlayerData); - - // Convert the CSV file of player stats into an array. - $playerData = []; - foreach ($playerStats as $playerStat) { - $playerData[] = str_getcsv($playerStat); - } - - $account = Account::create([ - 'username' => request('username'), - 'rank' => $playerData[0][0], - 'level' => $playerData[0][1], - 'xp' => $playerData[0][2] - ]); - - $skills = self::listSkills(); - - foreach ($skills as $key => $skill) { - DB::table($skills[$key])->insert([ - 'account_id' => $account->id, - 'rank' => $playerData[$key + 1][0], - 'level' => $playerData[$key + 1][1], - 'xp' => $playerData[$key + 1][2], - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now() - ]); - } - - return $account; - } else { - return false; - } - } - public static function listSkills() { return [ @@ -208,17 +140,15 @@ public static function listSkills() ]; } - public static function accountStats($accountId) + public static function listClueScrollTiers() { - $accountSkills = []; - - $skills = self::listSkills(); - - foreach ($skills as $skillName) { - array_push($accountSkills, DB::table($skillName)->where('account_id', $accountId)->get()); - } + return ["all", "beginner", "easy", "medium", "hard", "elite", "master"]; + } - return $accountSkills; + public static function listBosses() + { + return Collection::where('type', 'boss')->orWhere('type', 'raid')->pluck('name')->toArray(); +// return dd(["abyssal sire", "alchemical hydra", "barrows chests", "bryophyta", "callisto", "cerberus", "chambers of xeric", "chambers of xeric challenge mode", "chaos elemental", "chaos fanatic", "commander zilyana", "corporeal beast", "crazy archaeologist", "dagannoth kings", "dagannoth prime", "dagannoth rex", "dagannoth supreme", "deranged archaeologist", "general graardor", "giant mole","grotesque guardians", "hespori", "kalphite queen", "king black dragon", "kraken", "kreearra", "kril tsutsaroth", "mimic", "the nightmare", "obor", "sarachnis", "scorpia", "skotizo", "the gauntlet", "the corrupted gauntlet", "theatre of blood", "thermonuclear smoke devil", "tzkal zuk", "tztok jad", "venenatis", "vetion", "vorkath", "wintertodt", "zalcano", "zulrah"]); } public static function listAccountTypes() From 6bbe771bafd84636d4dbba3ea3085fc878e702e4 Mon Sep 17 00:00:00 2001 From: Zlimon Date: Tue, 29 Dec 2020 21:30:42 +0100 Subject: [PATCH 34/39] Proper check if OSRS account exist --- app/Helpers/Helper.php | 32 +++++++++++++------ .../Controllers/AccountAuthController.php | 4 +-- .../Controllers/Api/AccountController.php | 13 ++------ database/seeds/CollectionSeeder.php | 2 +- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index a45003bb..8bc20261 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -56,15 +56,11 @@ public static function verifyItem($itemId) { $itemData = 'https://www.osrsbox.com/osrsbox-db/items-json/' . $itemId . '.json'; - if (self::verifyUrl($itemData)) { - $itemData = file_get_contents($itemData); - $itemData = json_decode($itemData, true); + $itemData = file_get_contents($itemData); + $itemData = json_decode($itemData, true); - if (!$itemData['noted']) { - return true; - } else { - return false; - } + if (!$itemData['noted']) { + return true; } else { return false; } @@ -75,7 +71,7 @@ public static function verifyItem($itemId) * * @return */ - public static function verifyUrl($url) + public static function getPlayerData($url) { $handle = curl_init($url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); @@ -89,7 +85,23 @@ public static function verifyUrl($url) /* If the document has loaded successfully without any redirection or error */ if ($httpCode >= 200 && $httpCode < 300) { - return $response; + $playerStats = explode("\n", $response); + + if (count($playerStats) > 1) { + /* Convert the CSV file of player stats into an array */ + $playerData = []; + foreach ($playerStats as $playerStat) { + $playerData[] = str_getcsv($playerStat); + } + + if ($playerData[0][0]) { + return $playerData; + } else { + return false; + } + } else { + return false; + } } else { return false; } diff --git a/app/Http/Controllers/AccountAuthController.php b/app/Http/Controllers/AccountAuthController.php index 0cd3dde7..875b5c27 100644 --- a/app/Http/Controllers/AccountAuthController.php +++ b/app/Http/Controllers/AccountAuthController.php @@ -51,7 +51,7 @@ public function create() } else { $playerDataUrl = Helper::formatHiscoreUrl(request('account_type'), request('username')); - if (Helper::verifyUrl($playerDataUrl)) { + if (Helper::getPlayerData($playerDataUrl)) { $authStatus = new AccountAuthStatus; $authStatus->user_id = Auth::user()->id; @@ -83,7 +83,7 @@ public function updateAccountType() if ($authStatus->account_type != request('account_type')) { $playerDataUrl = Helper::formatHiscoreUrl(request('account_type'), $authStatus->username); - if (Helper::verifyUrl($playerDataUrl)) { + if (Helper::getPlayerData($playerDataUrl)) { $authStatus->account_type = request('account_type'); $authStatus->save(); diff --git a/app/Http/Controllers/Api/AccountController.php b/app/Http/Controllers/Api/AccountController.php index 28a5843d..3e0445c6 100644 --- a/app/Http/Controllers/Api/AccountController.php +++ b/app/Http/Controllers/Api/AccountController.php @@ -69,18 +69,9 @@ public function store(Request $request) '%20', request('username')); /* Get the $playerDataUrl file content. */ - $getPlayerData = file_get_contents($playerDataUrl); + $playerData = Helper::getPlayerData($playerDataUrl); - /* Fetch the content from $playerDataUrl. */ - $playerStats = explode("\n", $getPlayerData); - - /* Convert the CSV file of player stats into an array */ - $playerData = []; - foreach ($playerStats as $playerStat) { - $playerData[] = str_getcsv($playerStat); - } - - if ($playerData[0][0]) { + if ($playerData) { $account = Account::create([ 'user_id' => $authStatus->user_id, 'account_type' => request('account_type'), diff --git a/database/seeds/CollectionSeeder.php b/database/seeds/CollectionSeeder.php index 8d5ba74c..39c68e2d 100644 --- a/database/seeds/CollectionSeeder.php +++ b/database/seeds/CollectionSeeder.php @@ -60,7 +60,7 @@ public function run() // ["name" => "the fight caves", "alias" => "The Fight caves", "type" => "boss", "model" => "App\Boss\TheFightCaves"], // ["name" => "the inferno", "alias" => "something", "type" => "boss", "model" => "App\Boss\TheInferno"], ["name" => "the nightmare", "alias" => "The Nightmare", "type" => "boss", "model" => "App\Boss\TheNightmare"], - ["name" => "goblin", "alias" => "Goblin", "type" => "boss", "model" => "App\Boss\Goblin"], // TODO remove later + ["name" => "goblin", "alias" => "Goblin", "type" => "npc", "model" => "App\Npc\Goblin"], // TODO remove later ]); } } From 97b7ec6dc50faddeecd02deb62bb8896b8dea7bc Mon Sep 17 00:00:00 2001 From: Zlimon Date: Tue, 29 Dec 2020 21:33:18 +0100 Subject: [PATCH 35/39] Check if item exist --- app/Helpers/Helper.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 8bc20261..baf437ac 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -56,7 +56,12 @@ public static function verifyItem($itemId) { $itemData = 'https://www.osrsbox.com/osrsbox-db/items-json/' . $itemId . '.json'; - $itemData = file_get_contents($itemData); + $itemData = @file_get_contents($itemData); + + if ($itemData === false) { + return false; + } + $itemData = json_decode($itemData, true); if (!$itemData['noted']) { From 2d980bcb6f8c914685a9cc0c2e1d3e6ff9f67abc Mon Sep 17 00:00:00 2001 From: Zlimon Date: Tue, 29 Dec 2020 21:38:46 +0100 Subject: [PATCH 36/39] Ironman symbol on accounts in account index --- public/css/button.css | 2 +- resources/views/account/index.blade.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/public/css/button.css b/public/css/button.css index cd3bfa04..490fca25 100644 --- a/public/css/button.css +++ b/public/css/button.css @@ -81,7 +81,7 @@ } .button-rectangle { - width: 12rem; + width: 15rem; height: 5rem; } diff --git a/resources/views/account/index.blade.php b/resources/views/account/index.blade.php index ce2f2cea..13ad9573 100644 --- a/resources/views/account/index.blade.php +++ b/resources/views/account/index.blade.php @@ -6,7 +6,7 @@ @section('content')
- @if (count($accounts) > 0) + @if ($accounts->isNotEmpty())

Search for accounts

@@ -50,7 +50,14 @@ class="pixel icon"
- {{ $account->username }} + + @if ($account->account_type !== "normal") + {{ Helper::formatAccountTypeName($account->account_type) }} icon + @endif + {{ $account->username }} +
Date: Tue, 29 Dec 2020 21:39:01 +0100 Subject: [PATCH 37/39] Better alert box style --- resources/views/layouts/layout.blade.php | 26 ++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/resources/views/layouts/layout.blade.php b/resources/views/layouts/layout.blade.php index 24ea84d4..3786ad5a 100644 --- a/resources/views/layouts/layout.blade.php +++ b/resources/views/layouts/layout.blade.php @@ -167,8 +167,17 @@ class="pixel mr-1"
@foreach ($errors->all() as $errorMessage) -

Error!

-

{{ $errorMessage }}

+
+
+ Sad face +
+
+

Error!

+

{{ $errorMessage }}

+
+
@endforeach
@endif @@ -176,8 +185,17 @@ class="pixel mr-1" @if (Session::has('message'))
-

Success!

-

{{ Session::get('message') }}

+
+
+ Happy face +
+
+

Success!

+

{{ Session::get('message') }}

+
+
@endif From f58ed8d646d16dd67b9cc31d608b772b9e564716 Mon Sep 17 00:00:00 2001 From: Zlimon Date: Tue, 29 Dec 2020 21:47:19 +0100 Subject: [PATCH 38/39] Pixelate icons in button --- resources/js/components/AccountBossHiscore.vue | 2 +- resources/js/components/AccountHiscore.vue | 4 ++-- resources/views/hiscore.blade.php | 4 ++-- resources/views/index.blade.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/js/components/AccountBossHiscore.vue b/resources/js/components/AccountBossHiscore.vue index c1477edb..4c337436 100644 --- a/resources/js/components/AccountBossHiscore.vue +++ b/resources/js/components/AccountBossHiscore.vue @@ -64,7 +64,7 @@

{{ data.username }}