Update the following dependencies in composer.json
jakyeru/larascord
to^5.0
Run the composer update
command
composer update
Publish and run the migrations
php artisan vendor:publish --provider="Jakyeru\Larascord\LarascordServiceProvider" --tag="migrations"
php artisan migrate
Publish the config file
php artisan larascord:publish --force
Add the InteractsWithDiscord
trait to your User
model
app/Models/User.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;U
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Jakyeru\Larascord\Traits\InteractsWithDiscord;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, InteractsWithDiscord;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'id',
'username',
'discriminator',
'email',
'avatar',
'verified',
'locale',
'mfa_enabled',
'refresh_token'
];
/**
* The attributes that should be hidden for serialization.
*
* @var array
*/
protected $hidden = [
'refresh_token',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'id' => 'string',
'username' => 'string',
'discriminator' => 'string',
'email' => 'string',
'avatar' => 'string',
'verified' => 'boolean',
'locale' => 'string',
'mfa_enabled' => 'boolean',
'refresh_token' => 'encrypted',
'roles' => 'json',
];
}
Remove the refresh_token
from the User
model
app/Models/User.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Jakyeru\Larascord\Traits\InteractsWithDiscord;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, InteractsWithDiscord;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'id',
'username',
'discriminator',
'email',
'avatar',
'verified',
'locale',
'mfa_enabled',
'roles',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array
*/
protected $hidden = [
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'id' => 'string',
'username' => 'string',
'discriminator' => 'string',
'email' => 'string',
'avatar' => 'string',
'verified' => 'boolean',
'locale' => 'string',
'mfa_enabled' => 'boolean',
'roles' => 'json',
];
}
Cast the id
attribute to an integer
app/Models/User.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Jakyeru\Larascord\Traits\InteractsWithDiscord;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, InteractsWithDiscord;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'id',
'username',
'discriminator',
'email',
'avatar',
'verified',
'locale',
'mfa_enabled',
'roles',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array
*/
protected $hidden = [
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'id' => 'integer',
'username' => 'string',
'discriminator' => 'string',
'email' => 'string',
'avatar' => 'string',
'verified' => 'boolean',
'locale' => 'string',
'mfa_enabled' => 'boolean',
'roles' => 'json',
];
}