1 year ago

Help with shirt -> colors -> sizes laravel relationship

Posted 1 year ago by Gabotronix

Hi everybody, I'm trying to wrap my head about this relationship which I think is many-to-many, I have 3 models, a shirt model, a shirt color model and a shirtsize model. Now this is how I see things, I could say:

One shirt can be many colors and many sizes but you could also say a shirt will be ONE color and ONE size (a shirt can't be multiple colors/sizes at once...) , so this got me pretty confused. I got the feeling this has to be a many to many relationship between shirt, size and color but I'm not so sure how (and if I should) do this?

This are my migrations:

Schema::create('shirts', function (Blueprint $table) {
            $table->decimal('finalPrice', 5,2);

Schema::create('shirtcolors', function (Blueprint $table) {

Schema::create('shirtsizes', function (Blueprint $table) {

Please sign in or create an account to participate in this conversation.