Skip to content

Commit 7f2672e

Browse files
committed
feat: init module
chore(deps): bump vormkracht10/filament-mails from 1.0.5 to 2.0.1 (#301) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> feat: LAR-0189 init modular configuration' feat: wip feat: LAR-0192 update stub
1 parent 61cc439 commit 7f2672e

File tree

86 files changed

+7242
-2589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+7242
-2589
lines changed

.github/actions/setup/action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runs:
77
- name: 🐘 Setup PHP
88
uses: shivammathur/setup-php@v2
99
with:
10-
php-version: "8.2"
10+
php-version: "8.3"
1111
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick
1212
tools: composer:v2
1313
coverage: none
@@ -21,7 +21,7 @@ runs:
2121
shell: sh
2222
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
2323
- name: Cache dependencies
24-
uses: actions/cache@v3
24+
uses: actions/cache@v4
2525
with:
2626
path: ${{ steps.composer-cache.outputs.dir }}
2727
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}

.github/workflows/update-changelog.yml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
jobs:
88
update:
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
1012

1113
steps:
1214
- name: Checkout code

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ composer.phar
2121
/public/hot
2222
/public/storage
2323
/public/media
24+
public/css/
25+
public/js/
2426
/public/**/*.xml
2527
/storage/*.key
2628
/storage/framework/cache

app-modules/gamify/composer.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "laravelcm/gamify",
3+
"description": "Module laravelcm/gamify for Laravel.cm",
4+
"type": "library",
5+
"version": "1.1.0",
6+
"license": "proprietary",
7+
"require": {
8+
"filament/filament": "^3.2"
9+
},
10+
"require-dev": {
11+
"pestphp/pest": "^2.32",
12+
"pestphp/pest-plugin-laravel": "^2.1"
13+
},
14+
"autoload": {
15+
"psr-4": {
16+
"Laravelcm\\Gamify\\": "src/",
17+
"Laravelcm\\Gamify\\Database\\Factories\\": "database/factories/",
18+
"Laravelcm\\Gamify\\Database\\Seeders\\": "database/seeders/"
19+
},
20+
"files": [
21+
"src/helpers.php"
22+
]
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"Laravelcm\\Gamify\\Tests\\": "tests/"
27+
}
28+
},
29+
"minimum-stability": "stable",
30+
"extra": {
31+
"laravel": {
32+
"providers": [
33+
"Laravelcm\\Gamify\\Providers\\GamifyServiceProvider"
34+
]
35+
}
36+
}
37+
}

app-modules/gamify/config/gamify.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use App\Models\User;
6+
use Laravelcm\Gamify\Models\Reputation;
7+
8+
return [
9+
10+
'payee_model' => User::class,
11+
12+
'reputation_model' => Reputation::class,
13+
14+
'allow_reputation_duplicate' => true,
15+
16+
'broadcast_on_private_channel' => true,
17+
18+
'channel_name' => 'user.reputation.',
19+
20+
];

app-modules/gamify/database/factories/.gitkeep

Whitespace-only changes.

database/migrations/2022_01_15_201921_create_gamify_tables.php renamed to app-modules/gamify/database/migrations/2022_01_15_201921_create_gamify_tables.php

-19
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,10 @@ public function up(): void
2020
$table->text('meta')->nullable();
2121
$table->timestamps();
2222
});
23-
24-
Schema::create('badges', function (Blueprint $table): void {
25-
$table->id();
26-
$table->string('name');
27-
$table->string('description')->nullable();
28-
$table->string('icon')->nullable();
29-
$table->tinyInteger('level')->default(config('gamify.badge_default_level', 1));
30-
$table->timestamps();
31-
});
32-
33-
// user_badges pivot
34-
Schema::create('user_badges', function (Blueprint $table): void {
35-
$table->primary(['user_id', 'badge_id']);
36-
$table->unsignedBigInteger('user_id');
37-
$table->unsignedBigInteger('badge_id');
38-
$table->timestamps();
39-
});
4023
}
4124

4225
public function down(): void
4326
{
44-
Schema::dropIfExists('user_badges');
45-
Schema::dropIfExists('badges');
4627
Schema::dropIfExists('reputations');
4728
}
4829
}

app-modules/gamify/database/seeders/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Laravelcm\Gamify\Console;
6+
7+
use Illuminate\Console\GeneratorCommand;
8+
9+
final class MakePointCommand extends GeneratorCommand
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'gamify:point {name}';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = 'Create a Gamify point type class.';
24+
25+
/**
26+
* The type of class being generated.
27+
*
28+
* @var string
29+
*/
30+
protected $type = 'Point';
31+
32+
/**
33+
* Get the stub file for the generator.
34+
*/
35+
protected function getStub(): string
36+
{
37+
return __DIR__.'/stubs/point.stub';
38+
}
39+
40+
/**
41+
* Get the default namespace for the class.
42+
*
43+
* @param string $rootNamespace The root namespace
44+
*/
45+
protected function getDefaultNamespace($rootNamespace): string
46+
{
47+
return $rootNamespace.'\Gamify\Points';
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DummyNamespace;
6+
7+
use App\Models\User;
8+
use Laravelcm\Gamify\PointType;
9+
10+
final class DummyClass extends PointType
11+
{
12+
/**
13+
* Number of points
14+
*
15+
* @var int
16+
*/
17+
public int $points = 20;
18+
19+
/**
20+
* Point constructor
21+
*
22+
* @param mixed $subject
23+
*/
24+
public function __construct(mixed $subject)
25+
{
26+
$this->subject = $subject;
27+
}
28+
29+
/**
30+
* User who will be receive points
31+
*
32+
* @return mixed
33+
*/
34+
public function payee(): ?User
35+
{
36+
return $this->getSubject()->user;
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Laravelcm\Gamify\Exceptions;
6+
7+
final class InvalidPayeeModelException extends \Exception
8+
{
9+
protected $message = 'payee() method must return a model which will get the points.';
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Laravelcm\Gamify\Exceptions;
6+
7+
use Exception;
8+
9+
final class PointSubjectNotSetException extends Exception
10+
{
11+
protected string $message = 'Initialize $subject field in constructor.';
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Laravelcm\Gamify\Exceptions;
6+
7+
use Exception;
8+
9+
final class PointsNotDefinedException extends Exception
10+
{
11+
protected string $message = 'You must define a $points field or a getPoints() method.';
12+
}

app-modules/gamify/src/Models/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Laravelcm\Gamify\Models;
6+
7+
use App\Models\User;
8+
use Carbon\Carbon;
9+
use Illuminate\Database\Eloquent\Model;
10+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
11+
use Illuminate\Database\Eloquent\Relations\MorphTo;
12+
13+
/**
14+
* @property-read int $id
15+
* @property-read int $point
16+
* @property-read User payee
17+
* @property-read Carbon $created_at
18+
* @property-read Carbon $updated_at
19+
*/
20+
final class Reputation extends Model
21+
{
22+
protected $guarded = [];
23+
24+
/**
25+
* @return BelongsTo<User, $this>
26+
*/
27+
public function payee(): BelongsTo
28+
{
29+
return $this->belongsTo(config('gamify.payee_model'), 'payee_id');
30+
}
31+
32+
/**
33+
* Get the owning subject model
34+
*/
35+
public function subject(): MorphTo
36+
{
37+
return $this->morphTo();
38+
}
39+
40+
/**
41+
* Undo last point
42+
*
43+
* @throws \Exception
44+
*/
45+
public function undo(): void
46+
{
47+
if ($this->exists) {
48+
$this->payee->reducePoint($this->point);
49+
$this->delete();
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)