@@ -7,67 +7,67 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Handler extends ExceptionHandler |
| 9 | 9 | {
|
| 10 | - /** |
|
| 11 | - * A list of the exception types that are not reported. |
|
| 12 | - * |
|
| 13 | - * @var array |
|
| 14 | - */ |
|
| 15 | - protected $dontReport = [ |
|
| 16 | - \League\OAuth2\Server\Exception\OAuthServerException::class, |
|
| 17 | - ]; |
|
| 10 | + /** |
|
| 11 | + * A list of the exception types that are not reported. |
|
| 12 | + * |
|
| 13 | + * @var array |
|
| 14 | + */ |
|
| 15 | + protected $dontReport = [ |
|
| 16 | + \League\OAuth2\Server\Exception\OAuthServerException::class, |
|
| 17 | + ]; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * A list of the inputs that are never flashed for validation exceptions. |
|
| 21 | - * |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - protected $dontFlash = [ |
|
| 25 | - 'password', |
|
| 26 | - 'password_confirmation', |
|
| 27 | - ]; |
|
| 19 | + /** |
|
| 20 | + * A list of the inputs that are never flashed for validation exceptions. |
|
| 21 | + * |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + protected $dontFlash = [ |
|
| 25 | + 'password', |
|
| 26 | + 'password_confirmation', |
|
| 27 | + ]; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Report or log an exception. |
|
| 31 | - * |
|
| 32 | - * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|
| 33 | - * |
|
| 34 | - * @param \Exception $exception |
|
| 35 | - * @return void |
|
| 36 | - */ |
|
| 37 | - public function report(Exception $exception) |
|
| 38 | - {
|
|
| 39 | - parent::report($exception); |
|
| 40 | - } |
|
| 29 | + /** |
|
| 30 | + * Report or log an exception. |
|
| 31 | + * |
|
| 32 | + * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
|
| 33 | + * |
|
| 34 | + * @param \Exception $exception |
|
| 35 | + * @return void |
|
| 36 | + */ |
|
| 37 | + public function report(Exception $exception) |
|
| 38 | + {
|
|
| 39 | + parent::report($exception); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Render an exception into an HTTP response. |
|
| 44 | - * |
|
| 45 | - * @param \Illuminate\Http\Request $request |
|
| 46 | - * @param \Exception $exception |
|
| 47 | - * @return \Illuminate\Http\Response |
|
| 48 | - */ |
|
| 49 | - public function render($request, Exception $exception) |
|
| 50 | - {
|
|
| 51 | - if ($request->wantsJson()) {
|
|
| 52 | - if ($exception instanceof \Illuminate\Auth\AuthenticationException) {
|
|
| 53 | - \Errors::unAuthorized(); |
|
| 54 | - } |
|
| 55 | - if ($exception instanceof \Illuminate\Database\QueryException) {
|
|
| 56 | - \Errors::dbQueryError(); |
|
| 57 | - } elseif ($exception instanceof \predis\connection\connectionexception) {
|
|
| 58 | - \Errors::redisNotRunning(); |
|
| 59 | - } elseif ($exception instanceof \GuzzleHttp\Exception\ClientException) {
|
|
| 60 | - \Errors::connectionError(); |
|
| 61 | - } elseif ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) {
|
|
| 62 | - $errors = $exception->getStatusCode() === 404 ? 'not found' : $exception->getMessage(); |
|
| 63 | - return \Response::json(['errors' => [$errors]], $exception->getStatusCode()); |
|
| 64 | - } elseif ($exception instanceof \Illuminate\Validation\ValidationException) {
|
|
| 65 | - return \Response::json(['errors' => $exception->errors()], 422); |
|
| 66 | - } elseif (! $exception instanceof \Symfony\Component\ErrorHandler\Error\FatalError) {
|
|
| 67 | - return parent::render($request, $exception); |
|
| 68 | - } |
|
| 69 | - } |
|
| 42 | + /** |
|
| 43 | + * Render an exception into an HTTP response. |
|
| 44 | + * |
|
| 45 | + * @param \Illuminate\Http\Request $request |
|
| 46 | + * @param \Exception $exception |
|
| 47 | + * @return \Illuminate\Http\Response |
|
| 48 | + */ |
|
| 49 | + public function render($request, Exception $exception) |
|
| 50 | + {
|
|
| 51 | + if ($request->wantsJson()) {
|
|
| 52 | + if ($exception instanceof \Illuminate\Auth\AuthenticationException) {
|
|
| 53 | + \Errors::unAuthorized(); |
|
| 54 | + } |
|
| 55 | + if ($exception instanceof \Illuminate\Database\QueryException) {
|
|
| 56 | + \Errors::dbQueryError(); |
|
| 57 | + } elseif ($exception instanceof \predis\connection\connectionexception) {
|
|
| 58 | + \Errors::redisNotRunning(); |
|
| 59 | + } elseif ($exception instanceof \GuzzleHttp\Exception\ClientException) {
|
|
| 60 | + \Errors::connectionError(); |
|
| 61 | + } elseif ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) {
|
|
| 62 | + $errors = $exception->getStatusCode() === 404 ? 'not found' : $exception->getMessage(); |
|
| 63 | + return \Response::json(['errors' => [$errors]], $exception->getStatusCode()); |
|
| 64 | + } elseif ($exception instanceof \Illuminate\Validation\ValidationException) {
|
|
| 65 | + return \Response::json(['errors' => $exception->errors()], 422); |
|
| 66 | + } elseif (! $exception instanceof \Symfony\Component\ErrorHandler\Error\FatalError) {
|
|
| 67 | + return parent::render($request, $exception); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - return parent::render($request, $exception); |
|
| 72 | - } |
|
| 71 | + return parent::render($request, $exception); |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Here goes your error messages. |
|
| 7 | - */ |
|
| 5 | + /** |
|
| 6 | + * Here goes your error messages. |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | ]; |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Here goes your error messages. |
|
| 7 | - */ |
|
| 5 | + /** |
|
| 6 | + * Here goes your error messages. |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | ]; |
@@ -10,36 +10,36 @@ |
||
| 10 | 10 | class Permission extends Model |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - use SoftDeletes; |
|
| 14 | - protected $table = 'permissions'; |
|
| 15 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 16 | - protected $hidden = ['deleted_at']; |
|
| 17 | - protected $guarded = ['id']; |
|
| 18 | - protected $fillable = ['name', 'model']; |
|
| 19 | - |
|
| 20 | - public function getCreatedAtAttribute($value) |
|
| 21 | - { |
|
| 22 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public function getUpdatedAtAttribute($value) |
|
| 26 | - { |
|
| 27 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - public function getDeletedAtAttribute($value) |
|
| 31 | - { |
|
| 32 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 33 | - } |
|
| 13 | + use SoftDeletes; |
|
| 14 | + protected $table = 'permissions'; |
|
| 15 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 16 | + protected $hidden = ['deleted_at']; |
|
| 17 | + protected $guarded = ['id']; |
|
| 18 | + protected $fillable = ['name', 'model']; |
|
| 19 | + |
|
| 20 | + public function getCreatedAtAttribute($value) |
|
| 21 | + { |
|
| 22 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public function getUpdatedAtAttribute($value) |
|
| 26 | + { |
|
| 27 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + public function getDeletedAtAttribute($value) |
|
| 31 | + { |
|
| 32 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public function roles() |
|
| 36 | - { |
|
| 37 | - return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps(); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - public static function boot() |
|
| 41 | - { |
|
| 42 | - parent::boot(); |
|
| 43 | - Permission::observe(PermissionObserver::class); |
|
| 44 | - } |
|
| 35 | + public function roles() |
|
| 36 | + { |
|
| 37 | + return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps(); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + public static function boot() |
|
| 41 | + { |
|
| 42 | + parent::boot(); |
|
| 43 | + Permission::observe(PermissionObserver::class); |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Here goes your error messages. |
|
| 7 | - */ |
|
| 5 | + /** |
|
| 6 | + * Here goes your error messages. |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | ]; |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Here goes your error messages. |
|
| 7 | - */ |
|
| 5 | + /** |
|
| 6 | + * Here goes your error messages. |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | ]; |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Here goes your error messages. |
|
| 7 | - */ |
|
| 5 | + /** |
|
| 6 | + * Here goes your error messages. |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | ]; |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Here goes your error messages. |
|
| 7 | - */ |
|
| 5 | + /** |
|
| 6 | + * Here goes your error messages. |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | ]; |
@@ -10,63 +10,63 @@ |
||
| 10 | 10 | |
| 11 | 11 | class PushNotificationDeviceService extends BaseService |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Init new object. |
|
| 15 | - * |
|
| 16 | - * @param PushNotificationDeviceRepository $repo |
|
| 17 | - * @return void |
|
| 18 | - */ |
|
| 19 | - public function __construct(PushNotificationDeviceRepository $repo) |
|
| 20 | - { |
|
| 21 | - parent::__construct($repo); |
|
| 22 | - } |
|
| 13 | + /** |
|
| 14 | + * Init new object. |
|
| 15 | + * |
|
| 16 | + * @param PushNotificationDeviceRepository $repo |
|
| 17 | + * @return void |
|
| 18 | + */ |
|
| 19 | + public function __construct(PushNotificationDeviceRepository $repo) |
|
| 20 | + { |
|
| 21 | + parent::__construct($repo); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Register the given device to the logged in user. |
|
| 26 | - * |
|
| 27 | - * @param array $data |
|
| 28 | - * @return void |
|
| 29 | - */ |
|
| 30 | - public function registerDevice($data) |
|
| 31 | - { |
|
| 32 | - $data['access_token'] = \Auth::user()->token(); |
|
| 33 | - $data['user_id'] = \Auth::id(); |
|
| 34 | - $device = $this->repo->first([ |
|
| 35 | - 'and' => [ |
|
| 36 | - 'device_token' => $data['device_token'], |
|
| 37 | - 'user_id' => $data['user_id'] |
|
| 38 | - ] |
|
| 39 | - ]); |
|
| 24 | + /** |
|
| 25 | + * Register the given device to the logged in user. |
|
| 26 | + * |
|
| 27 | + * @param array $data |
|
| 28 | + * @return void |
|
| 29 | + */ |
|
| 30 | + public function registerDevice($data) |
|
| 31 | + { |
|
| 32 | + $data['access_token'] = \Auth::user()->token(); |
|
| 33 | + $data['user_id'] = \Auth::id(); |
|
| 34 | + $device = $this->repo->first([ |
|
| 35 | + 'and' => [ |
|
| 36 | + 'device_token' => $data['device_token'], |
|
| 37 | + 'user_id' => $data['user_id'] |
|
| 38 | + ] |
|
| 39 | + ]); |
|
| 40 | 40 | |
| 41 | - if ($device) { |
|
| 42 | - $data['id'] = $device->id; |
|
| 43 | - } |
|
| 41 | + if ($device) { |
|
| 42 | + $data['id'] = $device->id; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return $this->repo->save($data); |
|
| 46 | - } |
|
| 45 | + return $this->repo->save($data); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Generate the given message data. |
|
| 50 | - * |
|
| 51 | - * @param string $title |
|
| 52 | - * @param string $message |
|
| 53 | - * @param array $data |
|
| 54 | - * @return void |
|
| 55 | - */ |
|
| 56 | - public function generateMessageData($title, $message, $data = []) |
|
| 57 | - { |
|
| 58 | - $optionBuilder = new OptionsBuilder(); |
|
| 59 | - $notificationBuilder = new PayloadNotificationBuilder($title); |
|
| 60 | - $dataBuilder = new PayloadDataBuilder(); |
|
| 48 | + /** |
|
| 49 | + * Generate the given message data. |
|
| 50 | + * |
|
| 51 | + * @param string $title |
|
| 52 | + * @param string $message |
|
| 53 | + * @param array $data |
|
| 54 | + * @return void |
|
| 55 | + */ |
|
| 56 | + public function generateMessageData($title, $message, $data = []) |
|
| 57 | + { |
|
| 58 | + $optionBuilder = new OptionsBuilder(); |
|
| 59 | + $notificationBuilder = new PayloadNotificationBuilder($title); |
|
| 60 | + $dataBuilder = new PayloadDataBuilder(); |
|
| 61 | 61 | |
| 62 | - $optionBuilder->setTimeToLive(60 * 20); |
|
| 63 | - $notificationBuilder->setBody($message); |
|
| 64 | - $dataBuilder->addData($data); |
|
| 62 | + $optionBuilder->setTimeToLive(60 * 20); |
|
| 63 | + $notificationBuilder->setBody($message); |
|
| 64 | + $dataBuilder->addData($data); |
|
| 65 | 65 | |
| 66 | - $options = $optionBuilder->build(); |
|
| 67 | - $notification = $notificationBuilder->build(); |
|
| 68 | - $data = $dataBuilder->build(); |
|
| 66 | + $options = $optionBuilder->build(); |
|
| 67 | + $notification = $notificationBuilder->build(); |
|
| 68 | + $data = $dataBuilder->build(); |
|
| 69 | 69 | |
| 70 | - return compact('options', 'notification', 'data'); |
|
| 71 | - } |
|
| 70 | + return compact('options', 'notification', 'data'); |
|
| 71 | + } |
|
| 72 | 72 | } |