From 7dca0c9231ed867cfe515e3e8b8dadb7ad181451 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Fri, 3 Oct 2025 09:54:53 +0700 Subject: [PATCH] feat: install and implementasi hash id --- .../Datatable/Studio/Catalog/BottlesTable.php | 8 +- .../Datatable/Studio/Catalog/BrandsTable.php | 14 +- .../Studio/Catalog/CategoriesTable.php | 14 +- .../Studio/Catalog/PerfumesTable.php | 8 +- .../Studio/Catalog/ProductsTable.php | 8 +- .../Studio/Finance/ExpensesTable.php | 6 +- .../Studio/Loyalty/CustomersTable.php | 6 +- .../Datatable/Studio/Loyalty/TiersTable.php | 6 +- .../Studio/Loyalty/VouchersTable.php | 8 +- .../Datatable/Studio/Master/OutletsTable.php | 8 +- .../Datatable/Studio/Master/UsersTable.php | 8 +- app/Livewire/Studio/Catalog/Brand.php | 2 +- app/Livewire/Studio/Catalog/Category.php | 2 +- app/Livewire/Studio/Finance/Expense.php | 2 +- app/Livewire/Studio/Loyalty/Customer.php | 2 +- app/Livewire/Studio/Loyalty/Tier.php | 2 +- app/Models/Bottle.php | 3 +- app/Models/Brand.php | 3 +- app/Models/Category.php | 3 +- app/Models/Customer.php | 3 +- app/Models/Employee.php | 3 +- app/Models/Expense.php | 3 +- app/Models/Facility.php | 3 +- app/Models/Membership.php | 3 + app/Models/OpeningHour.php | 3 +- app/Models/Outlet.php | 3 +- app/Models/Perfume.php | 3 +- app/Models/Product.php | 3 +- app/Models/ReferralCode.php | 3 +- app/Models/ReferralUsage.php | 3 +- app/Models/Tier.php | 3 +- app/Models/User.php | 3 +- app/Models/Voucher.php | 3 +- composer.json | 3 +- composer.lock | 139 +++++++++++++++++- 35 files changed, 227 insertions(+), 70 deletions(-) diff --git a/app/Livewire/Datatable/Studio/Catalog/BottlesTable.php b/app/Livewire/Datatable/Studio/Catalog/BottlesTable.php index ac0f262..d5bc7fc 100644 --- a/app/Livewire/Datatable/Studio/Catalog/BottlesTable.php +++ b/app/Livewire/Datatable/Studio/Catalog/BottlesTable.php @@ -65,15 +65,15 @@ public function columns(): array if (auth()->user()->can('update bottle')) { $actions .= view('components.datatables.edit', [ - 'id' => $row->id, - 'editRoute' => route('studio.catalog.bottle.edit', $row->id), + 'id' => $row->hash, + 'editRoute' => route('studio.catalog.bottle.edit', $row->hash), ])->render(); } if (auth()->user()->can('delete bottle')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.catalog.bottle.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.catalog.bottle.delete', $row->hash), ])->render(); } diff --git a/app/Livewire/Datatable/Studio/Catalog/BrandsTable.php b/app/Livewire/Datatable/Studio/Catalog/BrandsTable.php index 95bcf1f..24b7c87 100644 --- a/app/Livewire/Datatable/Studio/Catalog/BrandsTable.php +++ b/app/Livewire/Datatable/Studio/Catalog/BrandsTable.php @@ -37,7 +37,7 @@ public function columns(): array if (auth()->user()->can('update brand')) { if ($row->sort_order > 1) { $actions .= view('components.datatables.sort-button', [ - 'id' => $row->id, + 'id' => $row->hash, 'module' => 'brand', 'direction' => 'up', 'tooltip' => 'Naik', @@ -46,7 +46,7 @@ public function columns(): array ])->render(); $actions .= view('components.datatables.sort-button', [ - 'id' => $row->id, + 'id' => $row->hash, 'module' => 'brand', 'direction' => 'first', 'tooltip' => 'Pertama', @@ -57,7 +57,7 @@ public function columns(): array if ($row->sort_order < $maxSortOrder) { $actions .= view('components.datatables.sort-button', [ - 'id' => $row->id, + 'id' => $row->hash, 'module' => 'brand', 'direction' => 'down', 'tooltip' => 'Turun', @@ -66,7 +66,7 @@ public function columns(): array ])->render(); $actions .= view('components.datatables.sort-button', [ - 'id' => $row->id, + 'id' => $row->hash, 'module' => 'brand', 'direction' => 'last', 'tooltip' => 'Terakhir', @@ -78,7 +78,7 @@ public function columns(): array if (auth()->user()->can('update brand')) { $actions .= view('components.datatables.edit-modal', [ - 'id' => $row->id, + 'id' => $row->hash, 'method' => 'update', 'modalTitle' => 'Ubah Kategori', ])->render(); @@ -86,8 +86,8 @@ public function columns(): array if (auth()->user()->can('delete brand')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.catalog.brand.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.catalog.brand.delete', $row->hash), ])->render(); } diff --git a/app/Livewire/Datatable/Studio/Catalog/CategoriesTable.php b/app/Livewire/Datatable/Studio/Catalog/CategoriesTable.php index 299e14e..a891a2f 100644 --- a/app/Livewire/Datatable/Studio/Catalog/CategoriesTable.php +++ b/app/Livewire/Datatable/Studio/Catalog/CategoriesTable.php @@ -28,7 +28,7 @@ public function columns(): array if (auth()->user()->can('update category')) { if ($row->sort_order > 1) { $actions .= view('components.datatables.sort-button', [ - 'id' => $row->id, + 'id' => $row->hash, 'module' => 'category', 'direction' => 'up', 'tooltip' => 'Naik', @@ -37,7 +37,7 @@ public function columns(): array ])->render(); $actions .= view('components.datatables.sort-button', [ - 'id' => $row->id, + 'id' => $row->hash, 'module' => 'category', 'direction' => 'first', 'tooltip' => 'Pertama', @@ -48,7 +48,7 @@ public function columns(): array if ($row->sort_order < $maxSortOrder) { $actions .= view('components.datatables.sort-button', [ - 'id' => $row->id, + 'id' => $row->hash, 'module' => 'category', 'direction' => 'down', 'tooltip' => 'Turun', @@ -57,7 +57,7 @@ public function columns(): array ])->render(); $actions .= view('components.datatables.sort-button', [ - 'id' => $row->id, + 'id' => $row->hash, 'module' => 'category', 'direction' => 'last', 'tooltip' => 'Terakhir', @@ -69,7 +69,7 @@ public function columns(): array if (auth()->user()->can('update category')) { $actions .= view('components.datatables.edit-modal', [ - 'id' => $row->id, + 'id' => $row->hash, 'method' => 'update', 'modalTitle' => 'Ubah Kategori', ])->render(); @@ -77,8 +77,8 @@ public function columns(): array if (auth()->user()->can('delete category')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.catalog.category.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.catalog.category.delete', $row->hash), ])->render(); } diff --git a/app/Livewire/Datatable/Studio/Catalog/PerfumesTable.php b/app/Livewire/Datatable/Studio/Catalog/PerfumesTable.php index 60799b6..b35e12f 100644 --- a/app/Livewire/Datatable/Studio/Catalog/PerfumesTable.php +++ b/app/Livewire/Datatable/Studio/Catalog/PerfumesTable.php @@ -74,15 +74,15 @@ public function columns(): array if (auth()->user()->can('update perfume')) { $actions .= view('components.datatables.edit', [ - 'id' => $row->id, - 'editRoute' => route('studio.catalog.perfume.edit', $row->id), + 'id' => $row->hash, + 'editRoute' => route('studio.catalog.perfume.edit', $row->hash), ])->render(); } if (auth()->user()->can('delete perfume')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.catalog.perfume.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.catalog.perfume.delete', $row->hash), ])->render(); } diff --git a/app/Livewire/Datatable/Studio/Catalog/ProductsTable.php b/app/Livewire/Datatable/Studio/Catalog/ProductsTable.php index 0b45d44..6a7ce62 100644 --- a/app/Livewire/Datatable/Studio/Catalog/ProductsTable.php +++ b/app/Livewire/Datatable/Studio/Catalog/ProductsTable.php @@ -57,15 +57,15 @@ public function columns(): array if (auth()->user()->can('update product')) { $actions .= view('components.datatables.edit', [ - 'id' => $row->id, - 'editRoute' => route('studio.catalog.product.edit', $row->id), + 'id' => $row->hash, + 'editRoute' => route('studio.catalog.product.edit', $row->hash), ])->render(); } if (auth()->user()->can('delete product')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.catalog.product.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.catalog.product.delete', $row->hash), ])->render(); } diff --git a/app/Livewire/Datatable/Studio/Finance/ExpensesTable.php b/app/Livewire/Datatable/Studio/Finance/ExpensesTable.php index ab5ef6a..fe0be75 100644 --- a/app/Livewire/Datatable/Studio/Finance/ExpensesTable.php +++ b/app/Livewire/Datatable/Studio/Finance/ExpensesTable.php @@ -31,7 +31,7 @@ public function columns(): array if (auth()->user()->can('update expense')) { $actions .= view('components.datatables.edit-modal', [ - 'id' => $row->id, + 'id' => $row->hash, 'method' => 'update', 'modalTitle' => 'Ubah Kategori', ])->render(); @@ -39,8 +39,8 @@ public function columns(): array if (auth()->user()->can('delete expense')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.finance.expense.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.finance.expense.delete', $row->hash), ])->render(); } diff --git a/app/Livewire/Datatable/Studio/Loyalty/CustomersTable.php b/app/Livewire/Datatable/Studio/Loyalty/CustomersTable.php index 14fe78b..d7b326f 100644 --- a/app/Livewire/Datatable/Studio/Loyalty/CustomersTable.php +++ b/app/Livewire/Datatable/Studio/Loyalty/CustomersTable.php @@ -38,7 +38,7 @@ public function columns(): array if (auth()->user()->can('update customer')) { $actions .= view('components.datatables.edit-modal', [ - 'id' => $row->id, + 'id' => $row->hash, 'method' => 'update', 'modalTitle' => 'Ubah Customer', ])->render(); @@ -46,8 +46,8 @@ public function columns(): array if (auth()->user()->can('delete customer')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.loyalty.customer.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.loyalty.customer.delete', $row->hash), ])->render(); } diff --git a/app/Livewire/Datatable/Studio/Loyalty/TiersTable.php b/app/Livewire/Datatable/Studio/Loyalty/TiersTable.php index b324355..3d99313 100644 --- a/app/Livewire/Datatable/Studio/Loyalty/TiersTable.php +++ b/app/Livewire/Datatable/Studio/Loyalty/TiersTable.php @@ -31,7 +31,7 @@ public function columns(): array if (auth()->user()->can('update tier')) { $actions .= view('components.datatables.edit-modal', [ - 'id' => $row->id, + 'id' => $row->hash, 'method' => 'update', 'modalTitle' => 'Ubah Tier', ])->render(); @@ -39,8 +39,8 @@ public function columns(): array if (auth()->user()->can('delete tier')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.loyalty.tier.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.loyalty.tier.delete', $row->hash), ])->render(); } diff --git a/app/Livewire/Datatable/Studio/Loyalty/VouchersTable.php b/app/Livewire/Datatable/Studio/Loyalty/VouchersTable.php index 03fcd93..67f6e71 100644 --- a/app/Livewire/Datatable/Studio/Loyalty/VouchersTable.php +++ b/app/Livewire/Datatable/Studio/Loyalty/VouchersTable.php @@ -95,15 +95,15 @@ public function columns(): array if (auth()->user()->can('update voucher')) { $actions .= view('components.datatables.edit', [ - 'id' => $row->id, - 'editRoute' => route('studio.loyalty.voucher.edit', $row->id), + 'id' => $row->hash, + 'editRoute' => route('studio.loyalty.voucher.edit', $row->hash), ])->render(); } if (auth()->user()->can('delete voucher')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.loyalty.voucher.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.loyalty.voucher.delete', $row->hash), ])->render(); } diff --git a/app/Livewire/Datatable/Studio/Master/OutletsTable.php b/app/Livewire/Datatable/Studio/Master/OutletsTable.php index ce91791..ca0a3fd 100644 --- a/app/Livewire/Datatable/Studio/Master/OutletsTable.php +++ b/app/Livewire/Datatable/Studio/Master/OutletsTable.php @@ -106,15 +106,15 @@ public function columns(): array if (auth()->user()->can('update outlet')) { $actions .= view('components.datatables.edit', [ - 'id' => $row->id, - 'editRoute' => route('studio.master.outlet.edit', $row->id), + 'id' => $row->hash, + 'editRoute' => route('studio.master.outlet.edit', $row->hash), ])->render(); } if (auth()->user()->can('delete outlet')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.master.outlet.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.master.outlet.delete', $row->hash), ])->render(); } diff --git a/app/Livewire/Datatable/Studio/Master/UsersTable.php b/app/Livewire/Datatable/Studio/Master/UsersTable.php index 3157da9..444c8ea 100644 --- a/app/Livewire/Datatable/Studio/Master/UsersTable.php +++ b/app/Livewire/Datatable/Studio/Master/UsersTable.php @@ -132,15 +132,15 @@ public function columns(): array if (auth()->id() !== $row?->user?->id) { if (auth()->user()->can('update user')) { $actions .= view('components.datatables.edit', [ - 'id' => $row->id, - 'editRoute' => route('studio.master.user.edit', $row->id), + 'id' => $row->hash, + 'editRoute' => route('studio.master.user.edit', $row->hash), ])->render(); } if (auth()->user()->can('delete user')) { $actions .= view('components.datatables.delete', [ - 'id' => $row->id, - 'deleteRoute' => route('studio.master.user.delete', $row->id), + 'id' => $row->hash, + 'deleteRoute' => route('studio.master.user.delete', $row->hash), ])->render(); } } diff --git a/app/Livewire/Studio/Catalog/Brand.php b/app/Livewire/Studio/Catalog/Brand.php index a0c820d..67e1329 100644 --- a/app/Livewire/Studio/Catalog/Brand.php +++ b/app/Livewire/Studio/Catalog/Brand.php @@ -35,7 +35,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null $this->modalTitle = $modalTitle; if ($id) { - $this->form->setBrand(BrandModel::findOrFail($id)); + $this->form->setBrand(BrandModel::byHashOrFail($id)); } } diff --git a/app/Livewire/Studio/Catalog/Category.php b/app/Livewire/Studio/Catalog/Category.php index 799aebe..5b1c8e9 100644 --- a/app/Livewire/Studio/Catalog/Category.php +++ b/app/Livewire/Studio/Catalog/Category.php @@ -35,7 +35,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null $this->modalTitle = $modalTitle; if ($id) { - $this->form->setCategory(CategoryModel::findOrFail($id)); + $this->form->setCategory(CategoryModel::byHashOrFail($id)); } } diff --git a/app/Livewire/Studio/Finance/Expense.php b/app/Livewire/Studio/Finance/Expense.php index 3f3a8e9..4f2c85a 100644 --- a/app/Livewire/Studio/Finance/Expense.php +++ b/app/Livewire/Studio/Finance/Expense.php @@ -35,7 +35,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null $this->modalTitle = $modalTitle; if ($id) { - $this->form->setExpense(ExpenseModel::findOrFail($id)); + $this->form->setExpense(ExpenseModel::byHashOrFail($id)); } } diff --git a/app/Livewire/Studio/Loyalty/Customer.php b/app/Livewire/Studio/Loyalty/Customer.php index 2868fa0..1f74e03 100644 --- a/app/Livewire/Studio/Loyalty/Customer.php +++ b/app/Livewire/Studio/Loyalty/Customer.php @@ -35,7 +35,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null $this->modalTitle = $modalTitle; if ($id) { - $this->form->setCustomer(CustomerModel::findOrFail($id)); + $this->form->setCustomer(CustomerModel::byHashOrFail($id)); } } diff --git a/app/Livewire/Studio/Loyalty/Tier.php b/app/Livewire/Studio/Loyalty/Tier.php index 55ef6ec..f238dd5 100644 --- a/app/Livewire/Studio/Loyalty/Tier.php +++ b/app/Livewire/Studio/Loyalty/Tier.php @@ -35,7 +35,7 @@ public function openModal(string $method, string $modalTitle, ?string $id = null $this->modalTitle = $modalTitle; if ($id) { - $this->form->setTier(TierModel::findOrFail($id)); + $this->form->setTier(TierModel::byHashOrFail($id)); } } diff --git a/app/Models/Bottle.php b/app/Models/Bottle.php index dcefb04..35298ca 100644 --- a/app/Models/Bottle.php +++ b/app/Models/Bottle.php @@ -11,10 +11,11 @@ use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\Sluggable\HasSlug; use Spatie\Sluggable\SlugOptions; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Bottle extends Model implements HasMedia { - use CascadeSoftDeletes, HasFactory, HasSlug, InteractsWithMedia, SoftDeletes; + use CascadeSoftDeletes, HasFactory, HashableId, HasSlug, InteractsWithMedia, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Brand.php b/app/Models/Brand.php index cdce4e9..e9f438b 100644 --- a/app/Models/Brand.php +++ b/app/Models/Brand.php @@ -10,10 +10,11 @@ use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\Sluggable\HasSlug; use Spatie\Sluggable\SlugOptions; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Brand extends Model implements HasMedia { - use HasFactory, HasSlug, InteractsWithMedia, SoftDeletes; + use HasFactory, HashableId, HasSlug, InteractsWithMedia, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Category.php b/app/Models/Category.php index 9ecbe46..15aaed8 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -9,10 +9,11 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Spatie\Sluggable\HasSlug; use Spatie\Sluggable\SlugOptions; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Category extends Model { - use CascadeSoftDeletes, HasFactory, HasSlug, SoftDeletes; + use CascadeSoftDeletes, HasFactory, HashableId, HasSlug, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Customer.php b/app/Models/Customer.php index d2637fe..fb9cefe 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -7,10 +7,11 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Customer extends Model { - use HasFactory, SoftDeletes; + use HasFactory, HashableId, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Employee.php b/app/Models/Employee.php index f000280..0f8b4a0 100644 --- a/app/Models/Employee.php +++ b/app/Models/Employee.php @@ -8,10 +8,11 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Employee extends Model { - use HasFactory, SoftDeletes; + use HasFactory, HashableId, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Expense.php b/app/Models/Expense.php index ace189e..91486b9 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -7,10 +7,11 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Expense extends Model { - use HasFactory, SoftDeletes; + use HasFactory, HashableId, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Facility.php b/app/Models/Facility.php index ea46811..505dc1a 100644 --- a/app/Models/Facility.php +++ b/app/Models/Facility.php @@ -6,10 +6,11 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Facility extends Model { - use HasFactory, SoftDeletes; + use HasFactory, HashableId, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Membership.php b/app/Models/Membership.php index 82821f6..48622f5 100644 --- a/app/Models/Membership.php +++ b/app/Models/Membership.php @@ -4,9 +4,12 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Membership extends Model { + use HashableId; + protected $guarded = ['id']; protected function casts(): array diff --git a/app/Models/OpeningHour.php b/app/Models/OpeningHour.php index d61ad15..b04443d 100644 --- a/app/Models/OpeningHour.php +++ b/app/Models/OpeningHour.php @@ -7,10 +7,11 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; +use Veelasky\LaravelHashId\Eloquent\HashableId; class OpeningHour extends Model { - use HasFactory, SoftDeletes; + use HasFactory, HashableId, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Outlet.php b/app/Models/Outlet.php index 3b30339..0f07fe4 100644 --- a/app/Models/Outlet.php +++ b/app/Models/Outlet.php @@ -13,10 +13,11 @@ use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\Sluggable\HasSlug; use Spatie\Sluggable\SlugOptions; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Outlet extends Model implements HasMedia { - use CascadeSoftDeletes, HasFactory, HasSlug, InteractsWithMedia, SoftDeletes; + use CascadeSoftDeletes, HasFactory, HashableId, HasSlug, InteractsWithMedia, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Perfume.php b/app/Models/Perfume.php index 038fd79..c055e7d 100644 --- a/app/Models/Perfume.php +++ b/app/Models/Perfume.php @@ -12,10 +12,11 @@ use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\Sluggable\HasSlug; use Spatie\Sluggable\SlugOptions; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Perfume extends Model implements HasMedia { - use HasFactory, HasSlug, InteractsWithMedia, SoftDeletes; + use HasFactory, HashableId, HasSlug, InteractsWithMedia, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Product.php b/app/Models/Product.php index 0a47e8d..6175c16 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -10,10 +10,11 @@ use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\Sluggable\HasSlug; use Spatie\Sluggable\SlugOptions; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Product extends Model implements HasMedia { - use HasFactory, HasSlug, InteractsWithMedia, SoftDeletes; + use HasFactory, HashableId, HasSlug, InteractsWithMedia, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/ReferralCode.php b/app/Models/ReferralCode.php index c4b9eca..0c7d9df 100644 --- a/app/Models/ReferralCode.php +++ b/app/Models/ReferralCode.php @@ -7,10 +7,11 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; +use Veelasky\LaravelHashId\Eloquent\HashableId; class ReferralCode extends Model { - use HasFactory, SoftDeletes; + use HasFactory, HashableId, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/ReferralUsage.php b/app/Models/ReferralUsage.php index 23838d7..682dbd6 100644 --- a/app/Models/ReferralUsage.php +++ b/app/Models/ReferralUsage.php @@ -5,10 +5,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Veelasky\LaravelHashId\Eloquent\HashableId; class ReferralUsage extends Model { - use HasFactory; + use HasFactory, HashableId; protected $guarded = ['id']; diff --git a/app/Models/Tier.php b/app/Models/Tier.php index 5934142..cfceab7 100644 --- a/app/Models/Tier.php +++ b/app/Models/Tier.php @@ -7,10 +7,11 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Tier extends Model { - use CascadeSoftDeletes, HasFactory, SoftDeletes; + use CascadeSoftDeletes, HasFactory, HashableId, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/User.php b/app/Models/User.php index 8160070..7d27101 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -14,10 +14,11 @@ use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Spatie\Permission\Traits\HasRoles; +use Veelasky\LaravelHashId\Eloquent\HashableId; class User extends Authenticatable implements MustVerifyEmail { - use CascadeSoftDeletes, HasFactory, HasRoles, Notifiable, SoftDeletes; + use CascadeSoftDeletes, HasFactory, HashableId, HasRoles, Notifiable, SoftDeletes; protected $guarded = ['id']; diff --git a/app/Models/Voucher.php b/app/Models/Voucher.php index 37d7daf..ec59d2f 100644 --- a/app/Models/Voucher.php +++ b/app/Models/Voucher.php @@ -8,10 +8,11 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\SoftDeletes; +use Veelasky\LaravelHashId\Eloquent\HashableId; class Voucher extends Model { - use HasFactory, SoftDeletes; + use HasFactory, HashableId, SoftDeletes; protected $guarded = ['id']; diff --git a/composer.json b/composer.json index bfaa9dd..9a19795 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ "rappasoft/laravel-livewire-tables": "^3.7", "spatie/laravel-medialibrary": "^11.15", "spatie/laravel-permission": "^6.21", - "spatie/laravel-sluggable": "^3.7" + "spatie/laravel-sluggable": "^3.7", + "veelasky/laravel-hashid": "^3.1" }, "repositories": [ { diff --git a/composer.lock b/composer.lock index 98c47bc..8b920f9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bc292bca89df03817c564af417271187", + "content-hash": "d2c5ff203a0e5bd1b8d683556236ad97", "packages": [ { "name": "archtechx/enums", @@ -1677,6 +1677,75 @@ ], "time": "2025-08-22T14:27:06+00:00" }, + { + "name": "hashids/hashids", + "version": "5.0.2", + "source": { + "type": "git", + "url": "https://github.com/vinkla/hashids.git", + "reference": "197171016b77ddf14e259e186559152eb3f8cf33" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vinkla/hashids/zipball/197171016b77ddf14e259e186559152eb3f8cf33", + "reference": "197171016b77ddf14e259e186559152eb3f8cf33", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "suggest": { + "ext-bcmath": "Required to use BC Math arbitrary precision mathematics (*).", + "ext-gmp": "Required to use GNU multiple precision mathematics (*)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Hashids\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ivan Akimov", + "email": "ivan@barreleye.com" + }, + { + "name": "Vincent Klaiber", + "email": "hello@doubledip.se" + } + ], + "description": "Generate short, unique, non-sequential ids (like YouTube and Bitly) from numbers", + "homepage": "https://hashids.org/php", + "keywords": [ + "bitly", + "decode", + "encode", + "hash", + "hashid", + "hashids", + "ids", + "obfuscate", + "youtube" + ], + "support": { + "issues": "https://github.com/vinkla/hashids/issues", + "source": "https://github.com/vinkla/hashids/tree/5.0.2" + }, + "time": "2023-02-23T15:00:54+00:00" + }, { "name": "laravel-lang/config", "version": "1.14.0", @@ -7941,6 +8010,74 @@ }, "time": "2024-12-21T16:25:41+00:00" }, + { + "name": "veelasky/laravel-hashid", + "version": "v3.1.4", + "source": { + "type": "git", + "url": "https://github.com/veelasky/laravel-hashid.git", + "reference": "539597d535b01a8c95c47307ec6267865408eb46" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/veelasky/laravel-hashid/zipball/539597d535b01a8c95c47307ec6267865408eb46", + "reference": "539597d535b01a8c95c47307ec6267865408eb46", + "shasum": "" + }, + "require": { + "hashids/hashids": "^4.0|^5.0", + "illuminate/config": ">=6.18", + "illuminate/contracts": ">=6.18", + "illuminate/database": ">=6.18", + "illuminate/support": ">=6.18", + "illuminate/validation": ">=6.18", + "php": "^8.0" + }, + "require-dev": { + "orchestra/testbench": ">=4.0", + "phpunit/phpunit": ">=8.5", + "roave/security-advisories": "dev-latest" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "HashId": "Veelasky\\LaravelHashId\\Facade" + }, + "providers": [ + "Veelasky\\LaravelHashId\\HashIdServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Veelasky\\LaravelHashId\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rifki Alhuraibi", + "email": "veelasky@pm.com" + } + ], + "description": "HashId Implementation on Laravel Eloquent ORM", + "keywords": [ + "eloquent", + "hashid", + "hashids", + "laravel", + "lumen" + ], + "support": { + "issues": "https://github.com/veelasky/laravel-hashid/issues", + "source": "https://github.com/veelasky/laravel-hashid/tree/v3.1.4" + }, + "time": "2023-10-03T07:32:21+00:00" + }, { "name": "vlucas/phpdotenv", "version": "v5.6.2",