Giter Club home page Giter Club logo

Comments (2)

djunehor avatar djunehor commented on August 28, 2024

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.e php 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.

EmadAdly avatar EmadAdly commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.