public function setPriority() { $first_day = SelectList::where('subject', '<', 20000)->get(); $second_day = SelectList::where('subject', '>', 20000)->get(); foreach ($first_day as $first_day_people) { $user_name = RegisterDetails::where('phone', $first_day_people->phone)->get(['account_id']); if (isset($user_name[0])) { if (isset($user_name[0]->account_id)) { RegisterSubjects::where('reg_subject_1', $first_day_people->subject)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } } $user_name = RegisterUsers::where('pid', $first_day_people->pid)->get(['id']); if (isset($user_name[0])) { if (isset($user_name[0]->account_id)) { RegisterSubjects::where('reg_subject_1', $first_day_people->subject)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } } $user_name = RegisterDetails::where('name', $first_day_people->name)->get(['account_id']); if (isset($user_name[0])) { if (isset($user_name[0]->account_id)) { RegisterSubjects::where('reg_subject_1', $first_day_people->subject)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } } $user_name = RegisterUsers::where('email', $first_day_people->email)->get(['id']); if (isset($user_name[0])) { if (isset($user_name[0]->id)) { RegisterSubjects::where('reg_subject_1', $first_day_people->subject)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } } } foreach ($second_day as $second_day_people) { $user_name = RegisterDetails::where('phone', $second_day_people->phone)->get(['account_id']); if (isset($user_name[0])) { if (isset($user_name[0]->account_id)) { if ($second_day_people->subject == 40005) { RegisterSubjects2::where('reg_subject_2', '>=', 20002)->where('reg_subject_2', '<=', 20003)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } else { RegisterSubjects2::where('reg_subject_2', $second_day_people->subject)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } } } $user_name = RegisterUsers::where('pid', $second_day_people->pid)->get(['id']); if (isset($user_name[0])) { if (isset($user_name[0]->id)) { if ($second_day_people->subject == 40005) { RegisterSubjects2::where('reg_subject_2', '>=', 20002)->where('reg_subject_2', '<=', 20003)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } else { RegisterSubjects2::where('reg_subject_2', $second_day_people->subject)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } } } $user_name = RegisterDetails::where('name', $second_day_people->name)->get(['account_id']); if (isset($user_name[0])) { if (isset($user_name[0]->account_id)) { if ($second_day_people->subject == 40005) { RegisterSubjects2::where('reg_subject_2', '>=', 20002)->where('reg_subject_2', '<=', 20003)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } else { RegisterSubjects2::where('reg_subject_2', $second_day_people->subject)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } } } $user_name = RegisterUsers::where('email', $second_day_people->email)->get(['id']); if (isset($user_name[0])) { if (isset($user_name[0]->id)) { if ($second_day_people->subject == 40005) { RegisterSubjects2::where('reg_subject_2', '>=', 20002)->where('reg_subject_2', '<=', 20003)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } else { RegisterSubjects2::where('reg_subject_2', $second_day_people->subject)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } } } } return 'SUCCESS'; }
public function PriorityMemberQuery() { $select_count = SelectList::all()->count(); $select_list = SelectList::all(); $count = 0; for ($i = 0; $i < $select_count; $i++) { if (isset($select_list[0]->pid)) { $count += RegisterUsers::where('pid', $select_list[0]->pid)->take(1)->count(); } elseif (isset($select_list[0]->email)) { $count += RegisterUsers::where('email', $select_list[0]->email)->take(1)->count(); } elseif (isset($select_list[0]->phone)) { $count += RegisterDetails::where('phone', $select_list[0]->phone)->take(1)->count(); } elseif (isset($select_list[0]->phone)) { $count += RegisterDetails::where('name', $select_list[0]->name)->take(1)->count(); } } }