@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function unverified() |
| 49 | 49 | { |
| 50 | - return $this->state(function (array $attributes) { |
|
| 50 | + return $this->state(function(array $attributes) { |
|
| 51 | 51 | return [ |
| 52 | 52 | 'email_verified_at' => null, |
| 53 | 53 | ]; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function unactivate() |
| 63 | 63 | { |
| 64 | - return $this->state(function (array $attributes) { |
|
| 64 | + return $this->state(function(array $attributes) { |
|
| 65 | 65 | return [ |
| 66 | 66 | 'is_active' => false, |
| 67 | 67 | ]; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function activate() |
| 77 | 77 | { |
| 78 | - return $this->state(function (array $attributes) { |
|
| 78 | + return $this->state(function(array $attributes) { |
|
| 79 | 79 | return [ |
| 80 | 80 | 'is_active' => true, |
| 81 | 81 | ]; |
@@ -23,41 +23,41 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | Route::view('/', 'welcome'); |
| 25 | 25 | |
| 26 | -Route::middleware('auth:web', 'verified', 'user_is_active')->name('admin.')->group(function () { |
|
| 26 | +Route::middleware('auth:web', 'verified', 'user_is_active')->name('admin.')->group(function() { |
|
| 27 | 27 | Route::get('/dashboard', DashboardController::class)->name('dashboard'); |
| 28 | 28 | |
| 29 | - Route::prefix('/order')->name('order.')->group(function () { |
|
| 30 | - Route::post('/datatable', [OrderController::class, 'datatable'])->name('datatable'); |
|
| 29 | + Route::prefix('/order')->name('order.')->group(function() { |
|
| 30 | + Route::post('/datatable', [ OrderController::class, 'datatable' ])->name('datatable'); |
|
| 31 | 31 | }); |
| 32 | 32 | |
| 33 | - Route::prefix('/user')->name('user.')->group(function () { |
|
| 34 | - Route::post('/datatable', [UserController::class, 'datatable'])->name('datatable'); |
|
| 35 | - Route::delete('/multiple', [UserController::class, 'destroyMultiple'])->name('destroy-multiple'); |
|
| 33 | + Route::prefix('/user')->name('user.')->group(function() { |
|
| 34 | + Route::post('/datatable', [ UserController::class, 'datatable' ])->name('datatable'); |
|
| 35 | + Route::delete('/multiple', [ UserController::class, 'destroyMultiple' ])->name('destroy-multiple'); |
|
| 36 | 36 | }); |
| 37 | 37 | |
| 38 | - Route::prefix('/branch')->name('branch.')->group(function () { |
|
| 39 | - Route::post('/datatable', [BranchController::class, 'datatable'])->name('datatable'); |
|
| 40 | - Route::delete('/multiple', [BranchController::class, 'destroyMultiple'])->name('destroy-multiple'); |
|
| 38 | + Route::prefix('/branch')->name('branch.')->group(function() { |
|
| 39 | + Route::post('/datatable', [ BranchController::class, 'datatable' ])->name('datatable'); |
|
| 40 | + Route::delete('/multiple', [ BranchController::class, 'destroyMultiple' ])->name('destroy-multiple'); |
|
| 41 | 41 | }); |
| 42 | 42 | |
| 43 | - Route::prefix('/customer')->name('customer.')->group(function () { |
|
| 44 | - Route::post('/datatable', [CustomerController::class, 'datatable'])->name('datatable'); |
|
| 43 | + Route::prefix('/customer')->name('customer.')->group(function() { |
|
| 44 | + Route::post('/datatable', [ CustomerController::class, 'datatable' ])->name('datatable'); |
|
| 45 | 45 | }); |
| 46 | 46 | |
| 47 | - Route::prefix('/denomination')->name('denomination.')->group(function () { |
|
| 48 | - Route::post('/datatable', [DenominationController::class, 'datatable'])->name('datatable'); |
|
| 49 | - Route::delete('/multiple', [DenominationController::class, 'destroyMultiple'])->name('destroy-multiple'); |
|
| 50 | - Route::delete('/{denomination}/image', [DenominationController::class, 'destroyImage'])->name('destroy-image'); |
|
| 47 | + Route::prefix('/denomination')->name('denomination.')->group(function() { |
|
| 48 | + Route::post('/datatable', [ DenominationController::class, 'datatable' ])->name('datatable'); |
|
| 49 | + Route::delete('/multiple', [ DenominationController::class, 'destroyMultiple' ])->name('destroy-multiple'); |
|
| 50 | + Route::delete('/{denomination}/image', [ DenominationController::class, 'destroyImage' ])->name('destroy-image'); |
|
| 51 | 51 | }); |
| 52 | 52 | |
| 53 | - Route::prefix('/role')->name('role.')->middleware('role:admin')->group(function () { |
|
| 54 | - Route::post('/datatable', [RoleController::class, 'datatable'])->name('datatable'); |
|
| 55 | - Route::delete('/multiple', [RoleController::class, 'destroyMultiple'])->name('destroy-multiple'); |
|
| 53 | + Route::prefix('/role')->name('role.')->middleware('role:admin')->group(function() { |
|
| 54 | + Route::post('/datatable', [ RoleController::class, 'datatable' ])->name('datatable'); |
|
| 55 | + Route::delete('/multiple', [ RoleController::class, 'destroyMultiple' ])->name('destroy-multiple'); |
|
| 56 | 56 | }); |
| 57 | 57 | |
| 58 | - Route::prefix('/configuration')->name('configuration.')->group(function () { |
|
| 59 | - Route::post('/datatable', [ConfigurationController::class, 'datatable'])->name('datatable'); |
|
| 60 | - Route::delete('/multiple', [ConfigurationController::class, 'destroyMultiple'])->middleware('role:admin')->name('destroy-multiple'); |
|
| 58 | + Route::prefix('/configuration')->name('configuration.')->group(function() { |
|
| 59 | + Route::post('/datatable', [ ConfigurationController::class, 'datatable' ])->name('datatable'); |
|
| 60 | + Route::delete('/multiple', [ ConfigurationController::class, 'destroyMultiple' ])->middleware('role:admin')->name('destroy-multiple'); |
|
| 61 | 61 | }); |
| 62 | 62 | |
| 63 | 63 | Route::resource('/order', OrderController::class)->except('show'); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | Route::resource('/branch', BranchController::class)->except('show'); |
| 66 | 66 | Route::resource('/customer', CustomerController::class)->except('create', 'store', 'show'); |
| 67 | 67 | Route::resource('/denomination', DenominationController::class)->except('show'); |
| 68 | - Route::resource('/role', RoleController::class, ['middleware' => 'role:admin'])->except('show'); |
|
| 68 | + Route::resource('/role', RoleController::class, [ 'middleware' => 'role:admin' ])->except('show'); |
|
| 69 | 69 | Route::resource('/configuration', ConfigurationController::class)->except('show'); |
| 70 | 70 | }); |
| 71 | 71 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | protected static function bootEvent() |
| 21 | 21 | { |
| 22 | - static::deleting(function (User $model) { |
|
| 22 | + static::deleting(function(User $model) { |
|
| 23 | 23 | $model->roles->map->delete(); |
| 24 | 24 | }); |
| 25 | 25 | } |
@@ -43,24 +43,3 @@ |
||
| 43 | 43 | { |
| 44 | 44 | if ($this->is_active) { |
| 45 | 45 | return sprintf(<<<'html' |
| 46 | - <div class="badge badge-success">%s</div> |
|
| 47 | - html, trans('Active')); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - return sprintf(<<<'html' |
|
| 51 | - <div class="badge badge-danger">%s</div> |
|
| 52 | - html, trans('Not Active')); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Return "role" attribute value. |
|
| 57 | - * |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - public function getRoleAttribute(): string |
|
| 61 | - { |
|
| 62 | - $this->load('roles:id,name'); |
|
| 63 | - |
|
| 64 | - return $this->roles->first()->name; |
|
| 65 | - } |
|
| 66 | -} |
|
@@ -43,24 +43,3 @@ |
||
| 43 | 43 | { |
| 44 | 44 | if ($this->is_active) { |
| 45 | 45 | return sprintf(<<<'html' |
| 46 | - <div class="badge badge-success">%s</div> |
|
| 47 | - html, trans('Active')); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - return sprintf(<<<'html' |
|
| 51 | - <div class="badge badge-danger">%s</div> |
|
| 52 | - html, trans('Not Active')); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Return "role" attribute value. |
|
| 57 | - * |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - public function getRoleAttribute(): string |
|
| 61 | - { |
|
| 62 | - $this->load('roles:id,name'); |
|
| 63 | - |
|
| 64 | - return $this->roles->first()->name; |
|
| 65 | - } |
|
| 66 | -} |
|
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function setPasswordAttribute($value) |
| 31 | 31 | { |
| 32 | - $this->attributes['password'] = Hash::make($value); |
|
| 32 | + $this->attributes[ 'password' ] = Hash::make($value); |
|
| 33 | 33 | |
| 34 | 34 | return $this; |
| 35 | 35 | } |
@@ -43,24 +43,3 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | if ($this->is_active) { |
| 45 | 45 | return sprintf(<<<'html' |
| 46 | - <div class="badge badge-success">%s</div> |
|
| 47 | - html, trans('Active')); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - return sprintf(<<<'html' |
|
| 51 | - <div class="badge badge-danger">%s</div> |
|
| 52 | - html, trans('Not Active')); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Return "role" attribute value. |
|
| 57 | - * |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - public function getRoleAttribute(): string |
|
| 61 | - { |
|
| 62 | - $this->load('roles:id,name'); |
|
| 63 | - |
|
| 64 | - return $this->roles->first()->name; |
|
| 65 | - } |
|
| 66 | -} |
|
@@ -43,24 +43,3 @@ |
||
| 43 | 43 | { |
| 44 | 44 | if ($this->is_active) { |
| 45 | 45 | return sprintf(<<<'html' |
| 46 | - <div class="badge badge-success">%s</div> |
|
| 47 | - html, trans('Active')); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - return sprintf(<<<'html' |
|
| 51 | - <div class="badge badge-danger">%s</div> |
|
| 52 | - html, trans('Not Active')); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Return "role" attribute value. |
|
| 57 | - * |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - public function getRoleAttribute(): string |
|
| 61 | - { |
|
| 62 | - $this->load('roles:id,name'); |
|
| 63 | - |
|
| 64 | - return $this->roles->first()->name; |
|
| 65 | - } |
|
| 66 | -} |
|
@@ -43,24 +43,3 @@ |
||
| 43 | 43 | { |
| 44 | 44 | if ($this->is_active) { |
| 45 | 45 | return sprintf(<<<'html' |
| 46 | - <div class="badge badge-success">%s</div> |
|
| 47 | - html, trans('Active')); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - return sprintf(<<<'html' |
|
| 51 | - <div class="badge badge-danger">%s</div> |
|
| 52 | - html, trans('Not Active')); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Return "role" attribute value. |
|
| 57 | - * |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - public function getRoleAttribute(): string |
|
| 61 | - { |
|
| 62 | - $this->load('roles:id,name'); |
|
| 63 | - |
|
| 64 | - return $this->roles->first()->name; |
|
| 65 | - } |
|
| 66 | -} |
|
@@ -19,11 +19,11 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | protected static function bootEvent() |
| 21 | 21 | { |
| 22 | - static::creating(function (Order $model) { |
|
| 22 | + static::creating(function(Order $model) { |
|
| 23 | 23 | $model->code = $model->generateCode(); |
| 24 | 24 | }); |
| 25 | 25 | |
| 26 | - static::deleting(function (Order $model) { |
|
| 26 | + static::deleting(function(Order $model) { |
|
| 27 | 27 | $model->items->map->delete(); |
| 28 | 28 | }); |
| 29 | 29 | } |
@@ -27,17 +27,17 @@ |
||
| 27 | 27 | 'branch_id' => 'required|exists:branches,id', |
| 28 | 28 | 'username' => 'required|string|max:255|unique:users', |
| 29 | 29 | 'fullname' => 'required|string|max:255', |
| 30 | - 'gender' => 'sometimes|nullable|enum:' . Gender::class, |
|
| 30 | + 'gender' => 'sometimes|nullable|enum:'.Gender::class, |
|
| 31 | 31 | 'email' => 'required|string|email|max:255|unique:users', |
| 32 | 32 | 'phone_country' => 'sometimes|in:ID', |
| 33 | - 'phone' => ['required', 'string', 'phone:ID', function ($attribute, $phone, $fail) { |
|
| 33 | + 'phone' => [ 'required', 'string', 'phone:ID', function($attribute, $phone, $fail) { |
|
| 34 | 34 | $user = User::where('phone', PhoneNumber::make($phone, request()->input('phone_country', env('PHONE_COUNTRY', 'ID')))->formatE164())->count(); |
| 35 | 35 | |
| 36 | 36 | if ($user > 0) { |
| 37 | - $fail(trans('validation.unique', ['attribute' => static::getAttributes()[$attribute]])); |
|
| 37 | + $fail(trans('validation.unique', [ 'attribute' => static::getAttributes()[ $attribute ] ])); |
|
| 38 | 38 | } |
| 39 | - }], |
|
| 40 | - 'password' => ['required', 'confirmed', Rules\Password::defaults()], |
|
| 39 | + } ], |
|
| 40 | + 'password' => [ 'required', 'confirmed', Rules\Password::defaults() ], |
|
| 41 | 41 | 'role' => 'required|exists:roles,name', |
| 42 | 42 | 'is_active' => 'required|boolean', |
| 43 | 43 | ]; |
@@ -26,21 +26,21 @@ |
||
| 26 | 26 | { |
| 27 | 27 | return [ |
| 28 | 28 | 'branch_id' => 'required|exists:branches,id', |
| 29 | - 'username' => ['required', 'string', 'max:255', Rule::unique(User::class)->ignoreModel($this->route('user'))], |
|
| 29 | + 'username' => [ 'required', 'string', 'max:255', Rule::unique(User::class)->ignoreModel($this->route('user')) ], |
|
| 30 | 30 | 'fullname' => 'required|string|max:255', |
| 31 | - 'gender' => 'sometimes|nullable|enum:' . Gender::class, |
|
| 32 | - 'email' => ['required', 'string', 'email', 'max:255', Rule::unique(User::class)->ignoreModel($this->route('user'))], |
|
| 31 | + 'gender' => 'sometimes|nullable|enum:'.Gender::class, |
|
| 32 | + 'email' => [ 'required', 'string', 'email', 'max:255', Rule::unique(User::class)->ignoreModel($this->route('user')) ], |
|
| 33 | 33 | 'phone_country' => 'sometimes|in:ID', |
| 34 | - 'phone' => ['required', 'string', 'phone:ID', function ($attribute, $phone, $fail) { |
|
| 34 | + 'phone' => [ 'required', 'string', 'phone:ID', function($attribute, $phone, $fail) { |
|
| 35 | 35 | $user = User::where('phone', PhoneNumber::make($phone, request()->input('phone_country', env('PHONE_COUNTRY', 'ID')))->formatE164()) |
| 36 | 36 | ->where($this->route('user')->getKeyName(), '!=', $this->route('user')->getKey()) |
| 37 | 37 | ->count(); |
| 38 | 38 | |
| 39 | 39 | if ($user > 0) { |
| 40 | - $fail(trans('validation.unique', ['attribute' => static::getAttributes()[$attribute]])); |
|
| 40 | + $fail(trans('validation.unique', [ 'attribute' => static::getAttributes()[ $attribute ] ])); |
|
| 41 | 41 | } |
| 42 | - }], |
|
| 43 | - 'password' => ['sometimes', 'nullable', 'confirmed', Rules\Password::defaults()], |
|
| 42 | + } ], |
|
| 43 | + 'password' => [ 'sometimes', 'nullable', 'confirmed', Rules\Password::defaults() ], |
|
| 44 | 44 | 'role' => 'required|exists:roles,name', |
| 45 | 45 | 'is_active' => 'required|boolean', |
| 46 | 46 | ]; |
@@ -21,17 +21,17 @@ |
||
| 21 | 21 | 'branch_name' => 'required|exists:branches,name', |
| 22 | 22 | 'username' => 'required|string|max:255|unique:users', |
| 23 | 23 | 'fullname' => 'required|string|max:255', |
| 24 | - 'gender' => 'sometimes|nullable|enum:' . Gender::class, |
|
| 24 | + 'gender' => 'sometimes|nullable|enum:'.Gender::class, |
|
| 25 | 25 | 'email' => 'required|string|email|max:255|unique:users', |
| 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 | } |
@@ -28,25 +28,25 @@ |
||
| 28 | 28 | public function datatable() |
| 29 | 29 | { |
| 30 | 30 | return DataTables::eloquent(Order::query()->with('user:id,fullname')) |
| 31 | - ->setTransformer(fn ($model) => OrderResource::make($model)->resolve()) |
|
| 32 | - ->orderColumn('customer_fullname', function ($query, $direction) { |
|
| 31 | + ->setTransformer(fn($model) => OrderResource::make($model)->resolve()) |
|
| 32 | + ->orderColumn('customer_fullname', function($query, $direction) { |
|
| 33 | 33 | $query->join('customers', 'orders.customer_id', '=', 'customers.id') |
| 34 | 34 | ->select('orders.*', 'customers.id as customer_id', 'customers.fullname as customer_fullname') |
| 35 | 35 | ->orderBy('customers.fullname', $direction); |
| 36 | 36 | }) |
| 37 | - ->filterColumn('customer_fullname', function ($query, $keyword) { |
|
| 38 | - $query->whereHas('customer', function ($query) use ($keyword) { |
|
| 39 | - $query->where('fullname', 'like', '%' . $keyword . '%'); |
|
| 37 | + ->filterColumn('customer_fullname', function($query, $keyword) { |
|
| 38 | + $query->whereHas('customer', function($query) use ($keyword) { |
|
| 39 | + $query->where('fullname', 'like', '%'.$keyword.'%'); |
|
| 40 | 40 | }); |
| 41 | 41 | }) |
| 42 | - ->orderColumn('status', function ($query, $direction) { |
|
| 42 | + ->orderColumn('status', function($query, $direction) { |
|
| 43 | 43 | $query->join('order_statuses', 'order_statuses.order_id', '=', 'orders.id') |
| 44 | 44 | ->select('orders.*', 'order_statuses.id as order_status_id', 'order_statuses.status as order_status') |
| 45 | 45 | ->orderBy('order_statuses.status', $direction); |
| 46 | 46 | }) |
| 47 | - ->filterColumn('status', function ($query, $keyword) { |
|
| 48 | - $query->whereHas('latestStatus', function ($query) use ($keyword) { |
|
| 49 | - $query->where('status', 'like', '%' . $keyword . '%'); |
|
| 47 | + ->filterColumn('status', function($query, $keyword) { |
|
| 48 | + $query->whereHas('latestStatus', function($query) use ($keyword) { |
|
| 49 | + $query->where('status', 'like', '%'.$keyword.'%'); |
|
| 50 | 50 | }); |
| 51 | 51 | }) |
| 52 | 52 | ->toJson(); |