Skip to content

Tag: eloquent

Get all data where pivot id (Laravel)

Is there the best way/the simplest way to get all data where pivot? I tried this $article = Article::with(‘category’)->wherePivot(‘category_id’, $category)->get(); but i got error The relation is many to many Article id content Articles_Has_Categories id article_id category_id Ca…

Laravel seeder with Eloquent give timestamp null

I am trying to insert static data, with the help of the seeder and Eloquent as bellow. Even after using Eloquent i am getting timestamp null in database. Answer The timestamp columns (created_at and updated_at) will be assigned automatically only if you are using the Eloquent save() method and create method a…