30 Days to Learn Laravel, Ep 12 - Pivot Tables and BelongsToMany Relationships

  Рет қаралды 13,579

Laracasts

Laracasts

Күн бұрын

Пікірлер: 29
@koertved
@koertved 9 ай бұрын
I really love laracast because even though I've been using laravel for 3 years, I still learn new things and tips in this series. Great job!
@i.t.starters2019
@i.t.starters2019 9 ай бұрын
Definitely, me too, I've been doing laravel for over 3 years but I've never really known how relationships, pivot tables actually work, and now I feel like a beginner 😅
@MrLaxr-op4be
@MrLaxr-op4be 3 ай бұрын
Hi, your tutorials are great and the thing you did on the computer after saying "I'll see you then" was beyond expectations. Cool !
@GilbertKarogoKabui
@GilbertKarogoKabui 4 ай бұрын
Wow you really make it easy to understand compared to other sources. Continue the good work.
@funkyjammaclips
@funkyjammaclips 28 күн бұрын
I have been trying for hours and even after adding PRAGMA foreing_keys=on it still will not delete the pivot table
@edorourke9223
@edorourke9223 7 ай бұрын
FYI - Tried the rollback and migration in the VSC terminal, and got the following error: "The token '&&' is not a valid statement separator in this version." Tried again in the cmd window and it was fine
@Cellohhh
@Cellohhh 5 ай бұрын
You saved me, thanks!
@SatoKazumaLvl
@SatoKazumaLvl 9 ай бұрын
Pheww. Everytime I finish an episode I feel like I level up 10 times
@diegosk8zero
@diegosk8zero 9 ай бұрын
Laravel is life
@axljoven984
@axljoven984 7 ай бұрын
Hi! Should pivot table names singular? e.g., job_tag instead of job_tags? I encountered a constraint violation error when I unknowingly job_tags.
@renatofrota
@renatofrota 6 ай бұрын
the convention for pivot tables is to name it accordingly to the model names (singular_singular), in alphabetical order. so a pivot for Posts (model Post) and Categories (model Category) would be category_post.
@axljoven984
@axljoven984 6 ай бұрын
@@renatofrota I see. That makes sense. Thanks!
@ShahidHussain-ew2bl
@ShahidHussain-ew2bl 3 ай бұрын
very nice 💞
@jerryjohnson5140
@jerryjohnson5140 8 ай бұрын
I've been debugging for some hours. I've checked and rechecked my code, but seems like my pivot table relationship is not similar as yours. Mine don't have the primary key for the job_listing_id and the tag_id
@jerryjohnson5140
@jerryjohnson5140 8 ай бұрын
5:57
@wuba6977
@wuba6977 8 ай бұрын
​@@jerryjohnson5140 Is just a structure but basically when you do $table->foreignIdFor(Model Class) which is in the video is Job::class, after migration, the column will be like this job_id, but since sir Jeffrey override it, it became like this job_listing_id. if you're inside job_tags table, the job_listing_id and tag_id are FK not PK. Maybe I miss something. You can reply your problem here so that others can also answer.
@jeremymattausch2218
@jeremymattausch2218 7 ай бұрын
I'm gonna guess you fixed that already, but if not : It probably comes from your migration "create_tags_table" where he puts 2 create in there (4:43 timestamp). This is what generates the fields in the DB if I'm not mistaken. If you've got it already, did you migrate:refresh ? If you did, did you CTLR + R while on TablePlus to refresh the DB tables/fields ? Cheers
@paulholsters7932
@paulholsters7932 6 ай бұрын
Really good video's. But I prefer edgeDB when it comes to relationships (and ORM's in general). So much simpler. So much less code to write! Just learning Laravel to get a job.
@sale7680
@sale7680 5 ай бұрын
❤❤❤
@brothercaleb
@brothercaleb 9 ай бұрын
Awesome
@jeremymattausch2218
@jeremymattausch2218 7 ай бұрын
There is a little something I have trouble understanding. You write, as relatedPivotKey and foreignPivotKey (in the Job/Tag models) for it to be "job_listing_id". Whereas, in your database (and everywhere else), it's clearly written "job_listings_id" with an "S" at listing. How come your query works with the table name not matching ? I tried without the S myself and it trhew an error not finding "job_listing_id" (which is normal, since in my database, just like yours, it's "job_listings_id" instead.
@renatofrota
@renatofrota 6 ай бұрын
the table name is "job_listings" (it is what it represents: a collection of job listings) as like the "tags" table is a collection of tags. the other hand, the columns at the pivot table job_tag holds the id of a particular listing (job_listing_id, in singular form) and the id of a particular tag (tag_id, also in singular form).
@sale7680
@sale7680 5 ай бұрын
Best best
@EnimaIffets
@EnimaIffets 9 ай бұрын
nice
I was too dumb for Laravel. Then they fixed it.
10:33
Theo - t3․gg
Рет қаралды 83 М.
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Laravel Pivot Tables: Simple to Advanced Many-to-Many
12:24
Laravel Daily
Рет қаралды 122 М.
30 Days to Learn Laravel, Ep 10 - Model Factories
19:17
Laracasts
Рет қаралды 14 М.
10 Signs Your Software Project Is Heading For FAILURE
17:59
Continuous Delivery
Рет қаралды 35 М.
Отношение belongsToMany. Гайд по отношениям в Laravel
30:37
Просто о сложном. CutCode
Рет қаралды 3,6 М.
Laravel Eloquent: Deeper Relationships with One Query
10:37
Laravel Daily
Рет қаралды 146 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 242 М.
I just tried o3-mini
6:31
ThePrimeTime
Рет қаралды 190 М.
09 - Events & Listeners
11:01
Laravel
Рет қаралды 25 М.
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН