PHP code example of atomjoy / apilogin

1. Go to this page and download the library: Download atomjoy/apilogin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

atomjoy / apilogin example snippets




namespace App\Models;

use Atomjoy\Apilogin\Contracts\HasProfilAddress;
use Atomjoy\Apilogin\Contracts\HasRolesPermissions;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;
    use HasProfilAddress, HasRolesPermissions;
    use HasRoles;

    /**
    * Model table.
    */
    protected $table = 'users';

    /**
    * Auth guard.
    */
    protected $guard = 'web';

    /**
    * Append user relations (optional).
    */
    protected $with = ['profile', 'roles'];

    // ...
}



use Atomjoy\Apilogin\Http\Controllers\ActivateController;

# Email activation link route
Route::get('/activate/{id}/{code}', [ActivateController::class, 'index'])->name('activation');

// config/apilogin.php
return [
  // Admin users emails (email with dns mx)
  'super_admin_email' => '[email protected]',
  'admin_email' => '[email protected]',
  'worker_email' => '[email protected]',

  // Admin users passsword
  'super_admin_password' => 'Password123#',
  'admin_password' => 'Password123#',
  'worker_password' => 'Password123#',
]

// config/apilogin.php
return [
  // Disable Storage::disk s3 to public overwrite
  'overwrite_disk_s3' => false,
]


// Add login route
Route::get('/login', function () {
  return view('vue');
})->name('login');

// Disable in testing
if (!app()->runningUnitTests()) {
  // Vue catch all
  Route::fallback(function () {
    return view('vue');
  });
}



use App\Models\User;
use Atomjoy\Apilogin\Notifications\Contracts\NotifyMessage;
use Atomjoy\Apilogin\Notifications\DbNotify;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
  $msg = new NotifyMessage();
  $msg->setContent('Hello max your LINK_SIGNUP and LINK_SIGNIN link (Register LINK_SIGNUP).');
  $msg->setLink('LINK_SIGNUP', 'https://example.com/signup', 'Sign Up');
  $msg->setLink('LINK_SIGNIN', 'https://example.com/signin', 'Sign In');

  $user = User::first();
  $user->notify(new DbNotify($msg));
  $user->notifyNow(new DbNotify($msg));

  return $user->notifications()->offset(0)->limit(15)->get()->each(function ($n) {
    $n->formatted_created_at = $n->created_at->format('Y-m-d H:i:s');
  });
});
sh
# Update
composer update

# Create permissions migrations
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"

# Then change the beginning of the permission migration file name to
2023_01_01_100000_create_permission_tables.php
sh
# notifications, storage
php artisan notifications:table
php artisan storage:link

# Create tables
php artisan migrate

# Refresh tables
php artisan migrate:fresh
sh
php artisan serve --host=localhost --port=8000
sh
php artisan lang:publish
php artisan vendor:publish --tag=apilogin-config--force
php artisan vendor:publish --tag=apilogin-views --force
php artisan vendor:publish --tag=apilogin-lang --force
# Permissions seeder migrations
php artisan db:seed --class=ApiloginPermissionsSeeder
sh
<testsuite name="Apilogin">
  <directory suffix="Test.php">./vendor/atomjoy/apilogin/tests/Dev</directory>
</testsuite>
sql
CREATE DATABASE IF NOT EXISTS laravel CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE IF NOT EXISTS laravel_testing CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'toor' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO [email protected] IDENTIFIED BY 'toor' WITH GRANT OPTION;
sh
php artisan test --stop-on-failure --testsuite=Apilogin