Comments (2)
In the case of others, here's a quick fix.
-
After installing the package, publish the config
php artisan vendor:publish --provider="Emadadly\LaravelUuid\LaravelUuidServiceProvider"
and set the uuid column if need be. -
Create a migration to add uuid column to
users
table i.ephp artisan make:migration add_uuid_column_to_users_table
.
The up
method should contain:
Schema::table('users', function (Blueprint $table) {
if(Schema::hasColumn('users', 'uuid')) {
$table->dropColumn(config('uuid.default_uuid_column'));
}
});
-
Run
php artisan migrate
-
Create a Seeder for users table i.e
php artisan db:seed --class=UsersTableSeeder
-
The
run
method should contain:
// Eloquent
\App\User::query()->orderBy('id')->chunk(100, function ($users) {
foreach ($users as $user) {
$user->{config('uuid.default_uuid_column')} = Uuid::uuid4()->toString();
$user->save();
}
});
// Query builder
$tableName = 'users';
$uuidColumn = config('uuid.default_uuid_column');
\DB::table('users')->orderBy('id')->chunk(100, function ($users) use ($tableName, $uuidColumn) {
foreach ($users as $user) {
\DB::table($tableName)
->where('id', $user->id)
->update([$uuidColumn => Uuid::uuid4()->toString()]);
}
});
from laravel-uuid.
Closing this as this is not an issue about the internals of the package.
Feel free to keep the conversation going.
from laravel-uuid.
Related Issues (20)
- Checking whether a record with generated Uuid exists HOT 7
- uuid is not saved when using model observer HOT 3
- uuid is not saved with pivot HOT 5
- Can not work in Laravel 5.7 HOT 1
- Laravel 5.7 & UUID HOT 7
- Laravel 5.8 HOT 1
- Laravel 6 HOT 1
- Add support laravel 6.2 up HOT 1
- Insert the autoincrement ID in the foreign keys instead of the UUID
- Documentation suggests both unique and primary index on the id column HOT 1
- Creating new record manually setting primary UUID HOT 1
- Support for laravel 7.0 HOT 2
- Note about casting the UUID when using Auth
- Auto discovery features issues
- PHP 8 support HOT 3
- Pipeline failed for PHP8 support HOT 1
- Laravel 9 Support HOT 1
- Laravel 9 update not published HOT 2
- Too few arguments to function Illuminate\Database\Eloquent\Model::setAttribute(), 1 passed in /var/www/app/PRS_System_V3/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 1036 and exactly 2 expected
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-uuid.