Skip to content

Tag: relationship

Laravel polymorphic with custom foreign key

I have problem with custom shipmentable_type. My structure looks like this: Now I have in my Transfer model realtion like this: The problem is, that to table shipmentable, to column shipmentable_type is going sth like this now: App/Models/Transfer, but I would like to force to be there ‘transfer’ …

Laravel Eloquent – Attach vs Sync

What is the difference between attach() and sync() in Laravel 4’s Eloquent ORM? I’ve tried to look around but couldn’t find anything! Answer attach(): Insert related models when working with many-to-many relations No array parameter is expected Example: sync(): Similar to the attach() method…