public function postUser($user_id) { can('user.manage'); $user = UserModel::find($user_id); $role = RoleModel::find(request()->role_id); if ($user->hasRole($role)) { $user->revokeRole($role); } else { $user->assignRole($role); } return redirect('role/user/' . $user_id); }
public function postSendemail($event_id) { can('registration.email'); // fetch users $reg = RegistrationModel::where('event_id', $event_id); if (request()->is_confirmed) { $reg->where('is_confirmed', 1); } if (request()->is_accepted) { $reg->where('is_accepted', 1); } if (request()->is_attended) { $reg->where('is_attended', 1); } $reg = $reg->get(); // d(request()->input()); // dd($reg); $count = 0; // loop through those users foreach ($reg as $instance) { $user = UserModel::find($instance->user_id); \Mail::send('email / custom', ['confirm_attendance' => request()->confirm_attendance, 'event_id' => $event_id, 'user' => $user, 'body' => request()->body], function ($m) use($user) { $m->from('noreply@NablusTechMeetups . com', 'Nablus Tech Meetups'); $m->to($user->email, $user->name)->subject(request()->subject); }); $count++; } // done! flash('emails in - queued for ' . $count, 'success'); return redirect(' / registration / view / ' . $event_id); }