Skip to content

Commit 5ab24b3

Browse files
authored
Merge pull request #35 from laravelcm/badges-reputations
Badges reputations
2 parents 6cada20 + d8c0de6 commit 5ab24b3

31 files changed

+657
-18
lines changed

app/Console/Commands/Cleanup/DeleteOldUnverifiedUsers.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,8 @@
88

99
class DeleteOldUnverifiedUsers extends Command
1010
{
11-
/**
12-
* The name and signature of the console command.
13-
*
14-
* @var string
15-
*/
1611
protected $signature = 'lcm:delete-old-unverified-users';
1712

18-
/**
19-
* The console command description.
20-
*
21-
* @var string
22-
*/
2313
protected $description = 'Removed all unverified users.';
2414

2515
public function handle()
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class UpdateUserCommentsPoints extends Command
8+
{
9+
/**
10+
* The name and signature of the console command.
11+
*
12+
* @var string
13+
*/
14+
protected $signature = 'command:name';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = 'Command description';
22+
23+
/**
24+
* Create a new command instance.
25+
*
26+
* @return void
27+
*/
28+
public function __construct()
29+
{
30+
parent::__construct();
31+
}
32+
33+
/**
34+
* Execute the console command.
35+
*
36+
* @return int
37+
*/
38+
public function handle()
39+
{
40+
return 0;
41+
}
42+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Gamify\Points\DiscussionCreated;
6+
use App\Models\Discussion;
7+
use Illuminate\Console\Command;
8+
9+
class UpdateUserDiscussionsPoints extends Command
10+
{
11+
protected $signature = 'lcm:update-users-discussions-points';
12+
13+
protected $description = 'Update users discussions reputation points';
14+
15+
public function handle()
16+
{
17+
$this->info('Updating users discussions reputations...');
18+
19+
foreach (Discussion::all() as $discussion) {
20+
givePoint(new DiscussionCreated($discussion), $discussion->author);
21+
}
22+
23+
$this->info('All done!');
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Gamify\Points\PostCreated;
6+
use App\Models\Article;
7+
use Illuminate\Console\Command;
8+
9+
class UpdateUserPostsPoints extends Command
10+
{
11+
protected $signature = 'lcm:update-users-posts-points';
12+
13+
protected $description = 'Update users posts reputation points';
14+
15+
public function handle()
16+
{
17+
$this->info('Updating users posts reputations...');
18+
19+
foreach (Article::all() as $article) {
20+
givePoint(new PostCreated($article), $article->author);
21+
}
22+
23+
$this->info('All done!');
24+
}
25+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class UpdateUserRepliesPoints extends Command
8+
{
9+
/**
10+
* The name and signature of the console command.
11+
*
12+
* @var string
13+
*/
14+
protected $signature = 'command:name';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = 'Command description';
22+
23+
/**
24+
* Create a new command instance.
25+
*
26+
* @return void
27+
*/
28+
public function __construct()
29+
{
30+
parent::__construct();
31+
}
32+
33+
/**
34+
* Execute the console command.
35+
*
36+
* @return int
37+
*/
38+
public function handle()
39+
{
40+
return 0;
41+
}
42+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Gamify\Points\ThreadCreated;
6+
use App\Models\Thread;
7+
use Illuminate\Console\Command;
8+
9+
class UpdateUserThreadsPoints extends Command
10+
{
11+
protected $signature = 'lcm:update-users-threads-points';
12+
13+
protected $description = 'Update users threads reputation points';
14+
15+
public function handle()
16+
{
17+
$this->info('Updating users threads reputations...');
18+
19+
foreach (Thread::all() as $thread) {
20+
givePoint(new ThreadCreated($thread), $thread->author);
21+
}
22+
23+
$this->info('All done!');
24+
}
25+
}

app/Gamify/Points/AddPhone.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace App\Gamify\Points;
4+
5+
use QCod\Gamify\PointType;
6+
7+
class AddPhone extends PointType
8+
{
9+
/**
10+
* Number of points.
11+
*
12+
* @var int
13+
*/
14+
public $points = 20;
15+
16+
/**
17+
* Point constructor.
18+
*
19+
* @param $subject
20+
*/
21+
public function __construct($subject)
22+
{
23+
$this->subject = $subject;
24+
}
25+
26+
/**
27+
* User who will be receive points.
28+
*
29+
* @return mixed
30+
*/
31+
public function payee()
32+
{
33+
return $this->getSubject()->user;
34+
}
35+
}

app/Gamify/Points/AddSocialLinks.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace App\Gamify\Points;
4+
5+
use QCod\Gamify\PointType;
6+
7+
class AddSocialLinks extends PointType
8+
{
9+
/**
10+
* Number of points.
11+
*
12+
* @var int
13+
*/
14+
public $points = 20;
15+
16+
/**
17+
* Point constructor.
18+
*
19+
* @param $subject
20+
*/
21+
public function __construct($subject)
22+
{
23+
$this->subject = $subject;
24+
}
25+
26+
/**
27+
* User who will be receive points.
28+
*
29+
* @return mixed
30+
*/
31+
public function payee()
32+
{
33+
return $this->getSubject()->user;
34+
}
35+
}

app/Gamify/Points/BestReply.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace App\Gamify\Points;
4+
5+
use QCod\Gamify\PointType;
6+
7+
class BestReply extends PointType
8+
{
9+
/**
10+
* Number of points.
11+
*
12+
* @var int
13+
*/
14+
public $points = 20;
15+
16+
/**
17+
* Point constructor.
18+
*
19+
* @param $subject
20+
*/
21+
public function __construct($subject)
22+
{
23+
$this->subject = $subject;
24+
}
25+
26+
/**
27+
* User who will be receive points.
28+
*
29+
* @return mixed
30+
*/
31+
public function payee()
32+
{
33+
return $this->getSubject()->user;
34+
}
35+
}

app/Gamify/Points/CommentCreated.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace App\Gamify\Points;
4+
5+
use QCod\Gamify\PointType;
6+
7+
class CommentCreated extends PointType
8+
{
9+
/**
10+
* Number of points.
11+
*
12+
* @var int
13+
*/
14+
public $points = 20;
15+
16+
/**
17+
* Point constructor.
18+
*
19+
* @param $subject
20+
*/
21+
public function __construct($subject)
22+
{
23+
$this->subject = $subject;
24+
}
25+
26+
/**
27+
* User who will be receive points.
28+
*
29+
* @return mixed
30+
*/
31+
public function payee()
32+
{
33+
return $this->getSubject()->user;
34+
}
35+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Gamify\Points;
4+
5+
use QCod\Gamify\PointType;
6+
7+
class DiscussionCreated extends PointType
8+
{
9+
public int $points = 10;
10+
11+
public function __construct($subject)
12+
{
13+
$this->subject = $subject;
14+
}
15+
16+
public function payee()
17+
{
18+
return $this->getSubject()->author;
19+
}
20+
}

app/Gamify/Points/PostCreated.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Gamify\Points;
4+
5+
use QCod\Gamify\PointType;
6+
7+
class PostCreated extends PointType
8+
{
9+
public int $points = 10;
10+
11+
public function __construct($subject)
12+
{
13+
$this->subject = $subject;
14+
}
15+
16+
public function payee()
17+
{
18+
return $this->getSubject()->author;
19+
}
20+
}

0 commit comments

Comments
 (0)