FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Excluding Table Names from Laravel's Many-to-Many Relations
NewsSystems

Excluding Table Names from Laravel's Many-to-Many Relations

via Dev.toKenta Takeuchi12h ago

This article was originally published on bmf-tech.com . When designing many-to-many relationships, I thought I was following the documentation, but I had a slight misunderstanding. Here are three tables, right? The tables in this case: events event_tags event_tag_event ← pivot table For normal tables: events tags tag_event You would typically set up the relationship according to the default conventions, but when using slightly unconventional names, there are some things to be cautious about. Let's take a look at the documentation Laravel 5.1 Eloquent: Relationships Ah, so I just need to provide a second argument! public function eventTags () { // The second argument is the Pivot table! return $this -> belongstoMany ( 'App\Modles\EventTag' , 'event_tag_event' ) -> withTimestamps (); } public function events () { return $this -> belongsToMany ( 'App\Models\Events' ); } When I launched tinker to check... SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias on rel

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles

Brompton Electric T-Line Folding Electric Bicycle Review: Pocket-Sized Pedal Power
News

Brompton Electric T-Line Folding Electric Bicycle Review: Pocket-Sized Pedal Power

Wired • 12h ago

News

Gothub is live

Lobsters • 12h ago

I Built the Tool I Wish I Had When I Started My Open Source Journey
News

I Built the Tool I Wish I Had When I Started My Open Source Journey

Medium Programming • 12h ago

Razer Boomslang 20th Anniversary Mouse Review: For Collectors
News

Razer Boomslang 20th Anniversary Mouse Review: For Collectors

Wired • 13h ago

How Bug Bounty Hunters Prioritize 10,000 Recon Targets (Without Losing Their Mind)
News

How Bug Bounty Hunters Prioritize 10,000 Recon Targets (Without Losing Their Mind)

Medium Programming • 13h ago

Discover More Articles