Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($ajax = Yii::$app->request->isAjax){
- // get the ajax post
- $workDaysInput = Yii::$app->request->post('input');
- // map over the items
- $workDays = collect($workDaysInput)
- ->map(function ($record){
- $identification = $record['identification'];
- $re = '/^work_days\[(.*?)\]/';
- $str = $identification;
- preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
- $recordId = preg_replace('/\D/','',$identification);
- $recordType = $matches[0][1];
- $record['type'] = $recordType;
- $record['id'] = $recordId;
- // change record and populate with id and type
- return $record;
- })
- // simply sort by type for easier search
- ->keyBy('type');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement