@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | use App\User; |
| 4 | 4 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 5 | -use Illuminate\Notifications\Notifiable; |
|
| 6 | 5 | use Laravel\Passport\HasApiTokens; |
| 7 | 6 | |
| 8 | 7 | class AclUser extends User { |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Get the profile picture url. |
|
| 35 | - * @return string |
|
| 36 | - */ |
|
| 33 | + /** |
|
| 34 | + * Get the profile picture url. |
|
| 35 | + * @return string |
|
| 36 | + */ |
|
| 37 | 37 | public function getProfilePictureAttribute($value) |
| 38 | 38 | { |
| 39 | 39 | return url(\Storage::url($value)); |
@@ -89,24 +89,24 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return array |
| 91 | 91 | */ |
| 92 | - public function routeNotificationForFCM() |
|
| 93 | - { |
|
| 94 | - $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
| 95 | - $tokens = []; |
|
| 96 | - |
|
| 97 | - foreach ($devices as $device) |
|
| 98 | - { |
|
| 99 | - if (\Core::users()->accessTokenExpiredOrRevoked($device->access_token)) |
|
| 100 | - { |
|
| 101 | - $device->forceDelete(); |
|
| 102 | - continue; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $tokens[] = $device->device_token; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - return $tokens; |
|
| 109 | - } |
|
| 92 | + public function routeNotificationForFCM() |
|
| 93 | + { |
|
| 94 | + $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
| 95 | + $tokens = []; |
|
| 96 | + |
|
| 97 | + foreach ($devices as $device) |
|
| 98 | + { |
|
| 99 | + if (\Core::users()->accessTokenExpiredOrRevoked($device->access_token)) |
|
| 100 | + { |
|
| 101 | + $device->forceDelete(); |
|
| 102 | + continue; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $tokens[] = $device->device_token; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + return $tokens; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * The channels the user receives notification broadcasts on. |
@@ -151,7 +151,7 @@ |
||
| 151 | 151 | * |
| 152 | 152 | * @param array $credentials |
| 153 | 153 | * @param boolean $skipConfirmEmail |
| 154 | - * @return array |
|
| 154 | + * @return boolean |
|
| 155 | 155 | */ |
| 156 | 156 | public function register($credentials, $skipConfirmEmail = false) |
| 157 | 157 | { |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php namespace App\Modules\Acl\Repositories; |
| 2 | 2 | |
| 3 | 3 | use App\Modules\Core\AbstractRepositories\AbstractRepository; |
| 4 | -use Lcobucci\JWT\ValidationData; |
|
| 5 | 4 | use Illuminate\Support\Arr; |
| 6 | 5 | |
| 7 | 6 | class UserRepository extends AbstractRepository |
@@ -293,14 +293,14 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function confirmEmail($confirmationCode) |
| 295 | 295 | { |
| 296 | - if ( ! $user = $this->first(['confirmation_code' => $confirmationCode])) |
|
| 297 | - { |
|
| 298 | - \ErrorHandler::invalidConfirmationCode(); |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - $user->confirmed = 1; |
|
| 302 | - $user->confirmation_code = null; |
|
| 303 | - $user->save(); |
|
| 296 | + if ( ! $user = $this->first(['confirmation_code' => $confirmationCode])) |
|
| 297 | + { |
|
| 298 | + \ErrorHandler::invalidConfirmationCode(); |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + $user->confirmed = 1; |
|
| 302 | + $user->confirmation_code = null; |
|
| 303 | + $user->save(); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -375,26 +375,26 @@ discard block |
||
| 375 | 375 | $this->save($data); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - /** |
|
| 379 | - * Ensure access token hasn't expired or revoked. |
|
| 380 | - * |
|
| 381 | - * @param string $accessToken |
|
| 382 | - * @return boolean |
|
| 383 | - */ |
|
| 384 | - public function accessTokenExpiredOrRevoked($accessToken) |
|
| 385 | - { |
|
| 386 | - $accessTokenId = json_decode($accessToken, true)['id']; |
|
| 387 | - $accessToken = \DB::table('oauth_access_tokens') |
|
| 388 | - ->where('id', $accessTokenId) |
|
| 389 | - ->first(); |
|
| 378 | + /** |
|
| 379 | + * Ensure access token hasn't expired or revoked. |
|
| 380 | + * |
|
| 381 | + * @param string $accessToken |
|
| 382 | + * @return boolean |
|
| 383 | + */ |
|
| 384 | + public function accessTokenExpiredOrRevoked($accessToken) |
|
| 385 | + { |
|
| 386 | + $accessTokenId = json_decode($accessToken, true)['id']; |
|
| 387 | + $accessToken = \DB::table('oauth_access_tokens') |
|
| 388 | + ->where('id', $accessTokenId) |
|
| 389 | + ->first(); |
|
| 390 | 390 | |
| 391 | - if (\Carbon\Carbon::parse($accessToken->expires_at)->isPast() || $accessToken->revoked) |
|
| 392 | - { |
|
| 393 | - return true; |
|
| 394 | - } |
|
| 391 | + if (\Carbon\Carbon::parse($accessToken->expires_at)->isPast() || $accessToken->revoked) |
|
| 392 | + { |
|
| 393 | + return true; |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - return false; |
|
| 397 | - } |
|
| 396 | + return false; |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | 399 | /** |
| 400 | 400 | * Revoke the given access token and all |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param array $relations |
| 34 | 34 | * @param string $sortBy |
| 35 | - * @param boolean $desc |
|
| 35 | + * @param integer $desc |
|
| 36 | 36 | * @param array $columns |
| 37 | 37 | * @return collection |
| 38 | 38 | */ |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param integer $perPage |
| 51 | 51 | * @param array $relations |
| 52 | 52 | * @param string $sortBy |
| 53 | - * @param boolean $desc |
|
| 53 | + * @param integer $desc |
|
| 54 | 54 | * @param array $columns |
| 55 | 55 | * @return collection |
| 56 | 56 | */ |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param integer $perPage |
| 165 | 165 | * @param array $relations |
| 166 | 166 | * @param string $sortBy |
| 167 | - * @param boolean $desc |
|
| 167 | + * @param integer $desc |
|
| 168 | 168 | * @param array $columns |
| 169 | 169 | * @return collection |
| 170 | 170 | */ |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param integer $perPage |
| 183 | 183 | * @param array $relations |
| 184 | 184 | * @param string $sortBy |
| 185 | - * @param boolean $desc |
|
| 185 | + * @param integer $desc |
|
| 186 | 186 | * @param array $columns |
| 187 | 187 | * @return collection |
| 188 | 188 | */ |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * Save the given model to the storage. |
| 199 | 199 | * |
| 200 | 200 | * @param array $data |
| 201 | - * @return mixed |
|
| 201 | + * @return boolean |
|
| 202 | 202 | */ |
| 203 | 203 | public function save(array $data) |
| 204 | 204 | { |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | * @param array $conditions array of conditions |
| 532 | 532 | * @param array $relations |
| 533 | 533 | * @param string $sortBy |
| 534 | - * @param boolean $desc |
|
| 534 | + * @param integer $desc |
|
| 535 | 535 | * @param array $columns |
| 536 | 536 | * @return collection |
| 537 | 537 | */ |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | * @param array $conditions array of conditions |
| 564 | 564 | * @param integer $perPage |
| 565 | 565 | * @param string $sortBy |
| 566 | - * @param boolean $desc |
|
| 566 | + * @param integer $desc |
|
| 567 | 567 | * @param array $columns |
| 568 | 568 | * @return collection |
| 569 | 569 | */ |
@@ -621,14 +621,12 @@ discard block |
||
| 621 | 621 | $conditions = $this->constructConditions($value, $model); |
| 622 | 622 | $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} '; |
| 623 | 623 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 624 | - } |
|
| 625 | - else if ($key == 'or') |
|
| 624 | + } else if ($key == 'or') |
|
| 626 | 625 | { |
| 627 | 626 | $conditions = $this->constructConditions($value, $model); |
| 628 | 627 | $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} '; |
| 629 | 628 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 630 | - } |
|
| 631 | - else |
|
| 629 | + } else |
|
| 632 | 630 | { |
| 633 | 631 | if (is_array($value)) |
| 634 | 632 | { |
@@ -653,29 +651,24 @@ discard block |
||
| 653 | 651 | |
| 654 | 652 | $conditionString .= $key.' <= ? {op} '; |
| 655 | 653 | $conditionValues[] = $value2; |
| 656 | - } |
|
| 657 | - elseif (strtolower($operator) == 'in') |
|
| 654 | + } elseif (strtolower($operator) == 'in') |
|
| 658 | 655 | { |
| 659 | 656 | $conditionValues = array_merge($conditionValues, $value); |
| 660 | 657 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
| 661 | 658 | $conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} '; |
| 662 | - } |
|
| 663 | - elseif (strtolower($operator) == 'null') |
|
| 659 | + } elseif (strtolower($operator) == 'null') |
|
| 664 | 660 | { |
| 665 | 661 | $conditionString .= $key.' is null {op} '; |
| 666 | - } |
|
| 667 | - elseif (strtolower($operator) == 'not null') |
|
| 662 | + } elseif (strtolower($operator) == 'not null') |
|
| 668 | 663 | { |
| 669 | 664 | $conditionString .= $key.' is not null {op} '; |
| 670 | - } |
|
| 671 | - elseif (strtolower($operator) == 'has') |
|
| 665 | + } elseif (strtolower($operator) == 'has') |
|
| 672 | 666 | { |
| 673 | 667 | $sql = $model->withTrashed()->has($key)->toSql(); |
| 674 | 668 | $conditions = $this->constructConditions($value, $model->$key()->getRelated()); |
| 675 | 669 | $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')').' and '.$conditions['conditionString'].') {op} '; |
| 676 | 670 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 677 | - } |
|
| 678 | - else |
|
| 671 | + } else |
|
| 679 | 672 | { |
| 680 | 673 | $conditionString .= $key.' '.$operator.' ? {op} '; |
| 681 | 674 | $conditionValues[] = $value; |
@@ -217,7 +217,7 @@ |
||
| 217 | 217 | /** |
| 218 | 218 | * Get the given method body code. |
| 219 | 219 | * |
| 220 | - * @param object $reflectionMethod |
|
| 220 | + * @param \ReflectionMethod $reflectionMethod |
|
| 221 | 221 | * @return string |
| 222 | 222 | */ |
| 223 | 223 | protected function getMethodBody($reflectionMethod) |
@@ -174,14 +174,12 @@ |
||
| 174 | 174 | if (strpos($rule, 'unique')) |
| 175 | 175 | { |
| 176 | 176 | $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
| 177 | - } |
|
| 178 | - elseif (strpos($rule, 'exists')) |
|
| 177 | + } elseif (strpos($rule, 'exists')) |
|
| 179 | 178 | { |
| 180 | 179 | $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
| 181 | 180 | } |
| 182 | 181 | } |
| 183 | - } |
|
| 184 | - else |
|
| 182 | + } else |
|
| 185 | 183 | { |
| 186 | 184 | $route['body'] = 'conditions'; |
| 187 | 185 | } |
@@ -227,10 +227,8 @@ |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
| 230 | - {} |
|
| 231 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model.'-'.$permission)) |
|
| 232 | - {} |
|
| 233 | - else |
|
| 230 | + {} elseif ( ! $isPasswordClient && $user->tokenCan($this->model.'-'.$permission)) |
|
| 231 | + {} else |
|
| 234 | 232 | { |
| 235 | 233 | |
| 236 | 234 | \ErrorHandler::noPermissions(); |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | return $next($request); |
| 44 | 44 | }); |
| 45 | 45 | |
| 46 | - $this->setSessions(); |
|
| 47 | - $this->checkPermission($route); |
|
| 48 | - $this->setRelations($route); |
|
| 46 | + $this->setSessions(); |
|
| 47 | + $this->checkPermission($route); |
|
| 48 | + $this->setRelations($route); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $user = \Auth::user(); |
| 222 | 222 | $permission = $permission !== 'index' ? $permission : 'list'; |
| 223 | 223 | $isPasswordClient = $user->token()->client->password_client; |
| 224 | - $this->updateLocaleAndTimezone($user); |
|
| 224 | + $this->updateLocaleAndTimezone($user); |
|
| 225 | 225 | |
| 226 | 226 | if ($user->blocked) |
| 227 | 227 | { |
@@ -287,32 +287,32 @@ discard block |
||
| 287 | 287 | $this->relations = $relations && isset($relations[$route]) ? $relations[$route] : []; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - /** |
|
| 291 | - * Update the logged in user locale and time zone. |
|
| 292 | - * |
|
| 293 | - * @param object $user |
|
| 294 | - * @return void |
|
| 295 | - */ |
|
| 296 | - private function updateLocaleAndTimezone($user) |
|
| 297 | - { |
|
| 298 | - $update = false; |
|
| 299 | - $locale = \Session::get('locale'); |
|
| 300 | - $timezone = \Session::get('time-zone'); |
|
| 301 | - if ($locale && $locale !== 'all' && $locale !== $user->locale) |
|
| 302 | - { |
|
| 303 | - $user->locale = $locale; |
|
| 304 | - $update = true; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - if ($timezone && $timezone !== $user->timezone) |
|
| 308 | - { |
|
| 309 | - $user->timezone = $timezone; |
|
| 310 | - $update = true; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - if ($update) |
|
| 314 | - { |
|
| 315 | - $user->save(); |
|
| 316 | - } |
|
| 317 | - } |
|
| 290 | + /** |
|
| 291 | + * Update the logged in user locale and time zone. |
|
| 292 | + * |
|
| 293 | + * @param object $user |
|
| 294 | + * @return void |
|
| 295 | + */ |
|
| 296 | + private function updateLocaleAndTimezone($user) |
|
| 297 | + { |
|
| 298 | + $update = false; |
|
| 299 | + $locale = \Session::get('locale'); |
|
| 300 | + $timezone = \Session::get('time-zone'); |
|
| 301 | + if ($locale && $locale !== 'all' && $locale !== $user->locale) |
|
| 302 | + { |
|
| 303 | + $user->locale = $locale; |
|
| 304 | + $update = true; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + if ($timezone && $timezone !== $user->timezone) |
|
| 308 | + { |
|
| 309 | + $user->timezone = $timezone; |
|
| 310 | + $update = true; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + if ($update) |
|
| 314 | + { |
|
| 315 | + $user->save(); |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | 318 | } |
@@ -307,7 +307,7 @@ |
||
| 307 | 307 | if ($timezone && $timezone !== $user->timezone) |
| 308 | 308 | { |
| 309 | 309 | $user->timezone = $timezone; |
| 310 | - $update = true; |
|
| 310 | + $update = true; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | if ($update) |
@@ -39,8 +39,7 @@ |
||
| 39 | 39 | if ( ! $report) |
| 40 | 40 | { |
| 41 | 41 | \ErrorHandler::notFound('report'); |
| 42 | - } |
|
| 43 | - else if ( ! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
| 42 | + } else if ( ! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
| 44 | 43 | { |
| 45 | 44 | \ErrorHandler::noPermissions(); |
| 46 | 45 | } |
@@ -13,26 +13,26 @@ discard block |
||
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | 15 | Schema::create('users', function(Blueprint $table) { |
| 16 | - $table->increments('id'); |
|
| 17 | - $table->string('profile_picture', 150)->nullable(); |
|
| 18 | - $table->string('name', 100)->nullable(); |
|
| 19 | - $table->string('email')->unique(); |
|
| 20 | - $table->string('password', 60)->nullable(); |
|
| 21 | - $table->boolean('blocked')->default(0); |
|
| 22 | - $table->boolean('confirmed')->default(0); |
|
| 23 | - $table->string('confirmation_code')->nullable(); |
|
| 24 | - $table->string('locale', 2)->default('en'); |
|
| 25 | - $table->string('timezone', 50)->default('Africa/Cairo'); |
|
| 26 | - $table->softDeletes(); |
|
| 27 | - $table->rememberToken(); |
|
| 28 | - $table->timestamps(); |
|
| 29 | - }); |
|
| 16 | + $table->increments('id'); |
|
| 17 | + $table->string('profile_picture', 150)->nullable(); |
|
| 18 | + $table->string('name', 100)->nullable(); |
|
| 19 | + $table->string('email')->unique(); |
|
| 20 | + $table->string('password', 60)->nullable(); |
|
| 21 | + $table->boolean('blocked')->default(0); |
|
| 22 | + $table->boolean('confirmed')->default(0); |
|
| 23 | + $table->string('confirmation_code')->nullable(); |
|
| 24 | + $table->string('locale', 2)->default('en'); |
|
| 25 | + $table->string('timezone', 50)->default('Africa/Cairo'); |
|
| 26 | + $table->softDeletes(); |
|
| 27 | + $table->rememberToken(); |
|
| 28 | + $table->timestamps(); |
|
| 29 | + }); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Create Default users. |
| 33 | 33 | */ |
| 34 | 34 | \DB::table('users')->insertGetId( |
| 35 | - [ |
|
| 35 | + [ |
|
| 36 | 36 | 'name' => 'Admin', |
| 37 | 37 | 'email' => '[email protected]', |
| 38 | 38 | 'password' => bcrypt('123456'), |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'created_at' => \DB::raw('NOW()'), |
| 41 | 41 | 'updated_at' => \DB::raw('NOW()') |
| 42 | 42 | ] |
| 43 | - ); |
|
| 43 | + ); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -7,10 +7,10 @@ |
||
| 7 | 7 | |
| 8 | 8 | public function saving($model) |
| 9 | 9 | { |
| 10 | - if ($model->isDirty('profile_picture')) |
|
| 11 | - { |
|
| 12 | - \Media::deleteImage($model->getOriginal('profile_picture')); |
|
| 13 | - } |
|
| 10 | + if ($model->isDirty('profile_picture')) |
|
| 11 | + { |
|
| 12 | + \Media::deleteImage($model->getOriginal('profile_picture')); |
|
| 13 | + } |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function saved($model) |
@@ -2,63 +2,63 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Media |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * Upload the given image. |
|
| 7 | - * |
|
| 8 | - * @param object $image |
|
| 9 | - * @param string $dir |
|
| 10 | - * @return string |
|
| 11 | - */ |
|
| 12 | - public function uploadImage($image, $dir) |
|
| 13 | - { |
|
| 14 | - $image = \Image::make($image); |
|
| 15 | - return $this->saveImage($image, $dir); |
|
| 16 | - } |
|
| 5 | + /** |
|
| 6 | + * Upload the given image. |
|
| 7 | + * |
|
| 8 | + * @param object $image |
|
| 9 | + * @param string $dir |
|
| 10 | + * @return string |
|
| 11 | + */ |
|
| 12 | + public function uploadImage($image, $dir) |
|
| 13 | + { |
|
| 14 | + $image = \Image::make($image); |
|
| 15 | + return $this->saveImage($image, $dir); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Upload the given image. |
|
| 20 | - * |
|
| 21 | - * @param object $image |
|
| 22 | - * @param string $dir |
|
| 23 | - * @return string |
|
| 24 | - */ |
|
| 25 | - public function uploadImageBas64($image, $dir) |
|
| 26 | - { |
|
| 27 | - if ( ! strlen($image)) |
|
| 28 | - { |
|
| 29 | - return null; |
|
| 30 | - } |
|
| 18 | + /** |
|
| 19 | + * Upload the given image. |
|
| 20 | + * |
|
| 21 | + * @param object $image |
|
| 22 | + * @param string $dir |
|
| 23 | + * @return string |
|
| 24 | + */ |
|
| 25 | + public function uploadImageBas64($image, $dir) |
|
| 26 | + { |
|
| 27 | + if ( ! strlen($image)) |
|
| 28 | + { |
|
| 29 | + return null; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - $base = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image)); |
|
| 33 | - $image = \Image::make($base); |
|
| 32 | + $base = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image)); |
|
| 33 | + $image = \Image::make($base); |
|
| 34 | 34 | |
| 35 | - return $this->saveImage($image, $dir); |
|
| 36 | - } |
|
| 35 | + return $this->saveImage($image, $dir); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Delete the given image. |
|
| 40 | - * |
|
| 41 | - * @param object $path |
|
| 42 | - * @return void |
|
| 43 | - */ |
|
| 44 | - public function deleteImage($path) |
|
| 45 | - { |
|
| 46 | - \Storage::delete($path); |
|
| 47 | - } |
|
| 38 | + /** |
|
| 39 | + * Delete the given image. |
|
| 40 | + * |
|
| 41 | + * @param object $path |
|
| 42 | + * @return void |
|
| 43 | + */ |
|
| 44 | + public function deleteImage($path) |
|
| 45 | + { |
|
| 46 | + \Storage::delete($path); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Save the given image. |
|
| 51 | - * |
|
| 52 | - * @param object $image |
|
| 53 | - * @param string $dir |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - protected function saveImage($image, $dir) |
|
| 57 | - { |
|
| 58 | - $imageName = 'image'.uniqid().time().'.jpg'; |
|
| 59 | - $path = 'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.$imageName; |
|
| 60 | - \Storage::put($path, $image->stream()); |
|
| 49 | + /** |
|
| 50 | + * Save the given image. |
|
| 51 | + * |
|
| 52 | + * @param object $image |
|
| 53 | + * @param string $dir |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + protected function saveImage($image, $dir) |
|
| 57 | + { |
|
| 58 | + $imageName = 'image'.uniqid().time().'.jpg'; |
|
| 59 | + $path = 'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.$imageName; |
|
| 60 | + \Storage::put($path, $image->stream()); |
|
| 61 | 61 | |
| 62 | - return $path; |
|
| 63 | - } |
|
| 62 | + return $path; |
|
| 63 | + } |
|
| 64 | 64 | } |