I am new to Laravel and have stumbled upon a problem. Would you mind advising the right way of doing it if I am doing it incorrectly? For example, I have 3 tables: product, product_category, product_image, as below. Question 1 I am paginating my data on the frontend, but I am getting the following error with …
Tag: laravel-8
How to Install Swagger to Laravel 8 API for documentation?
Installing Swagger for the First Time in laravel 8 Getting Error like: Answer I’m guessing the URL you’re hitting might be incorrect. Change it to just docs/api-docs instead of docs/api-docs.json. In addition, if you haven’t ran the generate command already, you would have to do so to make i…
Is it possible to use a passed parameter several times in Laravel?
I am new to Laravel and I’m developing an application. I’m trying to fetch the data from a database, which works fine, and print them on a screen using a passed parameter to blade, this also works fine. However, when I want to use the same passed parameter for several times, I get the following er…
Always get related model of relationship model in Laravel Eloquent
I have three Eloquent Models: Company, OrdersArea and Localization where a company has many orders areas and orders area always have one localization. I need to getting the Orders Area model to always load with Localization If I do that: I gets Company of logged user without OrdersArea and it’s ok. and …
Check user if is in chat room Laravel
I have models: ChatRoomMembers ChatRoom so I want to check if auth user is in chat room my relationships: ChatRoom: ChatRoomMembers: Answer So I created relationship in User Model: and I am getting only this user chat rooms
Include extra validation in Laravel 8 using $errors Variable
I have a store Method for my TransactionController, at the moment it does validate that the required information is received (standard Laravel validation), nonetheless, it can’t check if the value received exists on a third table (since it’s a foreign key). Store method of TransactionController.ph…
Only some values are editing with a form Laravel 8
I am using a form and I don’t know why I can edit with it the values except in the fields apellido and cedula. I am using the same logic in all the form fields so I dunno what can be causing it. I’m gonna post the code of the view, controller, and model. View Controller Model I have no
Query One to Many Relation in Laravel 8
I have one to many relation for User and Student. Model User.php Model Student.php and in Controller.php it will run and return json can I custom select in Students, only show firstname and lastname ? Answer You should use API Resources for this. Here’s a link to the official documentation: https://lara…
Laravel Eloquent how to get relationship self object?
I have tables with below relationship And my HousingAdvertisement model has and HousingAdNearPlace when I make query like this: I got HousingAdNearPlace object in HousingAdvertisement model: How can I got self NearPlace model like this: Answer You need “Has Many Through” relationship on HousingAdv…
find() does not get the existing row
I have a resource Controller with this index method like this: But it returns this error: Trying to get property ‘slug’ of non-object And when I dd(Category::find(25), Category::find(24), Category::find(23), Category::find(22)); I get NULL results. Meaning that it can not find data with specified …