Skip to content
Advertisement

Tag: laravel

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 HousingAdvertisement And also define id keys as in ducumentation: https://laravel.com/docs/8.x/eloquent-relationships#has-many-through-key-conventions

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 ids. However there are 25 records stored at the categories table: So what is going wrong here?

Cannot union two Joints Laravel

Im trying to union 2 joins, but im getting weird error… I have “Clientes” -> means clients, and i got all the clients that they got registered in orders and news. In news table i got the cliente_id -> client_id , And in orders, i got the same, cliente_id -> client_id, In news i got x clients, and in orders

check in blade if exists variable in @include

I´m developping a system with laravel 7.4 and i need check if one variable that i´m sending from my controller exists in my blade. If exists, include it: I have this code in my controller: this return profile image or system image but it´s possible that this images don´t exists and i need check before, because i have error in

Advertisement