Added Notifications
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
@@ -26,6 +27,21 @@ class UserAchievement extends Model
|
||||
'progress' => 'integer',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'unlocked',
|
||||
];
|
||||
|
||||
protected function unlocked(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function () {
|
||||
if (!$this->achievement) return false;
|
||||
if (!$this->achievement->progressive || !$this->achievement->threshold) return true;
|
||||
return ($this->progress ?? 0) >= $this->achievement->threshold;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Relationships
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user