src/EntityRelationsAchievements.php
public function lockedAchievements()
    {
        if (config('achievements.locked_sync')) {
            // Relationships should be synced. Just return relationship data.
            return $this->achievements()->whereNull('unlocked_at')->get();
        } else {
            // Query all unsynced
            $unsynced = AchievementDetails::getUnsyncedByAchiever($this)->get();
            $self = $this;
            $unsynced = $unsynced->map(function ($el) use ($self) {
                $progress = new AchievementProgress();
                $progress->details()->associate($el);
                $progress->achiever()->associate($this);
                $progress->points = 0;
                $progress->created_at = null;
                $progress->updated_at = null;
                return $progress;
            });

            // Merge with progressed, but not yet unlocked
            $lockedProgressed = $this->achievements()->whereNull('unlocked_at')->get();
            $locked = $lockedProgressed->merge($unsynced);

            return $locked;
        }
    }
public function lockedAchievements()
    {
        if (config('achievements.locked_sync')) {
            // Relationships should be synced. Just return relationship data.
            return $this->achievements()->whereNull('unlocked_at')->get();
        } else {
            // Query all unsynced
            $unsynced = AchievementDetails::getUnsyncedByAchiever($this)->get();
            $self = $this;
            $unsynced = $unsynced->map(function ($el) use ($self) {
                $progress = new AchievementProgress();
                $progress->details()->associate($el);
                $progress->achiever()->associate($this);
                $progress->points = 0;
                $progress->created_at = null;
                $progress->updated_at = null;
                return $progress;
            });

            // Merge with progressed, but not yet unlocked
            $lockedProgressed = $this->achievements()->whereNull('unlocked_at')->get();
            $locked = $lockedProgressed->merge($unsynced);

            return $locked;
        }
    }
public function lockedAchievements ( ) { if ( config ( 'achievements.locked_sync' ) ) { // Relationships should be synced. Just return relationship data. return $ this -> achievements ( ) -> whereNull ( 'unlocked_at' ) -> get ( ) ; } else { // Query all unsynced $ unsynced = AchievementDetails :: getUnsyncedByAchiever ( $ this ) -> get ( ) ; $ self = $ this ; $ unsynced = $ unsynced -> map ( function ( $ el ) use ( $ self ) { $ progress = new AchievementProgress ( ) ; $ progress -> details ( ) -> associate ( $ el ) ; $ progress -> achiever ( ) -> associate ( $ this ) ; $ progress -> points = 0 ; $ progress -> created_at = null ; $ progress -> updated_at = null ; return $ progress ; } ) ; // Merge with progressed, but not yet unlocked $ lockedProgressed = $ this -> achievements ( ) -> whereNull ( 'unlocked_at' ) -> get ( ) ; $ locked = $ lockedProgressed -> merge ( $ unsynced ) ; return $ locked ; } }
Get the entity's locked achievements.
Get the entity s locked achievements .