Comments (13)
@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.
Hey guys! Sorry for delay. I had very busy days. I'll take a look for it as soon as possible.
from laravel-uuid.
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.
Do not.
My primary key pattern is not only id
, but the name of the table + id, ie: user_id
, understood?
from laravel-uuid.
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.
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.
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.
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.
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.
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.
@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.
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.
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)
- 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
- Automatitly generate uuid for an existing table HOT 2
- 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.