Skip to content

Commit f9603b4

Browse files
committed
✨ installation et configuration du package Gamify pour les reputations et les badges
1 parent 6cada20 commit f9603b4

File tree

9 files changed

+78737
-17
lines changed

9 files changed

+78737
-17
lines changed

app/Models/User.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
use Illuminate\Foundation\Auth\User as Authenticatable;
1313
use Illuminate\Notifications\Notifiable;
1414
use Illuminate\Support\Facades\Auth;
15+
use QCod\Gamify\Gamify;
1516
use Spatie\MediaLibrary\HasMedia;
1617
use Spatie\MediaLibrary\InteractsWithMedia;
1718
use Spatie\Permission\Traits\HasRoles;
1819

1920
class User extends Authenticatable implements MustVerifyEmail, HasMedia
2021
{
21-
use HasFactory,
22+
use Gamify,
23+
HasFactory,
2224
HasProfilePhoto,
2325
HasRoles,
2426
InteractsWithMedia,

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"laravel/socialite": "^5.2",
2727
"laravel/tinker": "^2.5",
2828
"livewire/livewire": "^2.8",
29-
"wireui/wireui": "^0.14.0",
29+
"qcod/laravel-gamify": "^1.0",
3030
"ramsey/uuid": "^4.2",
3131
"sentry/sentry-laravel": "^2.10",
3232
"spatie/laravel-feed": "^4.0",
@@ -37,6 +37,7 @@
3737
"torchlight/torchlight-commonmark": "^0.5.2",
3838
"wire-elements/modal": "^1.0",
3939
"wire-elements/spotlight": "^1.0",
40+
"wireui/wireui": "^0.14.0",
4041
"yarri/link-finder": "^2.7"
4142
},
4243
"require-dev": {

composer.lock

Lines changed: 69 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/gamify.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
return [
4+
// Model which will be having points, generally it will be User
5+
'payee_model' => \App\Models\User::class,
6+
7+
// Reputation model
8+
'reputation_model' => '\QCod\Gamify\Reputation',
9+
10+
// Allow duplicate reputation points
11+
'allow_reputation_duplicate' => true,
12+
13+
// Broadcast on private channel
14+
'broadcast_on_private_channel' => true,
15+
16+
// Channel name prefix, user id will be suffixed
17+
'channel_name' => 'user.reputation.',
18+
19+
// Badge model
20+
'badge_model' => '\QCod\Gamify\Badge',
21+
22+
// Where all badges icon stored
23+
'badge_icon_folder' => 'images/badges/',
24+
25+
// Extention of badge icons
26+
'badge_icon_extension' => '.svg',
27+
28+
// All the levels for badge
29+
'badge_levels' => [
30+
'beginner' => 1,
31+
'intermediate' => 2,
32+
'advanced' => 3,
33+
],
34+
35+
// Default level
36+
'badge_default_level' => 1
37+
];
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class AddReputationFieldOnUserTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('users', function (Blueprint $table) {
17+
$table->unsignedInteger('reputation')->default(0)->after('remember_token');
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('users', function (Blueprint $table) {
29+
$table->dropColumn('reputation');
30+
});
31+
}
32+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateGamifyTables extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
// reputations table
17+
Schema::create('reputations', function (Blueprint $table) {
18+
$table->id();
19+
$table->string('name');
20+
$table->mediumInteger('point', false)->default(0);
21+
$table->bigInteger('subject_id')->nullable();
22+
$table->string('subject_type')->nullable();
23+
$table->unsignedBigInteger('payee_id')->nullable();
24+
$table->text('meta')->nullable();
25+
$table->timestamps();
26+
});
27+
28+
// badges table
29+
Schema::create('badges', function (Blueprint $table) {
30+
$table->id();
31+
$table->string('name');
32+
$table->string('description')->nullable();
33+
$table->string('icon')->nullable();
34+
$table->tinyInteger('level')->default(config('gamify.badge_default_level', 1));
35+
$table->timestamps();
36+
});
37+
38+
// user_badges pivot
39+
Schema::create('user_badges', function (Blueprint $table) {
40+
$table->primary(['user_id', 'badge_id']);
41+
$table->unsignedBigInteger('user_id');
42+
$table->unsignedBigInteger('badge_id');
43+
$table->timestamps();
44+
});
45+
}
46+
47+
/**
48+
* Reverse the migrations.
49+
*
50+
* @return void
51+
*/
52+
public function down()
53+
{
54+
Schema::dropIfExists('user_badges');
55+
Schema::dropIfExists('badges');
56+
Schema::dropIfExists('reputations');
57+
}
58+
}

public/css/app.css

Lines changed: 9390 additions & 10 deletions
Large diffs are not rendered by default.

public/js/app.js

Lines changed: 69144 additions & 2 deletions
Large diffs are not rendered by default.

public/mix-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"/js/app.js": "/js/app.js?id=24a959e67d1d9798dd27",
3-
"/css/app.css": "/css/app.css?id=84c90922f73faacd4564"
2+
"/js/app.js": "/js/app.js",
3+
"/css/app.css": "/css/app.css"
44
}

0 commit comments

Comments
 (0)