Laravel 10. How to switch laravel default notification model uuid to id?
- User
Laravel 10. How to switch laravel default notification model uuid to id?
- Assistant
To switch Laravel default notification model uuid to id, you can follow the steps given below:
- Create a new migration file using the artisan command:
codephp artisan make:migration change_notification_uuid_to_id --table=notifications- In your migration file, add the following code to change the column type from ‘uuid’ to ‘unsigned integer (id)’:
codepublic function up() { Schema::table('notifications', function (Blueprint $table) { $table->dropColumn('notifiable_id'); $table->unsignedBigInteger('notifiable_id')->nullable(); }); } public function down() { Schema::table('notifications', function (Blueprint $table) { $table->dropColumn('notifiable_id'); $table->uuid('notifiable_id')->nullable(); }); } - User
Laravel 10. how to use id instead of uuid in laravel notification itself, not notifiable_id, but id of notification?
- Assistant
To use id instead of uuid in Laravel notification itself, you can follow these steps:
- Create a new migration file using the artisan command:
codephp artisan make:migration change_notification_uuid_to_id --table=notifications- In your migration file, add the following code to change the column type from ‘uuid’ to ‘unsigned integer (id)’:
codepublic function up() { Schema::table('notifications', function (Blueprint $table) { $table->dropColumn('id'); $table->unsignedBigInteger('id')->primary(); }); } public function down() { Schema::table('notifications', function (Blueprint $table) { $table->dropColumn('id'); $table->uuid('id')->primary(); }); } - User
Laravel notifications. how to override default id used by notifications from string to bigInteger?
- Assistant
To override the default id used by notifications in Laravel from string to bigInteger, you can follow the steps given below:
- Create a new migration file using the artisan command:
codephp artisan make:migration alter_notifications_table_for_bigint_id --table=notifications- In your migration file, add the following code to change the column type of
idfrom string to bigInteger:
code