DeveloperBreeze

Blade Development Tutorials, Guides & Insights

Unlock 2+ expert-curated blade tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your blade skills on DeveloperBreeze.

Creating Personal Access Tokens for a Custom Model in Laravel

Tutorial October 24, 2024

Let's assume you have a custom model called Customer. We'll configure this model to issue personal access tokens.

use Laravel\Sanctum\HasApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Customer extends Authenticatable
{
    use HasApiTokens;

    protected $fillable = ['name', 'email'];

    // Define the relationship with tokens
    public function tokens()
    {
        return $this->morphMany(\Laravel\Sanctum\PersonalAccessToken::class, 'tokenable');
    }
}

Blade View in Laravel Extending Layout

Code January 26, 2024
html

No preview available for this content.