Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1. Cargo registros de BB.DD y los meto en una nueva colección con otro orden
- $_approvalCats = $this->parseCategories($this->getApprovalCategories($_approval->id));
- public static function parseCategories($categories = null) {
- $_arrCategories = collect();
- foreach ($categories as $category) {
- if (!$_arrCategories->has($category->priority)) {
- $_arrCategories->put($category->priority, collect());
- }
- $_arrCategories[$category->priority]->push($category);
- }
- return $_arrCategories;
- }
- // 2. Mediante una serie de condiciones tengo que llamar a esta otra función a la cual se le pasa la colección de arriba.
- private function processEspecialCat($categories = null) {
- $_filterSpecial = AlertApprovalCategory::all()->filter(function($item) {
- return $item->priority == self::ESPECIAL_CATEGORY_ID;
- });
- $_test = $categories;
- $_test->put(self::ESPECIAL_CATEGORY_ID, $_filterSpecial);
- // ESTE SORT NO ME LO HACE
- $_test = $_test->sort();
- return $_test;
- }
- // 3. Y el resultado que sale en Array es:
- Array
- (
- [1] => Array
- (
- ...
- )
- [4] => Array
- (
- ...
- )
- [3] => Array
- (
- ...
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement