I have this Contractor Model And ContractorDetails Model I can retrieve all columns under the Contractors Model, but whenever I do this $contractors->ContractorDetails->id, it will show this error “Trying to get property ‘id’ of non-object” . however when I just use this $contractors->ContractorDetails, it is able to show this collection {“id”:6,”contractors_id”:24} My controller looks like this My blade file Any
Tag: eloquent
How to show specific order details and all products which belongs only to that specific order on same view
How to show specific order details and all products which belongs only to that specific order on same view? Trying this, but getting empty array when doing dd(). OrderController: web.php Product.php Order.php Answer I would suggest to change the name of your route param to id to consistency and readability In view generate url for your route as And in
How to use print all comments for respective posts using relationship in Laravel 8
I am trying to print all comments per post using the relationship, Error: Property [comments] does not exist on the Eloquent builder instance. Post Model class WorkTravel extends Model { use …
Laravel Eloquent – Query with multiples parameters
I’m new to the Laravel framework and I could need a little help from you. Could someone help me to convert this request into Eloquent ? SELECT * FROM `non_working_days` WHERE YEAR(date) = “2021&…
Trying to get property ‘approval_code’ of non-object
I’m trying to build a task scheduler for sending email routine and i got this error when i try to get approval_code from auth. Here are my code in mail: <?php namespace AppMail; use Illuminate…
How to figure out what number a record is, when in date order
In my Laravel project I have a Policy model that looks like so: As you can see there are versions of a policy. My policy versions table schema looks like so: My question is as follows: if I have five versions of a policy in date order and I select a policy version, how could I say “you are on
Laravel Eloquent. When using With(), how can I pass data to the Model?
My db structure is Profile ID .. Profile_row ID Name: eks “First_name” Content: eks “James” Profile_id: 1 In my controller I do this: and my Profile Model looks like this And I get a nice nested list with profiles, and every profile_row where name=first_name under. But how can I send a argument from the controller to the Model where I
How to get records between two latitudes and longitudes using Laravel, php [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed last year. Improve this question here what I tried to get but it returns empty between 2 given coordinates Answer Check datatype Use a numeric database column type. Example of errors with a
How to display a table according to a foreign key which is display from another foreign key / Laravel 6
Model: public function followup() { return $this->hasMany(‘AppFollowUp’, ‘id_log’, ‘id’) ->select([‘id’, ‘id_log’, ‘request’, ‘id_priority’]); } follow_up.id_priority is a foreign key …
Adding additional column to the result of relationship in eloquent
I have two models. Both of them are pivots because they join other tables. But also they have a relationship with themselves. I want to get all entities of CompanyUserProduct but with the additional column user_id from CompanyUser, so I can do pluck(‘user_id’) on the collection and get all IDs at once. Is it possible to do it in Eloquent,