Giter Club home page Giter Club logo

Comments (13)

andreyvital avatar andreyvital commented on August 28, 2024 1

@EmadAdly the simplest solution I thought to resolve this issue would be to interpolate the default column name. So what I ended up doing is "default_uuid_column" => "{table}_id" which produces the desired column name.

Could you please review and merge? #11

Not sure if the code makes sense tho. Also, if you can publish it whenever you merge, that's going to be super.

from laravel-uuid.

EmadAdly avatar EmadAdly commented on August 28, 2024 1

Hey guys! Sorry for delay. I had very busy days. I'll take a look for it as soon as possible.

from laravel-uuid.

EmadAdly avatar EmadAdly commented on August 28, 2024

if you want to replacing default id with uuid and set the primary key replacing default id with uuid

or you ask if you can have more than one primary key ?

from laravel-uuid.

guilherme90 avatar guilherme90 commented on August 28, 2024

Do not.

My primary key pattern is not only id, but the name of the table + id, ie: user_id, understood?

from laravel-uuid.

EmadAdly avatar EmadAdly commented on August 28, 2024

Why don't you add a unique index, and keep the id or uuid as primary ? However, you can specify more than one column as the primary key As follows :

Schema::create('tests', function (Blueprint $table) {
  $table->unsignedInteger('id');
  $table->uuid('uuid');
  $table->string('name');
  $table->integer('user_id');
  $table->timestamps();
  $table->primary(array('id', 'name', 'user_id'));
});

from laravel-uuid.

guilherme90 avatar guilherme90 commented on August 28, 2024

Because there is no need to do this. My bank follows pattern other than id or uuid. But, there, how can you improve? It's not legal that way.

from laravel-uuid.

EmadAdly avatar EmadAdly commented on August 28, 2024

I don't know your app, and you don't explain what is the other pattern used in your bank.

And why the previous way is illegal check the Laravel docs in the Available Index types table, Is actually a composite keys. also you can set it through the mysql or phpmyadmin.

Please let me close this since it's not actually a bug report.

from laravel-uuid.

guilherme90 avatar guilherme90 commented on August 28, 2024

I just explained. I'll try again. I want the column name in my user table user_id and not id / uuid, understood now?

from laravel-uuid.

EmadAdly avatar EmadAdly commented on August 28, 2024

in config/uuid.php file set the default_uuid_column to user_id

'default_uuid_column' => 'user_id',

and if you make a first time migrate you can build schema like so

        Schema::create('cash_managements', function (Blueprint $table) {
            ...
            $table->uuid('user_id')->unique();
            ...
        });

Or if have already table in database
you can change this column to char(36) type and don't forget set as a unique.

i hope this solution will suit you

from laravel-uuid.

guilherme90 avatar guilherme90 commented on August 28, 2024

It's all right. And I want to use Laravel's modularization system, can I use this configuration file in each module? And if inside my module, I have several templates that represent different tables, how do I do in that case?

Your code has an architecture flaw ;(

from laravel-uuid.

andreyvital avatar andreyvital commented on August 28, 2024

@EmadAdly AFAIK, it doesn't suit. What I believe he's trying to say is... he wants the uuid column to be prefixed with the table name, and if I set it globally through the config/uuid.php, each model will have a user_id column rather than cash_id something_id something_else_id.

Does that make sense for ya?

from laravel-uuid.

EmadAdly avatar EmadAdly commented on August 28, 2024

I see it not a big need for this at the moment. and your approach uncommon and it is not good practice.

from laravel-uuid.

guilherme90 avatar guilherme90 commented on August 28, 2024

I totally disagree with you when you say this is a bad practice, and still says it's an unusual approach. Each one does the modeling of the bank according to its standards. I simply will not use it, and certainly many too, too, because it is very limited in its way of modeling a scheme, or in accordance with the standard laravel style.

Good luck!

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.