Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. if ($ajax = Yii::$app->request->isAjax){
  2.             // get the ajax post
  3.             $workDaysInput = Yii::$app->request->post('input');
  4.  
  5.             // map over the items
  6.             $workDays = collect($workDaysInput)
  7.                 ->map(function ($record){
  8.  
  9.                     $identification = $record['identification'];
  10.  
  11.                     $re = '/^work_days\[(.*?)\]/';
  12.                     $str = $identification;
  13.  
  14.                     preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
  15.  
  16.                     $recordId   = preg_replace('/\D/','',$identification);
  17.                     $recordType = $matches[0][1];
  18.  
  19.                     $record['type'] = $recordType;
  20.                     $record['id'] = $recordId;
  21.  
  22.                     // change record and populate with id and type
  23.                     return $record;
  24.                 })
  25.                 // simply sort by type for easier search
  26.                 ->keyBy('type');
  27.  
  28.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement