diff --git a/BEST_PRACTICE.md b/BEST_PRACTICE.md new file mode 100644 index 0000000..b29f794 --- /dev/null +++ b/BEST_PRACTICE.md @@ -0,0 +1,15 @@ +# Best Practices + +## PHP + +### Traits +- Gabungkan multiple `use` trait menjadi satu baris dengan koma. +- **Hindari:** + ```php + use FlashesEntityMessage; + use ParsesDataTableQuery; + ``` +- **Gunakan:** + ```php + use FlashesEntityMessage, ParsesDataTableQuery; + ``` diff --git a/app/Http/Controllers/Admin/Finance/CashController.php b/app/Http/Controllers/Admin/Finance/CashController.php index 4d436a1..722320c 100644 --- a/app/Http/Controllers/Admin/Finance/CashController.php +++ b/app/Http/Controllers/Admin/Finance/CashController.php @@ -17,8 +17,7 @@ class CashController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly CashService $cashService, diff --git a/app/Http/Controllers/Admin/Finance/EmployeeAdvanceController.php b/app/Http/Controllers/Admin/Finance/EmployeeAdvanceController.php index d9bb416..9f95b00 100644 --- a/app/Http/Controllers/Admin/Finance/EmployeeAdvanceController.php +++ b/app/Http/Controllers/Admin/Finance/EmployeeAdvanceController.php @@ -17,8 +17,7 @@ class EmployeeAdvanceController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly EmployeeAdvanceService $employeeAdvanceService, diff --git a/app/Http/Controllers/Admin/Finance/ExpenseController.php b/app/Http/Controllers/Admin/Finance/ExpenseController.php index c29103f..14e0aec 100644 --- a/app/Http/Controllers/Admin/Finance/ExpenseController.php +++ b/app/Http/Controllers/Admin/Finance/ExpenseController.php @@ -15,8 +15,7 @@ class ExpenseController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly ExpenseService $expenseService, diff --git a/app/Http/Controllers/Admin/Finance/PayrollPeriodController.php b/app/Http/Controllers/Admin/Finance/PayrollPeriodController.php index 4339452..27d1f85 100644 --- a/app/Http/Controllers/Admin/Finance/PayrollPeriodController.php +++ b/app/Http/Controllers/Admin/Finance/PayrollPeriodController.php @@ -13,8 +13,7 @@ class PayrollPeriodController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly PayrollService $payrollService, diff --git a/app/Http/Controllers/Admin/Hr/EmployeeController.php b/app/Http/Controllers/Admin/Hr/EmployeeController.php index 4f1893b..18ded31 100644 --- a/app/Http/Controllers/Admin/Hr/EmployeeController.php +++ b/app/Http/Controllers/Admin/Hr/EmployeeController.php @@ -18,8 +18,7 @@ class EmployeeController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly EmployeeService $employeeService, diff --git a/app/Http/Controllers/Admin/Hr/LeaveRequestController.php b/app/Http/Controllers/Admin/Hr/LeaveRequestController.php index 5145133..36fa9eb 100644 --- a/app/Http/Controllers/Admin/Hr/LeaveRequestController.php +++ b/app/Http/Controllers/Admin/Hr/LeaveRequestController.php @@ -18,8 +18,7 @@ class LeaveRequestController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly LeaveRequestService $leaveRequestService, diff --git a/app/Http/Controllers/Admin/Manage/CuttingController.php b/app/Http/Controllers/Admin/Manage/CuttingController.php index 2520fe3..ebcd067 100644 --- a/app/Http/Controllers/Admin/Manage/CuttingController.php +++ b/app/Http/Controllers/Admin/Manage/CuttingController.php @@ -17,8 +17,7 @@ class CuttingController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly CuttingService $cuttingService, diff --git a/app/Http/Controllers/Admin/Manage/OrderController.php b/app/Http/Controllers/Admin/Manage/OrderController.php index 00ddb00..1c06c68 100644 --- a/app/Http/Controllers/Admin/Manage/OrderController.php +++ b/app/Http/Controllers/Admin/Manage/OrderController.php @@ -19,8 +19,7 @@ class OrderController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly OrderService $orderService, diff --git a/app/Http/Controllers/Admin/Manage/PurchaseController.php b/app/Http/Controllers/Admin/Manage/PurchaseController.php index d42ea67..b9c2db3 100644 --- a/app/Http/Controllers/Admin/Manage/PurchaseController.php +++ b/app/Http/Controllers/Admin/Manage/PurchaseController.php @@ -15,8 +15,7 @@ class PurchaseController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly PurchaseService $purchaseService, diff --git a/app/Http/Controllers/Admin/Master/CategoryController.php b/app/Http/Controllers/Admin/Master/CategoryController.php index 743eaf9..9d9996b 100644 --- a/app/Http/Controllers/Admin/Master/CategoryController.php +++ b/app/Http/Controllers/Admin/Master/CategoryController.php @@ -15,8 +15,7 @@ class CategoryController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage,ParsesDataTableQuery; public function __construct( private readonly CategoryService $categoryService, diff --git a/app/Http/Controllers/Admin/Master/CustomerController.php b/app/Http/Controllers/Admin/Master/CustomerController.php index 6ad344c..6f61452 100644 --- a/app/Http/Controllers/Admin/Master/CustomerController.php +++ b/app/Http/Controllers/Admin/Master/CustomerController.php @@ -16,8 +16,7 @@ class CustomerController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly CustomerService $customerService, diff --git a/app/Http/Controllers/Admin/Master/ProductController.php b/app/Http/Controllers/Admin/Master/ProductController.php index 1fb8a10..10b366a 100644 --- a/app/Http/Controllers/Admin/Master/ProductController.php +++ b/app/Http/Controllers/Admin/Master/ProductController.php @@ -21,8 +21,7 @@ class ProductController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly CuttingService $cuttingService, diff --git a/app/Http/Controllers/Admin/Master/RawMaterialController.php b/app/Http/Controllers/Admin/Master/RawMaterialController.php index 06e2dc5..6d144f2 100644 --- a/app/Http/Controllers/Admin/Master/RawMaterialController.php +++ b/app/Http/Controllers/Admin/Master/RawMaterialController.php @@ -18,8 +18,7 @@ class RawMaterialController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly RawMaterialService $rawMaterialService, diff --git a/app/Http/Controllers/Admin/Master/SupplierController.php b/app/Http/Controllers/Admin/Master/SupplierController.php index bf2f329..b1eb399 100644 --- a/app/Http/Controllers/Admin/Master/SupplierController.php +++ b/app/Http/Controllers/Admin/Master/SupplierController.php @@ -15,8 +15,7 @@ class SupplierController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly SupplierService $supplierService, diff --git a/app/Http/Controllers/Admin/System/RoleController.php b/app/Http/Controllers/Admin/System/RoleController.php index a9ec1ce..41dd0b5 100644 --- a/app/Http/Controllers/Admin/System/RoleController.php +++ b/app/Http/Controllers/Admin/System/RoleController.php @@ -17,8 +17,7 @@ class RoleController extends Controller { - use FlashesEntityMessage; - use ParsesDataTableQuery; + use FlashesEntityMessage, ParsesDataTableQuery; public function __construct( private readonly RoleService $roleService, diff --git a/app/Models/Attendance.php b/app/Models/Attendance.php index 2c89ca2..990147a 100644 --- a/app/Models/Attendance.php +++ b/app/Models/Attendance.php @@ -26,9 +26,7 @@ ])] class Attendance extends Model implements HasMedia { - use HasFactory; - use HasModuleMedia; - use InteractsWithActivityLog; + use HasFactory, HasModuleMedia, InteractsWithActivityLog; protected function casts(): array { diff --git a/app/Models/CashAccount.php b/app/Models/CashAccount.php index 47e332c..6dd494b 100644 --- a/app/Models/CashAccount.php +++ b/app/Models/CashAccount.php @@ -14,8 +14,7 @@ #[Appends(['balance_formatted'])] class CashAccount extends Model { - use HasFactory; - use InteractsWithActivityLog; + use HasFactory, InteractsWithActivityLog; protected function casts(): array { diff --git a/app/Models/CashTransaction.php b/app/Models/CashTransaction.php index c4af611..778814b 100644 --- a/app/Models/CashTransaction.php +++ b/app/Models/CashTransaction.php @@ -26,10 +26,7 @@ ])] class CashTransaction extends Model implements HasMedia { - use HasFactory; - use HasModuleMedia; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, HasModuleMedia, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/Category.php b/app/Models/Category.php index e20298a..f71eddd 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -14,9 +14,7 @@ #[Sluggable(from: 'name', to: 'slug')] class Category extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; public function products(): BelongsToMany { diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 0d54c95..31593cf 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -12,9 +12,7 @@ #[Guarded(['id'])] class Customer extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; public function orders(): HasMany { diff --git a/app/Models/Cutting.php b/app/Models/Cutting.php index 76e7fa5..832825b 100644 --- a/app/Models/Cutting.php +++ b/app/Models/Cutting.php @@ -21,10 +21,7 @@ ])] class Cutting extends Model { - use HasFactory; - use HasRejection; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, HasRejection, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/CuttingMaterial.php b/app/Models/CuttingMaterial.php index d96c3bb..f168b7f 100644 --- a/app/Models/CuttingMaterial.php +++ b/app/Models/CuttingMaterial.php @@ -26,9 +26,7 @@ ])] class CuttingMaterial extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/CuttingResult.php b/app/Models/CuttingResult.php index c58e5b4..8ad4ad5 100644 --- a/app/Models/CuttingResult.php +++ b/app/Models/CuttingResult.php @@ -12,9 +12,7 @@ #[Guarded(['id'])] class CuttingResult extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/CuttingResultPrice.php b/app/Models/CuttingResultPrice.php index e787926..e62bd05 100644 --- a/app/Models/CuttingResultPrice.php +++ b/app/Models/CuttingResultPrice.php @@ -15,8 +15,7 @@ #[Appends(['price_formatted', 'cost_per_unit_formatted', 'type_label'])] class CuttingResultPrice extends Model { - use HasFactory; - use InteractsWithActivityLog; + use HasFactory, InteractsWithActivityLog; protected function casts(): array { diff --git a/app/Models/Employee.php b/app/Models/Employee.php index 283c81f..497be73 100644 --- a/app/Models/Employee.php +++ b/app/Models/Employee.php @@ -20,9 +20,7 @@ #[Appends(['base_salary_formatted', 'join_date_formatted', 'resign_date_formatted', 'join_date_input', 'employment_status_label'])] class Employee extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/EmployeeAdvance.php b/app/Models/EmployeeAdvance.php index 66c3c53..25c8690 100644 --- a/app/Models/EmployeeAdvance.php +++ b/app/Models/EmployeeAdvance.php @@ -27,9 +27,7 @@ ])] class EmployeeAdvance extends Model { - use HasFactory; - use HasRejection; - use InteractsWithActivityLog; + use HasFactory, HasRejection, InteractsWithActivityLog; protected function casts(): array { diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 55d2fa8..e156cd4 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -17,10 +17,7 @@ #[Appends(['amount_formatted', 'created_at_formatted', 'created_by_name'])] class Expense extends Model implements HasMedia { - use HasFactory; - use HasModuleMedia; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, HasModuleMedia, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/HomepageConfiguration.php b/app/Models/HomepageConfiguration.php index aa1ce3d..5cb0b5a 100644 --- a/app/Models/HomepageConfiguration.php +++ b/app/Models/HomepageConfiguration.php @@ -12,9 +12,7 @@ #[Guarded(['id'])] class HomepageConfiguration extends Model implements HasMedia { - use HasFactory; - use HasModuleMedia; - use InteractsWithActivityLog; + use HasFactory, HasModuleMedia, InteractsWithActivityLog; public static function mediaModuleName(): string { diff --git a/app/Models/LeaveRequest.php b/app/Models/LeaveRequest.php index 9b88083..8c60959 100644 --- a/app/Models/LeaveRequest.php +++ b/app/Models/LeaveRequest.php @@ -27,9 +27,7 @@ ])] class LeaveRequest extends Model { - use HasFactory; - use HasRejection; - use InteractsWithActivityLog; + use HasFactory, HasRejection, InteractsWithActivityLog; protected function casts(): array { diff --git a/app/Models/Order.php b/app/Models/Order.php index 7399e3c..f42c5a5 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -30,9 +30,7 @@ ])] class Order extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/OrderItem.php b/app/Models/OrderItem.php index 99c199f..16e8620 100644 --- a/app/Models/OrderItem.php +++ b/app/Models/OrderItem.php @@ -21,9 +21,7 @@ ])] class OrderItem extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/Payroll.php b/app/Models/Payroll.php index 9aabf20..4a58ddf 100644 --- a/app/Models/Payroll.php +++ b/app/Models/Payroll.php @@ -27,8 +27,7 @@ ])] class Payroll extends Model { - use HasFactory; - use InteractsWithActivityLog; + use HasFactory, InteractsWithActivityLog; protected function casts(): array { diff --git a/app/Models/PayrollAdjustment.php b/app/Models/PayrollAdjustment.php index ab2a2dd..27c8373 100644 --- a/app/Models/PayrollAdjustment.php +++ b/app/Models/PayrollAdjustment.php @@ -15,8 +15,7 @@ #[Appends(['amount_formatted', 'type_label', 'created_at_formatted', 'created_by_name'])] class PayrollAdjustment extends Model { - use HasFactory; - use InteractsWithActivityLog; + use HasFactory, InteractsWithActivityLog; public $timestamps = false; diff --git a/app/Models/PayrollPeriod.php b/app/Models/PayrollPeriod.php index f8da60e..7ee0eb1 100644 --- a/app/Models/PayrollPeriod.php +++ b/app/Models/PayrollPeriod.php @@ -17,8 +17,7 @@ #[Appends(['period_label', 'status_label', 'closed_at_formatted'])] class PayrollPeriod extends Model { - use HasFactory; - use InteractsWithActivityLog; + use HasFactory, InteractsWithActivityLog; protected function casts(): array { diff --git a/app/Models/Product.php b/app/Models/Product.php index c7aec85..aa8b8ea 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -28,10 +28,7 @@ ])] class Product extends Model { - use HasFactory; - use HasRejection; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, HasRejection, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/ProductVariant.php b/app/Models/ProductVariant.php index 1c8e5ce..1b25121 100644 --- a/app/Models/ProductVariant.php +++ b/app/Models/ProductVariant.php @@ -15,10 +15,7 @@ #[Guarded(['id'])] class ProductVariant extends Model implements HasMedia { - use HasFactory; - use HasModuleMedia; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, HasModuleMedia, InteractsWithActivityLog, SoftDeletes; private const MIN_STOCK = 5; diff --git a/app/Models/Purchase.php b/app/Models/Purchase.php index 32d8c68..4d4151e 100644 --- a/app/Models/Purchase.php +++ b/app/Models/Purchase.php @@ -24,10 +24,7 @@ ])] class Purchase extends Model implements HasMedia { - use HasFactory; - use HasModuleMedia; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, HasModuleMedia, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/PurchaseItem.php b/app/Models/PurchaseItem.php index 0ea4320..ea9c0b3 100644 --- a/app/Models/PurchaseItem.php +++ b/app/Models/PurchaseItem.php @@ -21,9 +21,7 @@ ])] class PurchaseItem extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/RawMaterial.php b/app/Models/RawMaterial.php index caff4f1..0fbc0ab 100644 --- a/app/Models/RawMaterial.php +++ b/app/Models/RawMaterial.php @@ -18,9 +18,7 @@ #[Appends(['unit_label', 'unit_abbreviation'])] class RawMaterial extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/RawMaterialPrice.php b/app/Models/RawMaterialPrice.php index d6bf476..d669cac 100644 --- a/app/Models/RawMaterialPrice.php +++ b/app/Models/RawMaterialPrice.php @@ -18,10 +18,7 @@ #[Appends(['price_formatted', 'stock_formatted', 'price_input', 'stock_input'])] class RawMaterialPrice extends Model implements HasMedia { - use HasFactory; - use HasModuleMedia; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, HasModuleMedia, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/app/Models/Rejection.php b/app/Models/Rejection.php index 10a9175..5b7380b 100644 --- a/app/Models/Rejection.php +++ b/app/Models/Rejection.php @@ -12,8 +12,7 @@ #[Guarded(['id'])] class Rejection extends Model { - use HasFactory; - use InteractsWithActivityLog; + use HasFactory, InteractsWithActivityLog; public function rejectable(): MorphTo { diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index a7e50ac..6e3ef48 100644 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -12,9 +12,7 @@ #[Guarded(['id'])] class Supplier extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; public function purchases(): HasMany { diff --git a/app/Models/SystemConfiguration.php b/app/Models/SystemConfiguration.php index 69d79f3..b96dcba 100644 --- a/app/Models/SystemConfiguration.php +++ b/app/Models/SystemConfiguration.php @@ -12,9 +12,7 @@ #[Guarded(['id'])] class SystemConfiguration extends Model implements HasMedia { - use HasFactory; - use HasModuleMedia; - use InteractsWithActivityLog; + use HasFactory, HasModuleMedia, InteractsWithActivityLog; public static function mediaModuleName(): string { diff --git a/app/Models/User.php b/app/Models/User.php index ee89bcf..f541571 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -24,12 +24,7 @@ #[Appends(['role_label'])] class User extends Authenticatable { - use CausesActivity; - use HasFactory; - use HasRoles; - use InteractsWithActivityLog; - use Notifiable; - use SoftDeletes; + use CausesActivity, HasFactory, HasRoles, InteractsWithActivityLog, Notifiable, SoftDeletes; protected function casts(): array { diff --git a/app/Models/UserProfile.php b/app/Models/UserProfile.php index f8ed020..25189e1 100644 --- a/app/Models/UserProfile.php +++ b/app/Models/UserProfile.php @@ -17,9 +17,7 @@ #[Appends(['birth_date_formatted', 'birth_date_input', 'gender_label'])] class UserProfile extends Model { - use HasFactory; - use InteractsWithActivityLog; - use SoftDeletes; + use HasFactory, InteractsWithActivityLog, SoftDeletes; protected function casts(): array { diff --git a/resources/js/pages/admin/master/raw-materials/Index.vue b/resources/js/pages/admin/master/raw-materials/Index.vue index 5a1da6c..4a89a43 100644 --- a/resources/js/pages/admin/master/raw-materials/Index.vue +++ b/resources/js/pages/admin/master/raw-materials/Index.vue @@ -66,7 +66,7 @@ const tablePagination = computed(() => ({ const firstItem = computed(() => props.rawMaterials.data.length > 0 ? (props.rawMaterials.current_page - 1) * props.rawMaterials.per_page + - 1 + 1 : 0, ); @@ -83,21 +83,16 @@ watch(