skip to Main Content

Laravel: collection map() returns wrong data

I have adverts (eloquent collection) with eager loaded advert attributes (details) and their values: $adverts = Advert::where('category_id', 1312)->with(['attributesValues.attribute'])->get(); $adverts->map(function (Advert $advert) { $details = new IlluminateDatabaseEloquentCollection(); foreach ($advert->attributesValues as $attributeValue) { $detail = $attributeValue->attribute; $detail->value = $attributeValue->value; $details->push($detail); } $advert->details…

VIEW QUESTION

Laravel sending raw request body

I am trying to send an API request to the endpoint, and it is successful via Postman raw JSON, Now I am implementing the same in Laravel with HTTP facade. Below is a POSTMAN screenshot with the successful response from…

VIEW QUESTION

Laravel Model attribute

I am using a third party table which very annoyingly has name and surname fields. The first name goes into name and of course the surname goes into surname. I want to concat these together in the model as I…

VIEW QUESTION
Back To Top
Search