I have a query that returns a collection object like so:
Illuminate\Database\Eloquent\Collection Object
(
[items:protected] => Array
(
[0] => App\Http\Models\LabTestRequests Object
(
[table:protected] => lab_test_requests
[primaryKey:protected] => request_id
[connection:protected] =>
[keyType:protected] => int
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[status_category] => Old Results
)
[original:protected] => Array
(
[status_category] => Old Results
)
[relations:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable:protected] => Array
(
)
[guarded:protected] => Array
(
[0] => *
)
[dates:protected] => Array
(
)
[dateFormat:protected] =>
[casts:protected] => Array
(
)
[touches:protected] => Array
(
)
[observables:protected] => Array
(
)
[with:protected] => Array
(
)
[exists] => 1
[wasRecentlyCreated] =>
)
[1] => App\Http\Models\LabTestRequests Object
(
[table:protected] => lab_test_requests
[primaryKey:protected] => request_id
[connection:protected] =>
[keyType:protected] => int
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[status_category] => Pending
)
[original:protected] => Array
(
[status_category] => Pending
)
[relations:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable:protected] => Array
(
)
[guarded:protected] => Array
(
[0] => *
)
[dates:protected] => Array
(
)
[dateFormat:protected] =>
[casts:protected] => Array
(
)
[touches:protected] => Array
(
)
[observables:protected] => Array
(
)
[with:protected] => Array
(
)
[exists] => 1
[wasRecentlyCreated] =>
)
[2] => App\Http\Models\LabTestRequests Object
(
[table:protected] => lab_test_requests
[primaryKey:protected] => request_id
[connection:protected] =>
[keyType:protected] => int
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[status_category] => Done
)
[original:protected] => Array
(
[status_category] => Done
)
[relations:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable:protected] => Array
(
)
[guarded:protected] => Array
(
[0] => *
)
[dates:protected] => Array
(
)
[dateFormat:protected] =>
[casts:protected] => Array
(
)
[touches:protected] => Array
(
)
[observables:protected] => Array
(
)
[with:protected] => Array
(
)
[exists] => 1
[wasRecentlyCreated] =>
)
[3] => App\Http\Models\LabTestRequests Object
(
[table:protected] => lab_test_requests
[primaryKey:protected] => request_id
[connection:protected] =>
[keyType:protected] => int
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[status_category] => Non-Negative
)
[original:protected] => Array
(
[status_category] => Non-Negative
)
[relations:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable:protected] => Array
(
)
[guarded:protected] => Array
(
[0] => *
)
[dates:protected] => Array
(
)
[dateFormat:protected] =>
[casts:protected] => Array
(
)
[touches:protected] => Array
(
)
[observables:protected] => Array
(
)
[with:protected] => Array
(
)
[exists] => 1
[wasRecentlyCreated] =>
)
[4] => App\Http\Models\LabTestRequests Object
(
[table:protected] => lab_test_requests
[primaryKey:protected] => request_id
[connection:protected] =>
[keyType:protected] => int
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[status_category] => Test Complete Pending Review
)
[original:protected] => Array
(
[status_category] => Test Complete Pending Review
)
[relations:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable:protected] => Array
(
)
[guarded:protected] => Array
(
[0] => *
)
[dates:protected] => Array
(
)
[dateFormat:protected] =>
[casts:protected] => Array
(
)
[touches:protected] => Array
(
)
[observables:protected] => Array
(
)
[with:protected] => Array
(
)
[exists] => 1
[wasRecentlyCreated] =>
)
)
)
In my view im iterating through each and showing the status_category value - what im trying to accomplish is to check if a specific status_category value does not exist then to add it to the end. I have tried doing: $categories->prepend('test', 'status_category');
but that doesnt add it like the object above and therefore my view will throw an error. Any ideas on this?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2X6QY88
via IFTTT
Aucun commentaire:
Enregistrer un commentaire