Questions tagged [laravel-collection]

A fluent, convenient wrapper for working with arrays of data provided by Illuminate\Support\Collection class.

368 questions
-1
votes
1 answer

Property [vehiclemodel] does not exist on this collection instance. in hasOneThrough relationship

Hi I am trying to get the model of a vehicle through hasOneThrough Relationship, but I am failing with the property, what am I doing…
Raydenz8
  • 13
  • 3
-1
votes
1 answer

Is there any way to loop 2 foreach and one for loop together?

I am working on Laravel 8 project where i shall create Human Resources Management System, so i struggle now with reporting of employees attendance. I have 2 model User.php and Attendance.php also 2 controllers and relation between the models. public…
Martin M
  • 111
  • 1
  • 12
-1
votes
1 answer

hide attributes in Laravel API Resource

I want to hide an attribute in the Collection API Resource I don't want to do it always, so I need something like makeHidden() to do it when I want. But API Resource return Illuminate\Support\Collection instance that has not makeHidden() method the…
samir
  • 159
  • 5
  • 13
-1
votes
2 answers

How to remove a selected item from a collection in Laravel?

I want toa remove an item that is selected from a collection. $resultCollection = $collection->where('test_key','test_value')->deleteORremove(); //$collection =…
reza yavari
  • 1
  • 1
  • 2
-1
votes
1 answer

Laravel - Sort collection with a specific order given by an array of ids

I'm trying to achieve the following: Lets say I have a collection of products like this one: $products = [{ id: 1, name: example1, price: 10 }, {id: 2, name: example2, price: 20}] And one array with one id: [0 => 2] I want to sort the $products…
-2
votes
1 answer

Laravel 5.8 - collect method return me undefined index

I got this array: What I want to do next is to make a collection from the array and I write: $variant_images = collect($p->images); but I got the error: "Undefined index: images" What's bad in my code and how to solve it?
Aleks Per
  • 1,549
  • 7
  • 33
  • 68
-2
votes
3 answers

Convert array laravel

I use Laravel framework and I have an array: [▼ "0.022" => "24.00000000" "0.013" => "506.00000000" "0.041" => "65.00000000" ] Could you help me to convert it to new format like this: [▼ 0 => {▼ "xxx": 0.022 "yyy": 24.00000000 } …
-2
votes
2 answers

Laravel : How to get values from table available in array?

I am using laravel 5 and having following array: array:3 [▼ 0 => 3, 1 => 4, 2 => 5 ] Now i wanted to get all values/rows from table say 'X' having id's 3,4,5
Kapil Verma
  • 178
  • 3
  • 17
1 2 3
24
25