Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/Achievement.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ abstract class Achievement implements CanAchieve
*/
public $description = "";

/*
* Image url for the achievement
*/
public $url = "";

/**
* The amount of points required to unlock this achievement.
*/
Expand Down Expand Up @@ -56,7 +61,8 @@ public function __construct()
* Wrapper for AchievementDetail::all();
* Conveniently fetches all achievements stored in the database.
*/
public static function all(){
public static function all()
{
return AchievementDetails::all();
}

Expand Down Expand Up @@ -87,7 +93,7 @@ public function getPoints()
*/
public function getModel()
{
if(!is_null($this->modelAttr)){
if (!is_null($this->modelAttr)) {
return $this->modelAttr;
}

Expand All @@ -98,9 +104,10 @@ public function getModel()
$model->class_name = $this->getClassName();
}

if(config('achievements.auto_sync') || is_null($model->name)) {
if (config('achievements.auto_sync') || is_null($model->name)) {
$model->name = $this->name;
$model->description = $this->description;
$model->url = $this->url;
$model->points = $this->points;
$model->secret = $this->secret;

Expand Down Expand Up @@ -155,9 +162,9 @@ public function getOrCreateProgressForAchiever($achiever)

$achievementId = $this->getModel()->id;
$progress = AchievementProgress::where('achiever_type', $className)
->where('achievement_id', $achievementId)
->where('achiever_id', $achiever->id)
->first();
->where('achievement_id', $achievementId)
->where('achiever_id', $achiever->id)
->first();

if (is_null($progress)) {
$progress = new AchievementProgress();
Expand Down Expand Up @@ -191,17 +198,15 @@ protected function getAchieverClassName($achiever)
* @param $progress
*/
public function whenUnlocked($progress)
{
}
{ }

/**
* Will be called when progress is made on the achievement.
*
* @param $progress
*/
public function whenProgress($progress)
{
}
{ }

/**
* Triggers the AchievementUnlocked Event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function up()
$table->increments('id');
$table->string('name');
$table->string('description');
$table->string('url');
$table->unsignedInteger('points')->default(1);
$table->boolean('secret')->default(false);
$table->string('class_name');
Expand Down