@@ -20,8 +20,8 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | protected static function bootEvent() |
| 22 | 22 | { |
| 23 | - static::deleting(function (Customer $model) { |
|
| 24 | - Storage::delete(Customer::IDENTITYCARD_IMAGE_PATH . '/' . $model->getRawOriginal('identitycard_image')); |
|
| 23 | + static::deleting(function(Customer $model) { |
|
| 24 | + Storage::delete(Customer::IDENTITYCARD_IMAGE_PATH.'/'.$model->getRawOriginal('identitycard_image')); |
|
| 25 | 25 | }); |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | return 'email'; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - if (!Validator::make(['phone' => $value], ['phone' => 'phone:ID'])->fails()) { |
|
| 24 | + if (!Validator::make([ 'phone' => $value ], [ 'phone' => 'phone:ID' ])->fails()) { |
|
| 25 | 25 | return 'phone'; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $field = $this->getIdentifierField($value); |
| 40 | 40 | |
| 41 | - $rules = ['required', 'string', 'exists:' . User::class . ',' . $field]; |
|
| 41 | + $rules = [ 'required', 'string', 'exists:'.User::class.','.$field ]; |
|
| 42 | 42 | |
| 43 | 43 | switch ($field) { |
| 44 | 44 | case 'email': |
| 45 | - $rules[] = 'email'; |
|
| 45 | + $rules[ ] = 'email'; |
|
| 46 | 46 | break; |
| 47 | 47 | |
| 48 | 48 | case 'phone': |
| 49 | - $rules[] = 'phone:ID'; |
|
| 49 | + $rules[ ] = 'phone:ID'; |
|
| 50 | 50 | break; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -26,21 +26,21 @@ |
||
| 26 | 26 | public function rules() |
| 27 | 27 | { |
| 28 | 28 | return [ |
| 29 | - 'branch_id' => 'required|exists:' . Branch::class . ',id', |
|
| 30 | - 'username' => 'required|string|max:255|unique:' . User::class, |
|
| 29 | + 'branch_id' => 'required|exists:'.Branch::class.',id', |
|
| 30 | + 'username' => 'required|string|max:255|unique:'.User::class, |
|
| 31 | 31 | 'fullname' => 'required|string|max:255', |
| 32 | - 'gender' => 'sometimes|nullable|enum:' . Gender::class, |
|
| 33 | - 'email' => 'required|string|email|max:255|unique:' . User::class, |
|
| 32 | + 'gender' => 'sometimes|nullable|enum:'.Gender::class, |
|
| 33 | + 'email' => 'required|string|email|max:255|unique:'.User::class, |
|
| 34 | 34 | 'phone_country' => 'sometimes|in:ID', |
| 35 | - 'phone' => ['required', 'string', 'phone:ID', function ($attribute, $phone, $fail) { |
|
| 35 | + 'phone' => [ 'required', 'string', 'phone:ID', function($attribute, $phone, $fail) { |
|
| 36 | 36 | $user = User::where($attribute, PhoneNumber::make($phone, request()->input('phone_country', env('PHONE_COUNTRY', 'ID')))->formatE164())->count(); |
| 37 | 37 | |
| 38 | 38 | if ($user > 0) { |
| 39 | - $fail(trans('validation.unique', ['attribute' => static::getAttributes()[$attribute]])); |
|
| 39 | + $fail(trans('validation.unique', [ 'attribute' => static::getAttributes()[ $attribute ] ])); |
|
| 40 | 40 | } |
| 41 | - }], |
|
| 42 | - 'password' => ['required', 'confirmed', Rules\Password::defaults()], |
|
| 43 | - 'role' => 'required|exists:' . Role::class . ',name', |
|
| 41 | + } ], |
|
| 42 | + 'password' => [ 'required', 'confirmed', Rules\Password::defaults() ], |
|
| 43 | + 'role' => 'required|exists:'.Role::class.',name', |
|
| 44 | 44 | 'is_active' => 'required|boolean', |
| 45 | 45 | ]; |
| 46 | 46 | } |
@@ -27,23 +27,23 @@ |
||
| 27 | 27 | public function rules() |
| 28 | 28 | { |
| 29 | 29 | return [ |
| 30 | - 'branch_id' => 'required|exists:' . Branch::class . ',id', |
|
| 31 | - 'username' => ['required', 'string', 'max:255', Rule::unique(User::class)->ignoreModel($this->route('user'))], |
|
| 30 | + 'branch_id' => 'required|exists:'.Branch::class.',id', |
|
| 31 | + 'username' => [ 'required', 'string', 'max:255', Rule::unique(User::class)->ignoreModel($this->route('user')) ], |
|
| 32 | 32 | 'fullname' => 'required|string|max:255', |
| 33 | - 'gender' => 'sometimes|nullable|enum:' . Gender::class, |
|
| 34 | - 'email' => ['required', 'string', 'email', 'max:255', Rule::unique(User::class)->ignoreModel($this->route('user'))], |
|
| 33 | + 'gender' => 'sometimes|nullable|enum:'.Gender::class, |
|
| 34 | + 'email' => [ 'required', 'string', 'email', 'max:255', Rule::unique(User::class)->ignoreModel($this->route('user')) ], |
|
| 35 | 35 | 'phone_country' => 'sometimes|in:ID', |
| 36 | - 'phone' => ['required', 'string', 'phone:ID', function ($attribute, $phone, $fail) { |
|
| 36 | + 'phone' => [ 'required', 'string', 'phone:ID', function($attribute, $phone, $fail) { |
|
| 37 | 37 | $user = User::where($attribute, PhoneNumber::make($phone, request()->input('phone_country', env('PHONE_COUNTRY', 'ID')))->formatE164()) |
| 38 | 38 | ->where($this->route('user')->getKeyName(), '!=', $this->route('user')->getKey()) |
| 39 | 39 | ->count(); |
| 40 | 40 | |
| 41 | 41 | if ($user > 0) { |
| 42 | - $fail(trans('validation.unique', ['attribute' => static::getAttributes()[$attribute]])); |
|
| 42 | + $fail(trans('validation.unique', [ 'attribute' => static::getAttributes()[ $attribute ] ])); |
|
| 43 | 43 | } |
| 44 | - }], |
|
| 45 | - 'password' => ['sometimes', 'nullable', 'confirmed', Rules\Password::defaults()], |
|
| 46 | - 'role' => 'required|exists:' . Role::class . ',name', |
|
| 44 | + } ], |
|
| 45 | + 'password' => [ 'sometimes', 'nullable', 'confirmed', Rules\Password::defaults() ], |
|
| 46 | + 'role' => 'required|exists:'.Role::class.',name', |
|
| 47 | 47 | 'is_active' => 'required|boolean', |
| 48 | 48 | ]; |
| 49 | 49 | } |
@@ -18,20 +18,20 @@ |
||
| 18 | 18 | public static function getRules() |
| 19 | 19 | { |
| 20 | 20 | return [ |
| 21 | - 'branch_name' => 'required|exists:' . Branch::class . ',name', |
|
| 22 | - 'username' => 'required|string|max:255|unique:' . User::class, |
|
| 21 | + 'branch_name' => 'required|exists:'.Branch::class.',name', |
|
| 22 | + 'username' => 'required|string|max:255|unique:'.User::class, |
|
| 23 | 23 | 'fullname' => 'required|string|max:255', |
| 24 | - 'gender' => 'sometimes|nullable|enum:' . Gender::class, |
|
| 25 | - 'email' => 'required|string|email|max:255|unique:' . User::class, |
|
| 24 | + 'gender' => 'sometimes|nullable|enum:'.Gender::class, |
|
| 25 | + 'email' => 'required|string|email|max:255|unique:'.User::class, |
|
| 26 | 26 | 'phone_country' => 'sometimes|in:ID', |
| 27 | - 'phone' => ['required', 'string', 'phone:ID', function ($attribute, $phone, $fail) { |
|
| 27 | + 'phone' => [ 'required', 'string', 'phone:ID', function($attribute, $phone, $fail) { |
|
| 28 | 28 | $user = User::where('phone', PhoneNumber::make($phone, request()->input('phone_country', env('PHONE_COUNTRY', 'ID')))->formatE164())->count(); |
| 29 | 29 | |
| 30 | 30 | if ($user > 0) { |
| 31 | - $fail(trans('validation.unique', ['attribute' => static::getAttributes()[$attribute]])); |
|
| 31 | + $fail(trans('validation.unique', [ 'attribute' => static::getAttributes()[ $attribute ] ])); |
|
| 32 | 32 | } |
| 33 | - }], |
|
| 34 | - 'password' => ['required', 'confirmed', Rules\Password::defaults()], |
|
| 33 | + } ], |
|
| 34 | + 'password' => [ 'required', 'confirmed', Rules\Password::defaults() ], |
|
| 35 | 35 | 'agree_with_terms' => 'required|boolean|in:1', |
| 36 | 36 | ]; |
| 37 | 37 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | public function rules() |
| 22 | 22 | { |
| 23 | 23 | return [ |
| 24 | - 'name' => 'required|string|max:255|unique:' . Branch::class, |
|
| 24 | + 'name' => 'required|string|max:255|unique:'.Branch::class, |
|
| 25 | 25 | 'address' => 'required|string', |
| 26 | 26 | 'address_latitude' => 'required|numeric', |
| 27 | 27 | 'address_longitude' => 'required|numeric', |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public static function getRules() |
| 17 | 17 | { |
| 18 | - $phoneRule = function () { |
|
| 19 | - return ['required', 'string', 'phone:ID', function ($attribute, $phone, $fail) { |
|
| 18 | + $phoneRule = function() { |
|
| 19 | + return [ 'required', 'string', 'phone:ID', function($attribute, $phone, $fail) { |
|
| 20 | 20 | $country = $attribute === 'phone' |
| 21 | 21 | ? request()->input('phone_country', env('PHONE_COUNTRY', 'ID')) |
| 22 | 22 | : request()->input('whatsapp_phone_country', env('PHONE_COUNTRY', 'ID')); |
@@ -25,22 +25,22 @@ discard block |
||
| 25 | 25 | ->count(); |
| 26 | 26 | |
| 27 | 27 | if ($user > 0) { |
| 28 | - $fail(trans('validation.unique', ['attribute' => static::getAttributes()[$attribute]])); |
|
| 28 | + $fail(trans('validation.unique', [ 'attribute' => static::getAttributes()[ $attribute ] ])); |
|
| 29 | 29 | } |
| 30 | - }]; |
|
| 30 | + } ]; |
|
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | 33 | return [ |
| 34 | 34 | 'username' => 'required|string|max:255', |
| 35 | 35 | 'fullname' => 'required|string|max:255', |
| 36 | - 'gender' => 'sometimes|nullable|enum:' . Gender::class, |
|
| 37 | - 'email' => 'required|string|email|max:255|unique:' . Customer::class, |
|
| 36 | + 'gender' => 'sometimes|nullable|enum:'.Gender::class, |
|
| 37 | + 'email' => 'required|string|email|max:255|unique:'.Customer::class, |
|
| 38 | 38 | 'phone_country' => 'sometimes|in:ID', |
| 39 | 39 | 'phone' => value($phoneRule), |
| 40 | 40 | 'whatsapp_phone_country' => 'sometimes|in:ID', |
| 41 | 41 | 'whatsapp_phone' => value($phoneRule), |
| 42 | - 'account_number' => ['required_without:identitycard_number'] + (request()->filled('account_number') ? ['numeric'] : []), |
|
| 43 | - 'identitycard_number' => ['required_without:account_number'] + (request()->filled('identitycard_number') ? ['numeric'] : []), |
|
| 42 | + 'account_number' => [ 'required_without:identitycard_number' ] + (request()->filled('account_number') ? [ 'numeric' ] : [ ]), |
|
| 43 | + 'identitycard_number' => [ 'required_without:account_number' ] + (request()->filled('identitycard_number') ? [ 'numeric' ] : [ ]), |
|
| 44 | 44 | 'identitycard_image' => 'sometimes|nullable|image', |
| 45 | 45 | 'location_latitude' => 'required|numeric', |
| 46 | 46 | 'location_longitude' => 'required|numeric', |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $file->storeAs( |
| 87 | 87 | Customer::IDENTITYCARD_IMAGE_PATH, |
| 88 | - $filename = (Str::random() . '.' . $file->getClientOriginalExtension()) |
|
| 88 | + $filename = (Str::random().'.'.$file->getClientOriginalExtension()) |
|
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | 91 | return $filename; |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public static function getRules() |
| 19 | 19 | { |
| 20 | - $phoneRule = function () { |
|
| 21 | - return ['required', 'string', 'phone:ID', function ($attribute, $phone, $fail) { |
|
| 20 | + $phoneRule = function() { |
|
| 21 | + return [ 'required', 'string', 'phone:ID', function($attribute, $phone, $fail) { |
|
| 22 | 22 | $country = $attribute === 'phone' |
| 23 | 23 | ? request()->input('phone_country', env('PHONE_COUNTRY', 'ID')) |
| 24 | 24 | : request()->input('whatsapp_phone_country', env('PHONE_COUNTRY', 'ID')); |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | ->count(); |
| 29 | 29 | |
| 30 | 30 | if ($user > 0) { |
| 31 | - $fail(trans('validation.unique', ['attribute' => static::getAttributes()[$attribute]])); |
|
| 31 | + $fail(trans('validation.unique', [ 'attribute' => static::getAttributes()[ $attribute ] ])); |
|
| 32 | 32 | } |
| 33 | - }]; |
|
| 33 | + } ]; |
|
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | 36 | return [ |
| 37 | 37 | 'username' => 'required|string|max:255', |
| 38 | 38 | 'fullname' => 'required|string|max:255', |
| 39 | - 'gender' => 'sometimes|nullable|enum:' . Gender::class, |
|
| 40 | - 'email' => ['required', 'string', 'email', 'max:255', function ($attribute, $email, $fail) { |
|
| 39 | + 'gender' => 'sometimes|nullable|enum:'.Gender::class, |
|
| 40 | + 'email' => [ 'required', 'string', 'email', 'max:255', function($attribute, $email, $fail) { |
|
| 41 | 41 | $validator = Validator::make(compact('email'), [ |
| 42 | 42 | $attribute => Rule::unique(Customer::class)->ignore($email, $attribute), |
| 43 | 43 | ]); |
@@ -45,13 +45,13 @@ discard block |
||
| 45 | 45 | if ($validator->fails()) { |
| 46 | 46 | $fail(trans('validation.unique', compact('attribute'))); |
| 47 | 47 | } |
| 48 | - }], |
|
| 48 | + } ], |
|
| 49 | 49 | 'phone_country' => 'sometimes|in:ID', |
| 50 | 50 | 'phone' => value($phoneRule), |
| 51 | 51 | 'whatsapp_phone_country' => 'sometimes|in:ID', |
| 52 | 52 | 'whatsapp_phone' => value($phoneRule), |
| 53 | - 'account_number' => ['required_without:identitycard_number'] + (request()->filled('account_number') ? ['numeric'] : []), |
|
| 54 | - 'identitycard_number' => ['required_without:account_number'] + (request()->filled('identitycard_number') ? ['numeric'] : []), |
|
| 53 | + 'account_number' => [ 'required_without:identitycard_number' ] + (request()->filled('account_number') ? [ 'numeric' ] : [ ]), |
|
| 54 | + 'identitycard_number' => [ 'required_without:account_number' ] + (request()->filled('identitycard_number') ? [ 'numeric' ] : [ ]), |
|
| 55 | 55 | 'identitycard_image' => 'sometimes|nullable|image', |
| 56 | 56 | 'location_latitude' => 'required|numeric', |
| 57 | 57 | 'location_longitude' => 'required|numeric', |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | $model = $this->route('customer'); |
| 97 | 97 | |
| 98 | 98 | if ($model->getRawOriginal('identitycard_image') && $this->hasFile($key)) { |
| 99 | - Storage::delete(Customer::IDENTITYCARD_IMAGE_PATH . '/' . $model->getRawOriginal('identitycard_image')); |
|
| 99 | + Storage::delete(Customer::IDENTITYCARD_IMAGE_PATH.'/'.$model->getRawOriginal('identitycard_image')); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $file = $this->file($key); |
| 103 | 103 | |
| 104 | 104 | $file->storeAs( |
| 105 | 105 | Customer::IDENTITYCARD_IMAGE_PATH, |
| 106 | - $filename = ($this->input('value') . '.' . $file->getClientOriginalExtension()) |
|
| 106 | + $filename = ($this->input('value').'.'.$file->getClientOriginalExtension()) |
|
| 107 | 107 | ); |
| 108 | 108 | |
| 109 | 109 | return $filename; |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | public function rules() |
| 23 | 23 | { |
| 24 | 24 | return [ |
| 25 | - 'key' => 'required|string|max:255|unique:' . Configuration::class, |
|
| 25 | + 'key' => 'required|string|max:255|unique:'.Configuration::class, |
|
| 26 | 26 | 'value' => 'required|string|max:255', |
| 27 | 27 | 'description' => 'sometimes|nullable|string', |
| 28 | 28 | ]; |