/** * Seed table. */ public function run() { $types = \App\NotificationType::all(); foreach ($types as $type) { factory(\App\Notification::class)->create(['notification_type_id' => $type->id, 'targeted_user_id' => \App\TargetedUser::where('key', 'none')->first()->id]); } }
/** * Update targeted users group for given $notificationId. * * @param string $group * @param int $notificationId */ private static function _updateTargetGroup($group, $notificationId) { Notification::where('id', $notificationId)->update(['targeted_user_id' => TargetedUser::where('name', $group)->first()->id]); }
/** * Return targeted users. * * @param GetTargetedUsersRequest $request * @param AjaxResponse $response * @return mixed */ public function getTargetedUsers(GetTargetedUsersRequest $request, AjaxResponse $response) { $targetedUsers = TargetedUser::all(); $response->setSuccessMessage(trans('notifications.targeted_users_returned')); $response->addExtraFields(['targeted_users' => $targetedUsers, 'number_of_targeted_users' => count($targetedUsers)]); return response($response->get())->header('Content-Type', 'application/json'); }