Laravel Apiato Using uuid in users table

I am a backend developer from Indonesia, focused on php, and some cloud platform administrator
Search for a command to run...

I am a backend developer from Indonesia, focused on php, and some cloud platform administrator
No comments yet. Be the first to comment.
AWS 3-Tier Architecture is an excellent choice for developers who aim to run their systems efficiently while minimizing costs. This architecture is structured into three distinct layers: the Presentation Tier, the Application Tier, and the Database T...
Pendahuluan Pada artikel ini kalian akan belajar tentang bagaimana build extensi PHP dengan menggunakan make, yang mana tools tersebut membantu dalam me-build PHP Library dari source code sehingga lebih fleksible digunakan pada berbagai versi php dal...
Hi everyone today i want to show you how to make filter search name by combine first name and last name in database field using laravel repository with implement request criteria refer to this l5-repository. Database Scheme first we have a database w...

Sometimes when you try to deploy your front-end frameworks like vue.js or react.js, your web server cannot refresh your page after you login into that page. Here are some configurations in your web server configuration if you are using NGINX : locati...
first things you must to do is use libray or something to provide uuid, you can use ramsey/uuid or use from laravel facades Illuminate\Database\Eloquent\Concerns\HasUuids.
namespace App\Containers\AppSection\User\Models;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
class User extends ParentUserModel implements MustVerifyEmail
{
use HasUuids;
...
public $incrementing = false;
...
protected $casts = [
...
'id' => 'string'
];
}
Next step is modify your migration file to make sure all field from bigInt to char(36), use this reference for spatie migration table
look at your file _create_users_table in ...\Containers\AppSection\User\Data\Migrations\2000_01_01_000001_create_users_table.php and change $table->id(); to $table->uuid('id');
in file ...\Containers\AppSection\Authorization\Data\Migrations\2016_12_29_201047_create_permission_tables.php find table model_has_roles and model_has_permissions modify like this
$table->unsignedBigInteger($columnNames['model_morph_key']);
// change to
$table->uuid($columnNames['model_morph_key']);
go to ...\app\database\migrations\2016_06_01_000002_create_oauth_access_tokens_table.php change $table->unsignedBigInteger('user_id')->nullable()->index(); to $table->uuid('user_id')->nullable()->index();
oauth_auth_codes tablego to ...\app\database\migrations\2016_06_01_000001_create_oauth_auth_codes_table then change $table->unsignedBigInteger('user_id')->index(); to $table->uuid('user_id')->index();
default notification is use hashed id which is auto increment id, but if we use uuid we cannot use that, so we must modify verify email file go to ...\app\Containers\AppSection\Authentication\Notifications\VerifyEmail.php
private function createUrl(UserModel $notifiable): string
{
$id = config('apiato.hash-id') ? $notifiable->getHashedKey() : $notifiable->getKey(); // this code will be modify
// change to this
$id = $notifiable->getKey();
$hash = sha1($notifiable->getEmailForVerification());
return $this->verification_url . '?url=' . URL::temporarySignedRoute(
'verification.verify',
now()->addMinutes(config('appSection-authentication.verification_link_expiration_time')),
[
'id' => $id,
'hash' => $hash,
]
);
}
from code above link verification will use uuid key, alternatively you can set in .env change HASH_ID=true to HASH_ID=false. After you modify verify email notification next step is modify verification.verify this will receive token and id to validated your email verification, go to ...\app\Containers\AppSection\Authentication\UI\API\Requests\VerifyEmailRequest.php this request file is use in ...\app\Containers\AppSection\Authentication\UI\API\Controllers\VerifyEmailController.php then comment id from decode, this will make request receive real id which is uuid than hash id.
protected array $decode = [
// 'id',
];
last step is do that migration php artisan migrate --seed