Skip to content

A lightweight profile visitor tracking system for CodeIgniter Shield, designed to monitor user profile visits similar to LinkedIn’s profile viewers feature.

License

Notifications You must be signed in to change notification settings

warcooft/shield-visitors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Profile Visitor Tracking System for CodeIgniter Shield

A lightweight profile visitor tracking system for CodeIgniter Shield, designed to monitor user profile visits similar to LinkedIn’s profile viewers feature.

Install

Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:

composer require aselsan/visitors

Once the files are downloaded and included in the autoload, run any library migrations to ensure the database is set up correctly:

php spark migrate --all

Configuration

Add HasVisitors trait to your users model and initialize visitors with initVisitors() method.

class ExampleUsersModel extends BaseModel
{
    use HasVisitors;

    // ...

    protected function initialize()
    {
        $this->initVisitors();
    }

    // ...
}

And if you use Entity class, add Visitable trait to it:

class ExampleUser extends Entity
{
    use Visitable;

    // ...
}

Usage

Visit a User

To record a visit to a specific user's profile:

$users = auth()->getProvider();
$user  = $users->find($id);

// Record a visit to this user
$user->visit();

Get a User with Visitor Information

To retrieve a user along with their visitors:

$users = auth()->getProvider();
$user  = $users->withVisitors()->find($id);

// Get total number of visitors
$user->getSumVisitors();

// Get detailed visitor information
$user->visitors;
// or
$user->getVisitors();

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A lightweight profile visitor tracking system for CodeIgniter Shield, designed to monitor user profile visits similar to LinkedIn’s profile viewers feature.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages