Skip to content
Advertisement

Tag: laravel-7

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 Category id name Answer Please try this:

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 are Eloquent. While insert method is not Eloquent, it’s

How to get saved value from dropdown in edit page laravel?

inside EmployeeController in the edit function, i have this code and inside edit.blade.php to display the dropdown i have this code This is the employees table and this is departments table Now, the goal is i want the dropdown on edit page to display department name of the employee belongs to, while the dropdown still have all of the department

Advertisement