From b5b4e2c97800a7a4d70b56d4a0db7bee088b9d35 Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski Date: Thu, 20 Aug 2026 21:50:34 +0200 Subject: [PATCH] chore(catalog,contacts): remove legacy-era catalog and contacts sources --- .../Http/Controllers/ItemsController.php | 119 -------- .../Http/Controllers/UnitsController.php | 94 ------- .../Http/Requests/DeleteItemsRequest.php | 38 --- .../Catalog/Http/Requests/ItemsRequest.php | 37 --- .../Catalog/Http/Requests/UnitRequest.php | 51 ---- .../Catalog/Http/Resources/ItemResource.php | 47 ---- .../Catalog/Http/Resources/UnitResource.php | 27 -- app/Domains/Catalog/Models/Item.php | 156 ----------- app/Domains/Catalog/Models/Unit.php | 77 ------ app/Domains/Catalog/Policies/ItemPolicy.php | 125 --------- app/Domains/Catalog/Policies/UnitPolicy.php | 112 -------- .../Company/CustomerStatsController.php | 37 --- .../Company/CustomersController.php | 126 --------- .../Http/Controllers/CountriesController.php | 24 -- .../Auth/ForgotPasswordController.php | 56 ---- .../CustomerPortal/Auth/LoginController.php | 45 --- .../Auth/ResetPasswordController.php | 84 ------ .../CustomerPortal/BootstrapController.php | 45 --- .../Middleware/CustomerPortalMiddleware.php | 31 --- .../CustomerPortal/CustomerLoginRequest.php | 33 --- .../CustomerPortal/CustomerProfileRequest.php | 143 ---------- .../Http/Requests/CustomerRequest.php | 200 -------------- .../Http/Requests/DeleteCustomersRequest.php | 33 --- .../Http/Resources/AddressResource.php | 41 --- .../Http/Resources/CountryResource.php | 24 -- .../CustomerPortal/AddressResource.php | 41 --- .../CustomerPortal/CountryResource.php | 24 -- .../CustomerPortal/CustomerResource.php | 55 ---- .../Http/Resources/CustomerResource.php | 66 ----- app/Domains/Contacts/Models/Address.php | 59 ---- app/Domains/Contacts/Models/Country.php | 19 -- app/Domains/Contacts/Models/Customer.php | 257 ------------------ .../CustomerMailResetPasswordNotification.php | 62 ----- .../Contacts/Policies/CustomerPolicy.php | 125 --------- 34 files changed, 2513 deletions(-) delete mode 100644 app/Domains/Catalog/Http/Controllers/ItemsController.php delete mode 100644 app/Domains/Catalog/Http/Controllers/UnitsController.php delete mode 100644 app/Domains/Catalog/Http/Requests/DeleteItemsRequest.php delete mode 100644 app/Domains/Catalog/Http/Requests/ItemsRequest.php delete mode 100644 app/Domains/Catalog/Http/Requests/UnitRequest.php delete mode 100644 app/Domains/Catalog/Http/Resources/ItemResource.php delete mode 100644 app/Domains/Catalog/Http/Resources/UnitResource.php delete mode 100644 app/Domains/Catalog/Models/Item.php delete mode 100644 app/Domains/Catalog/Models/Unit.php delete mode 100644 app/Domains/Catalog/Policies/ItemPolicy.php delete mode 100644 app/Domains/Catalog/Policies/UnitPolicy.php delete mode 100644 app/Domains/Contacts/Http/Controllers/Company/CustomerStatsController.php delete mode 100644 app/Domains/Contacts/Http/Controllers/Company/CustomersController.php delete mode 100644 app/Domains/Contacts/Http/Controllers/CountriesController.php delete mode 100644 app/Domains/Contacts/Http/Controllers/CustomerPortal/Auth/ForgotPasswordController.php delete mode 100644 app/Domains/Contacts/Http/Controllers/CustomerPortal/Auth/LoginController.php delete mode 100644 app/Domains/Contacts/Http/Controllers/CustomerPortal/Auth/ResetPasswordController.php delete mode 100644 app/Domains/Contacts/Http/Controllers/CustomerPortal/BootstrapController.php delete mode 100644 app/Domains/Contacts/Http/Middleware/CustomerPortalMiddleware.php delete mode 100644 app/Domains/Contacts/Http/Requests/CustomerPortal/CustomerLoginRequest.php delete mode 100644 app/Domains/Contacts/Http/Requests/CustomerPortal/CustomerProfileRequest.php delete mode 100644 app/Domains/Contacts/Http/Requests/CustomerRequest.php delete mode 100644 app/Domains/Contacts/Http/Requests/DeleteCustomersRequest.php delete mode 100644 app/Domains/Contacts/Http/Resources/AddressResource.php delete mode 100644 app/Domains/Contacts/Http/Resources/CountryResource.php delete mode 100644 app/Domains/Contacts/Http/Resources/CustomerPortal/AddressResource.php delete mode 100644 app/Domains/Contacts/Http/Resources/CustomerPortal/CountryResource.php delete mode 100644 app/Domains/Contacts/Http/Resources/CustomerPortal/CustomerResource.php delete mode 100644 app/Domains/Contacts/Http/Resources/CustomerResource.php delete mode 100644 app/Domains/Contacts/Models/Address.php delete mode 100644 app/Domains/Contacts/Models/Country.php delete mode 100644 app/Domains/Contacts/Models/Customer.php delete mode 100644 app/Domains/Contacts/Notifications/CustomerMailResetPasswordNotification.php delete mode 100644 app/Domains/Contacts/Policies/CustomerPolicy.php diff --git a/app/Domains/Catalog/Http/Controllers/ItemsController.php b/app/Domains/Catalog/Http/Controllers/ItemsController.php deleted file mode 100644 index 50187f94..00000000 --- a/app/Domains/Catalog/Http/Controllers/ItemsController.php +++ /dev/null @@ -1,119 +0,0 @@ -authorize('viewAny', Item::class); - - $limit = $request->has('limit') ? $request->limit : 10; - - $items = Item::whereCompany() - ->leftJoin('units', 'units.id', '=', 'items.unit_id') - ->applyFilters($request->all()) - ->select('items.*', 'units.name as unit_name') - ->latest() - ->paginateData($limit); - - return ItemResource::collection($items) - ->additional(['meta' => [ - 'tax_types' => TaxType::whereCompany() - ->whereTransactionType(TaxType::TRANSACTION_TYPE_SALES) - ->latest() - ->get(), - 'item_total_count' => Item::whereCompany()->count(), - ]]); - } - - /** - * Create Item. - * - * @return JsonResponse - */ - public function store(ItemsRequest $request) - { - $this->authorize('create', Item::class); - - $item = $this->itemService->create( - $request->validated(), - $request->input('taxes', []), - (int) $request->header('company'), - (int) $request->user()->getAuthIdentifier(), - ); - - return new ItemResource($item); - } - - /** - * get an existing Item. - * - * @return JsonResponse - */ - public function show(Item $item) - { - $this->authorize('view', $item); - - return new ItemResource($item); - } - - /** - * Update an existing Item. - * - * @return JsonResponse - */ - public function update(ItemsRequest $request, Item $item) - { - $this->authorize('update', $item); - - $item = $this->itemService->update( - $item, - $request->validated(), - $request->input('taxes', []), - (int) $request->header('company'), - ); - - return new ItemResource($item); - } - - /** - * Delete a list of existing Items. - * - * @param Request $request - * @return JsonResponse - */ - public function delete(DeleteItemsRequest $request) - { - $this->authorize('delete multiple items'); - - $ids = Item::whereCompany() - ->whereIn('id', $request->ids) - ->pluck('id'); - - Item::destroy($ids); - - return response()->json([ - 'success' => true, - ]); - } -} diff --git a/app/Domains/Catalog/Http/Controllers/UnitsController.php b/app/Domains/Catalog/Http/Controllers/UnitsController.php deleted file mode 100644 index 07df1285..00000000 --- a/app/Domains/Catalog/Http/Controllers/UnitsController.php +++ /dev/null @@ -1,94 +0,0 @@ -authorize('viewAny', Unit::class); - - $limit = $request->has('limit') ? $request->limit : 5; - - $units = Unit::applyFilters($request->all()) - ->whereCompany() - ->latest() - ->paginateData($limit); - - return UnitResource::collection($units); - } - - /** - * Store a newly created resource in storage. - * - * @param Request $request - * @return Response - */ - public function store(UnitRequest $request) - { - $this->authorize('create', Unit::class); - - $unit = Unit::create($request->getUnitPayload()); - - return new UnitResource($unit); - } - - /** - * Display the specified resource. - * - * @return Response - */ - public function show(Unit $unit) - { - $this->authorize('view', $unit); - - return new UnitResource($unit); - } - - /** - * Update the specified resource in storage. - * - * @param Request $request - * @return Response - */ - public function update(UnitRequest $request, Unit $unit) - { - $this->authorize('update', $unit); - - $unit->update($request->getUnitPayload()); - - return new UnitResource($unit); - } - - /** - * Remove the specified resource from storage. - * - * @return Response - */ - public function destroy(Unit $unit) - { - $this->authorize('delete', $unit); - - if ($unit->items()->exists()) { - return respondJson('items_attached', 'Items Attached'); - } - - $unit->delete(); - - return response()->json([ - 'success' => 'Unit deleted successfully', - ]); - } -} diff --git a/app/Domains/Catalog/Http/Requests/DeleteItemsRequest.php b/app/Domains/Catalog/Http/Requests/DeleteItemsRequest.php deleted file mode 100644 index 98ef3ac9..00000000 --- a/app/Domains/Catalog/Http/Requests/DeleteItemsRequest.php +++ /dev/null @@ -1,38 +0,0 @@ - [ - 'required', - ], - 'ids.*' => [ - 'required', - Rule::exists('items', 'id'), - new RelationNotExist(Item::class, 'invoiceItems'), - new RelationNotExist(Item::class, 'estimateItems'), - new RelationNotExist(Item::class, 'taxes'), - ], - ]; - } -} diff --git a/app/Domains/Catalog/Http/Requests/ItemsRequest.php b/app/Domains/Catalog/Http/Requests/ItemsRequest.php deleted file mode 100644 index 46bfa762..00000000 --- a/app/Domains/Catalog/Http/Requests/ItemsRequest.php +++ /dev/null @@ -1,37 +0,0 @@ - [ - 'required', - ], - 'price' => [ - 'required', - ], - 'unit_id' => [ - 'nullable', - ], - 'description' => [ - 'nullable', - ], - ]; - } -} diff --git a/app/Domains/Catalog/Http/Requests/UnitRequest.php b/app/Domains/Catalog/Http/Requests/UnitRequest.php deleted file mode 100644 index 47640309..00000000 --- a/app/Domains/Catalog/Http/Requests/UnitRequest.php +++ /dev/null @@ -1,51 +0,0 @@ - [ - 'required', - Rule::unique('units') - ->where('company_id', $this->header('company')), - ], - ]; - - if ($this->getMethod() == 'PUT') { - $data['name'] = [ - 'required', - Rule::unique('units') - ->ignore($this->route('unit'), 'id') - ->where('company_id', $this->header('company')), - ]; - } - - return $data; - } - - public function getUnitPayload() - { - return collect($this->validated()) - ->merge([ - 'company_id' => $this->header('company'), - ]) - ->toArray(); - } -} diff --git a/app/Domains/Catalog/Http/Resources/ItemResource.php b/app/Domains/Catalog/Http/Resources/ItemResource.php deleted file mode 100644 index 814b3b6c..00000000 --- a/app/Domains/Catalog/Http/Resources/ItemResource.php +++ /dev/null @@ -1,47 +0,0 @@ - $this->id, - 'name' => $this->name, - 'description' => $this->description, - 'price' => $this->price, - 'unit_id' => $this->unit_id, - 'company_id' => $this->company_id, - 'creator_id' => $this->creator_id, - 'currency_id' => $this->currency_id, - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, - 'tax_per_item' => $this->tax_per_item, - 'formatted_created_at' => $this->formattedCreatedAt, - 'unit' => $this->when($this->unit()->exists(), function () { - return new UnitResource($this->unit); - }), - 'company' => $this->when($this->company()->exists(), function () { - return new CompanyResource($this->company); - }), - 'taxes' => $this->when($this->taxes()->exists(), function () { - return TaxResource::collection($this->taxes); - }), - 'currency' => $this->when($this->currency()->exists(), function () { - return new CurrencyResource($this->currency); - }), - ]; - } -} diff --git a/app/Domains/Catalog/Http/Resources/UnitResource.php b/app/Domains/Catalog/Http/Resources/UnitResource.php deleted file mode 100644 index 1c54ffb2..00000000 --- a/app/Domains/Catalog/Http/Resources/UnitResource.php +++ /dev/null @@ -1,27 +0,0 @@ - $this->id, - 'name' => $this->name, - 'company_id' => $this->company_id, - 'company' => $this->when($this->company()->exists(), function () { - return new CompanyResource($this->company); - }), - ]; - } -} diff --git a/app/Domains/Catalog/Models/Item.php b/app/Domains/Catalog/Models/Item.php deleted file mode 100644 index d24c8cc0..00000000 --- a/app/Domains/Catalog/Models/Item.php +++ /dev/null @@ -1,156 +0,0 @@ - 'integer', - ]; - } - - public function unit(): BelongsTo - { - return $this->belongsTo(Unit::class, 'unit_id'); - } - - public function company(): BelongsTo - { - return $this->belongsTo(Company::class); - } - - public function creator(): BelongsTo - { - return $this->belongsTo(User::class, 'creator_id'); - } - - public function currency(): BelongsTo - { - return $this->belongsTo(Currency::class); - } - - public function scopeWhereSearch(Builder $query, string $search): Builder - { - return $query->where('items.name', 'LIKE', '%'.$search.'%'); - } - - public function scopeWherePrice(Builder $query, int $price): Builder - { - return $query->where('items.price', $price); - } - - public function scopeWhereUnit(Builder $query, int $unit_id): Builder - { - return $query->where('items.unit_id', $unit_id); - } - - public function scopeWhereOrder(Builder $query, string $orderByField, string $orderBy): void - { - SafeOrderBy::apply($query, $orderByField, $orderBy); - } - - public function scopeWhereItem(Builder $query, int $item_id): void - { - $query->orWhere('id', $item_id); - } - - /** - * Apply multiple filter conditions including search, price, unit, item, and ordering. - */ - public function scopeApplyFilters(Builder $query, array $filters): void - { - $filters = collect($filters); - - if ($filters->get('search')) { - $query->whereSearch($filters->get('search')); - } - - if ($filters->get('price')) { - $query->wherePrice($filters->get('price')); - } - - if ($filters->get('unit_id')) { - $query->whereUnit($filters->get('unit_id')); - } - - if ($filters->get('item_id')) { - $query->whereItem($filters->get('item_id')); - } - - if ($filters->get('orderByField') || $filters->get('orderBy')) { - $field = $filters->get('orderByField') ? $filters->get('orderByField') : 'name'; - $orderBy = $filters->get('orderBy') ? $filters->get('orderBy') : 'asc'; - $query->whereOrder($field, $orderBy); - } - } - - /** - * @return LengthAwarePaginator|Collection - */ - public function scopePaginateData(Builder $query, string $limit) - { - if ($limit == 'all') { - return $query->get(); - } - - return $query->paginate($limit); - } - - public function getFormattedCreatedAtAttribute(mixed $value): string - { - $dateFormat = CompanySetting::getSetting('carbon_date_format', request()->header('company')); - - return Carbon::parse($this->created_at)->translatedFormat($dateFormat); - } - - public function taxes(): HasMany - { - return $this->hasMany(Tax::class) - ->where('invoice_item_id', null) - ->where('estimate_item_id', null); - } - - public function scopeWhereCompany(Builder $query): void - { - $query->where('items.company_id', request()->header('company')); - } - - public function invoiceItems(): HasMany - { - return $this->hasMany(InvoiceItem::class); - } - - public function estimateItems(): HasMany - { - return $this->hasMany(EstimateItem::class); - } -} diff --git a/app/Domains/Catalog/Models/Unit.php b/app/Domains/Catalog/Models/Unit.php deleted file mode 100644 index 9c748622..00000000 --- a/app/Domains/Catalog/Models/Unit.php +++ /dev/null @@ -1,77 +0,0 @@ -hasMany(Item::class); - } - - public function company(): BelongsTo - { - return $this->belongsTo(Company::class); - } - - public function scopeWhereCompany(Builder $query): void - { - $query->where('company_id', request()->header('company')); - } - - public function scopeWhereUnit(Builder $query, int $unit_id): void - { - $query->orWhere('id', $unit_id); - } - - public function scopeWhereSearch(Builder $query, string $search): Builder - { - return $query->where('name', 'LIKE', '%'.$search.'%'); - } - - public function scopeApplyFilters(Builder $query, array $filters): Builder - { - $filters = collect($filters); - - if ($filters->get('search')) { - $query->whereSearch($filters->get('search')); - } - - if ($filters->get('unit_id')) { - $query->whereUnit($filters->get('unit_id')); - } - - if ($filters->get('company_id')) { - $query->whereCompany($filters->get('company_id')); - } - - return $query; - } - - /** - * @return Collection|LengthAwarePaginator - */ - public function scopePaginateData(Builder $query, string $limit) - { - if ($limit == 'all') { - return $query->get(); - } - - return $query->paginate($limit); - } -} diff --git a/app/Domains/Catalog/Policies/ItemPolicy.php b/app/Domains/Catalog/Policies/ItemPolicy.php deleted file mode 100644 index 680b9ec1..00000000 --- a/app/Domains/Catalog/Policies/ItemPolicy.php +++ /dev/null @@ -1,125 +0,0 @@ -hasCompany($item->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can create models. - * - * @return mixed - */ - public function create(User $user): bool - { - if (BouncerFacade::can('create-item', Item::class)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can update the model. - * - * @return mixed - */ - public function update(User $user, Item $item): bool - { - if (BouncerFacade::can('edit-item', $item) && $user->hasCompany($item->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can delete the model. - * - * @return mixed - */ - public function delete(User $user, Item $item): bool - { - if (BouncerFacade::can('delete-item', $item) && $user->hasCompany($item->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can restore the model. - * - * @return mixed - */ - public function restore(User $user, Item $item): bool - { - if (BouncerFacade::can('delete-item', $item) && $user->hasCompany($item->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can permanently delete the model. - * - * @return mixed - */ - public function forceDelete(User $user, Item $item): bool - { - if (BouncerFacade::can('delete-item', $item) && $user->hasCompany($item->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can delete models. - * - * @return mixed - */ - public function deleteMultiple(User $user) - { - if (BouncerFacade::can('delete-item', Item::class)) { - return true; - } - - return false; - } -} diff --git a/app/Domains/Catalog/Policies/UnitPolicy.php b/app/Domains/Catalog/Policies/UnitPolicy.php deleted file mode 100644 index e79c62c5..00000000 --- a/app/Domains/Catalog/Policies/UnitPolicy.php +++ /dev/null @@ -1,112 +0,0 @@ -hasCompany($unit->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can create models. - * - * @return mixed - */ - public function create(User $user): bool - { - if (BouncerFacade::can('view-item', Item::class)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can update the model. - * - * @return mixed - */ - public function update(User $user, Unit $unit): bool - { - if (BouncerFacade::can('view-item', Item::class) && $user->hasCompany($unit->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can delete the model. - * - * @return mixed - */ - public function delete(User $user, Unit $unit): bool - { - if (BouncerFacade::can('view-item', Item::class) && $user->hasCompany($unit->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can restore the model. - * - * @return mixed - */ - public function restore(User $user, Unit $unit): bool - { - if (BouncerFacade::can('view-item', Item::class) && $user->hasCompany($unit->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can permanently delete the model. - * - * @return mixed - */ - public function forceDelete(User $user, Unit $unit): bool - { - if (BouncerFacade::can('view-item', Item::class) && $user->hasCompany($unit->company_id)) { - return true; - } - - return false; - } -} diff --git a/app/Domains/Contacts/Http/Controllers/Company/CustomerStatsController.php b/app/Domains/Contacts/Http/Controllers/Company/CustomerStatsController.php deleted file mode 100644 index f42a365c..00000000 --- a/app/Domains/Contacts/Http/Controllers/Company/CustomerStatsController.php +++ /dev/null @@ -1,37 +0,0 @@ -authorize('view', $customer); - - $chartData = $this->customerStatsProvider->get( - $customer, - $request->header('company'), - $request->has('previous_year') - ); - - $customer = Customer::find($customer->id); - $this->customerStatementQuery->hydrateAccountSummaries([$customer]); - - return (new CustomerResource($customer)) - ->additional(['meta' => [ - 'chartData' => $chartData, - ]]); - } -} diff --git a/app/Domains/Contacts/Http/Controllers/Company/CustomersController.php b/app/Domains/Contacts/Http/Controllers/Company/CustomersController.php deleted file mode 100644 index 41cf9c00..00000000 --- a/app/Domains/Contacts/Http/Controllers/Company/CustomersController.php +++ /dev/null @@ -1,126 +0,0 @@ -authorize('viewAny', Customer::class); - - $limit = $request->has('limit') ? $request->limit : 10; - - $customers = Customer::with('creator') - ->whereCompany() - ->applyFilters($request->all()) - ->paginateData($limit); - - $this->customerStatementQuery->hydrateAccountSummaries( - $customers instanceof LengthAwarePaginator ? $customers->getCollection() : $customers - ); - - return CustomerResource::collection($customers) - ->additional(['meta' => [ - 'customer_total_count' => Customer::whereCompany()->count(), - ]]); - } - - /** - * Store a newly created resource in storage. - * - * @param Request $request - * @return JsonResponse - */ - public function store(CustomerRequest $request) - { - $this->authorize('create', Customer::class); - - $customer = $this->customerService->create( - attributes: $request->customerAttributes(), - shippingAddress: $request->shippingAddress(), - billingAddress: $request->billingAddress(), - customFields: $request->customFields(), - ); - $this->customerStatementQuery->hydrateAccountSummaries([$customer]); - - return new CustomerResource($customer); - } - - /** - * Display the specified resource. - * - * @return JsonResponse - */ - public function show(Customer $customer) - { - $this->authorize('view', $customer); - - $this->customerStatementQuery->hydrateAccountSummaries([$customer]); - - return new CustomerResource($customer); - } - - /** - * Update the specified resource in storage. - * - * @param Request $request - * @return JsonResponse - */ - public function update(CustomerRequest $request, Customer $customer) - { - $this->authorize('update', $customer); - - $customer = $this->customerService->update( - customer: $customer, - attributes: $request->customerAttributes(), - shippingAddress: $request->shippingAddress(), - billingAddress: $request->billingAddress(), - customFields: $request->customFields(), - ); - $this->customerStatementQuery->hydrateAccountSummaries([$customer]); - - return new CustomerResource($customer); - } - - /** - * Remove a list of Customers along side all their resources (ie. Estimates, Invoices, Payments and Addresses) - * - * @param Request $request - * @return JsonResponse - */ - public function delete(DeleteCustomersRequest $request) - { - $this->authorize('delete multiple customers'); - - $ids = Customer::whereCompany() - ->whereIn('id', $request->ids) - ->pluck('id'); - - $this->customerService->delete($ids); - - return response()->json([ - 'success' => true, - ]); - } -} diff --git a/app/Domains/Contacts/Http/Controllers/CountriesController.php b/app/Domains/Contacts/Http/Controllers/CountriesController.php deleted file mode 100644 index 2d3498fe..00000000 --- a/app/Domains/Contacts/Http/Controllers/CountriesController.php +++ /dev/null @@ -1,24 +0,0 @@ -json([ - 'message' => 'Password reset email sent.', - 'data' => $response, - ]); - } - - /** - * Get the response for a failed password reset link. - * - * @param string $response - * @return RedirectResponse|JsonResponse - */ - protected function sendResetLinkFailedResponse(Request $request, $response) - { - return response('Email could not be sent to this email address.', 403); - } -} diff --git a/app/Domains/Contacts/Http/Controllers/CustomerPortal/Auth/LoginController.php b/app/Domains/Contacts/Http/Controllers/CustomerPortal/Auth/LoginController.php deleted file mode 100644 index f6e00666..00000000 --- a/app/Domains/Contacts/Http/Controllers/CustomerPortal/Auth/LoginController.php +++ /dev/null @@ -1,45 +0,0 @@ -email)]) - ->where('company_id', $company->id) - ->first(); - - if (! $user || ! Hash::check($request->password, $user->password)) { - throw ValidationException::withMessages([ - 'email' => ['The provided credentials are incorrect.'], - ]); - } - - if (! $user->enable_portal) { - throw ValidationException::withMessages([ - 'email' => ['Customer portal not available for this user.'], - ]); - } - - Auth::guard('customer')->login($user); - - return response()->json([ - 'success' => true, - ]); - } -} diff --git a/app/Domains/Contacts/Http/Controllers/CustomerPortal/Auth/ResetPasswordController.php b/app/Domains/Contacts/Http/Controllers/CustomerPortal/Auth/ResetPasswordController.php deleted file mode 100644 index 2c12319a..00000000 --- a/app/Domains/Contacts/Http/Controllers/CustomerPortal/Auth/ResetPasswordController.php +++ /dev/null @@ -1,84 +0,0 @@ -json([ - 'message' => 'Password reset successfully.', - ]); - } - - /** - * Reset the given user's password. - * - * @param CanResetPassword $user - * @param string $password - * @return void - */ - protected function resetPassword($user, $password) - { - $user->password = $password; - - $user->setRememberToken(Str::random(60)); - - $user->save(); - - event(new PasswordReset($user)); - } - - /** - * Get the response for a failed password reset. - * - * @param string $response - * @return RedirectResponse|JsonResponse - */ - protected function sendResetFailedResponse(Request $request, $response) - { - return response('Failed, Invalid Token.', 403); - } -} diff --git a/app/Domains/Contacts/Http/Controllers/CustomerPortal/BootstrapController.php b/app/Domains/Contacts/Http/Controllers/CustomerPortal/BootstrapController.php deleted file mode 100644 index 033fd223..00000000 --- a/app/Domains/Contacts/Http/Controllers/CustomerPortal/BootstrapController.php +++ /dev/null @@ -1,45 +0,0 @@ -user(); - - foreach (\Menu::get('customer_portal_menu')->items->toArray() as $data) { - if ($customer) { - $menu[] = [ - 'title' => $data->title, - 'link' => $data->link->path['url'], - ]; - } - } - - $companyCurrencyId = CompanySetting::getSetting('currency', $customer->company_id); - - return (new CustomerResource($customer)) - ->additional(['meta' => [ - 'menu' => $menu, - 'current_customer_currency' => Currency::find($customer->currency_id), - 'current_company_currency' => $companyCurrencyId ? Currency::find($companyCurrencyId) : null, - 'modules' => Module::where('enabled', true)->pluck('name'), - 'current_company_language' => CompanySetting::getSetting('language', $customer->company_id), - ]]); - } -} diff --git a/app/Domains/Contacts/Http/Middleware/CustomerPortalMiddleware.php b/app/Domains/Contacts/Http/Middleware/CustomerPortalMiddleware.php deleted file mode 100644 index c1e2fb35..00000000 --- a/app/Domains/Contacts/Http/Middleware/CustomerPortalMiddleware.php +++ /dev/null @@ -1,31 +0,0 @@ -user(); - - if (! $user->enable_portal) { - Auth::guard('customer')->logout(); - - return response('Unauthorized.', 401); - } - - return $next($request); - } -} diff --git a/app/Domains/Contacts/Http/Requests/CustomerPortal/CustomerLoginRequest.php b/app/Domains/Contacts/Http/Requests/CustomerPortal/CustomerLoginRequest.php deleted file mode 100644 index 0ba1d830..00000000 --- a/app/Domains/Contacts/Http/Requests/CustomerPortal/CustomerLoginRequest.php +++ /dev/null @@ -1,33 +0,0 @@ - [ - 'required', - 'string', - ], - 'password' => [ - 'required', - 'string', - ], - ]; - } -} diff --git a/app/Domains/Contacts/Http/Requests/CustomerPortal/CustomerProfileRequest.php b/app/Domains/Contacts/Http/Requests/CustomerPortal/CustomerProfileRequest.php deleted file mode 100644 index 3968d71f..00000000 --- a/app/Domains/Contacts/Http/Requests/CustomerPortal/CustomerProfileRequest.php +++ /dev/null @@ -1,143 +0,0 @@ - [ - 'nullable', - ], - 'password' => [ - 'nullable', - 'min:8', - ], - 'email' => [ - 'nullable', - new IdnEmail, - Rule::unique('customers')->where('company_id', $this->header('company'))->ignore(Auth::id(), 'id'), - ], - 'billing.name' => [ - 'nullable', - ], - 'billing.address_street_1' => [ - 'nullable', - ], - 'billing.address_street_2' => [ - 'nullable', - ], - 'billing.city' => [ - 'nullable', - ], - 'billing.state' => [ - 'nullable', - ], - 'billing.country_id' => [ - 'nullable', - ], - 'billing.zip' => [ - 'nullable', - ], - 'billing.phone' => [ - 'nullable', - ], - 'billing.fax' => [ - 'nullable', - ], - 'shipping.name' => [ - 'nullable', - ], - 'shipping.address_street_1' => [ - 'nullable', - ], - 'shipping.address_street_2' => [ - 'nullable', - ], - 'shipping.city' => [ - 'nullable', - ], - 'shipping.state' => [ - 'nullable', - ], - 'shipping.country_id' => [ - 'nullable', - ], - 'shipping.zip' => [ - 'nullable', - ], - 'shipping.phone' => [ - 'nullable', - ], - 'shipping.fax' => [ - 'nullable', - ], - 'customer_avatar' => [ - 'nullable', - 'file', - 'mimes:gif,jpg,png', - 'max:20000', - ], - 'is_customer_avatar_removed' => [ - 'nullable', - 'boolean', - ], - ]; - } - - /** @return array */ - public function customerAttributes(): array - { - return $this->safe()->only(['name', 'email', 'password']); - } - - /** @return array|null */ - public function shippingAddress(): ?array - { - $address = $this->input('shipping'); - - if (! is_array($address)) { - return null; - } - - return collect($address) - ->merge([ - 'type' => Address::SHIPPING_TYPE, - ]) - ->toArray(); - } - - /** @return array|null */ - public function billingAddress(): ?array - { - $address = $this->input('billing'); - - if (! is_array($address)) { - return null; - } - - return collect($address) - ->merge([ - 'type' => Address::BILLING_TYPE, - ]) - ->toArray(); - } -} diff --git a/app/Domains/Contacts/Http/Requests/CustomerRequest.php b/app/Domains/Contacts/Http/Requests/CustomerRequest.php deleted file mode 100644 index 9600e1a0..00000000 --- a/app/Domains/Contacts/Http/Requests/CustomerRequest.php +++ /dev/null @@ -1,200 +0,0 @@ - [ - 'required', - ], - 'email' => [ - new IdnEmail, - 'nullable', - Rule::unique('customers')->where('company_id', $this->header('company')), - ], - 'password' => [ - 'nullable', - ], - 'phone' => [ - 'nullable', - ], - 'company_name' => [ - 'nullable', - ], - 'contact_name' => [ - 'nullable', - ], - 'website' => [ - 'nullable', - ], - 'prefix' => [ - 'nullable', - ], - 'tax_id' => [ - 'nullable', - ], - 'enable_portal' => [ - 'boolean', - ], - 'currency_id' => [ - 'nullable', - ], - 'billing.name' => [ - 'nullable', - ], - 'billing.address_street_1' => [ - 'nullable', - ], - 'billing.address_street_2' => [ - 'nullable', - ], - 'billing.city' => [ - 'nullable', - ], - 'billing.state' => [ - 'nullable', - ], - 'billing.country_id' => [ - 'nullable', - ], - 'billing.zip' => [ - 'nullable', - ], - 'billing.phone' => [ - 'nullable', - ], - 'billing.fax' => [ - 'nullable', - ], - 'shipping.name' => [ - 'nullable', - ], - 'shipping.address_street_1' => [ - 'nullable', - ], - 'shipping.address_street_2' => [ - 'nullable', - ], - 'shipping.city' => [ - 'nullable', - ], - 'shipping.state' => [ - 'nullable', - ], - 'shipping.country_id' => [ - 'nullable', - ], - 'shipping.zip' => [ - 'nullable', - ], - 'shipping.phone' => [ - 'nullable', - ], - 'shipping.fax' => [ - 'nullable', - ], - ]; - - if ($this->isMethod('PUT') && $this->email != null) { - $rules['email'] = [ - new IdnEmail, - 'nullable', - Rule::unique('customers')->where('company_id', $this->header('company'))->ignore($this->route('customer')->id), - ]; - } - - return $rules; - } - - /** @return array */ - public function customerAttributes(): array - { - return collect($this->validated()) - ->only([ - 'name', - 'email', - 'currency_id', - 'password', - 'phone', - 'prefix', - 'tax_id', - 'company_name', - 'contact_name', - 'website', - 'enable_portal', - 'estimate_prefix', - 'payment_prefix', - 'invoice_prefix', - ]) - ->merge([ - 'creator_id' => $this->user()->id, - 'company_id' => $this->header('company'), - ]) - ->toArray(); - } - - /** @return array|null */ - public function shippingAddress(): ?array - { - $address = $this->input('shipping'); - - if (! is_array($address) || ! $this->hasAddress($address)) { - return null; - } - - return collect($address) - ->merge([ - 'type' => Address::SHIPPING_TYPE, - ]) - ->toArray(); - } - - /** @return array|null */ - public function billingAddress(): ?array - { - $address = $this->input('billing'); - - if (! is_array($address) || ! $this->hasAddress($address)) { - return null; - } - - return collect($address) - ->merge([ - 'type' => Address::BILLING_TYPE, - ]) - ->toArray(); - } - - /** @return array|null */ - public function customFields(): ?array - { - $customFields = $this->input('customFields'); - - return is_array($customFields) && $customFields !== [] ? $customFields : null; - } - - private function hasAddress(array $address): bool - { - return Arr::where($address, fn ($value): bool => isset($value)) !== []; - } -} diff --git a/app/Domains/Contacts/Http/Requests/DeleteCustomersRequest.php b/app/Domains/Contacts/Http/Requests/DeleteCustomersRequest.php deleted file mode 100644 index 99352868..00000000 --- a/app/Domains/Contacts/Http/Requests/DeleteCustomersRequest.php +++ /dev/null @@ -1,33 +0,0 @@ - [ - 'required', - ], - 'ids.*' => [ - 'required', - Rule::exists('customers', 'id'), - ], - ]; - } -} diff --git a/app/Domains/Contacts/Http/Resources/AddressResource.php b/app/Domains/Contacts/Http/Resources/AddressResource.php deleted file mode 100644 index bd5a2e96..00000000 --- a/app/Domains/Contacts/Http/Resources/AddressResource.php +++ /dev/null @@ -1,41 +0,0 @@ - $this->id, - 'name' => $this->name, - 'address_street_1' => $this->address_street_1, - 'address_street_2' => $this->address_street_2, - 'city' => $this->city, - 'state' => $this->state, - 'country_id' => $this->country_id, - 'zip' => $this->zip, - 'phone' => $this->phone, - 'fax' => $this->fax, - 'type' => $this->type, - 'user_id' => $this->user_id, - 'company_id' => $this->company_id, - 'customer_id' => $this->customer_id, - 'country' => $this->when($this->country()->exists(), function () { - return new CountryResource($this->country); - }), - 'user' => $this->when($this->user()->exists(), function () { - return new UserResource($this->user); - }), - ]; - } -} diff --git a/app/Domains/Contacts/Http/Resources/CountryResource.php b/app/Domains/Contacts/Http/Resources/CountryResource.php deleted file mode 100644 index 5a1f9550..00000000 --- a/app/Domains/Contacts/Http/Resources/CountryResource.php +++ /dev/null @@ -1,24 +0,0 @@ - $this->id, - 'code' => $this->code, - 'name' => $this->name, - 'phone_code' => $this->phone_code, - ]; - } -} diff --git a/app/Domains/Contacts/Http/Resources/CustomerPortal/AddressResource.php b/app/Domains/Contacts/Http/Resources/CustomerPortal/AddressResource.php deleted file mode 100644 index 50fa5214..00000000 --- a/app/Domains/Contacts/Http/Resources/CustomerPortal/AddressResource.php +++ /dev/null @@ -1,41 +0,0 @@ - $this->id, - 'name' => $this->name, - 'address_street_1' => $this->address_street_1, - 'address_street_2' => $this->address_street_2, - 'city' => $this->city, - 'state' => $this->state, - 'country_id' => $this->country_id, - 'zip' => $this->zip, - 'phone' => $this->phone, - 'fax' => $this->fax, - 'type' => $this->type, - 'user_id' => $this->user_id, - 'company_id' => $this->company_id, - 'customer_id' => $this->customer_id, - 'country' => $this->when($this->country()->exists(), function () { - return new CountryResource($this->country); - }), - 'user' => $this->when($this->user()->exists(), function () { - return new UserResource($this->user); - }), - ]; - } -} diff --git a/app/Domains/Contacts/Http/Resources/CustomerPortal/CountryResource.php b/app/Domains/Contacts/Http/Resources/CustomerPortal/CountryResource.php deleted file mode 100644 index 35ba8d53..00000000 --- a/app/Domains/Contacts/Http/Resources/CustomerPortal/CountryResource.php +++ /dev/null @@ -1,24 +0,0 @@ - $this->id, - 'code' => $this->code, - 'name' => $this->name, - 'phonecode' => $this->phonecode, - ]; - } -} diff --git a/app/Domains/Contacts/Http/Resources/CustomerPortal/CustomerResource.php b/app/Domains/Contacts/Http/Resources/CustomerPortal/CustomerResource.php deleted file mode 100644 index 2e988f4b..00000000 --- a/app/Domains/Contacts/Http/Resources/CustomerPortal/CustomerResource.php +++ /dev/null @@ -1,55 +0,0 @@ - $this->id, - 'name' => $this->name, - 'email' => $this->email, - 'phone' => $this->phone, - 'contact_name' => $this->contact_name, - 'company_name' => $this->company_name, - 'website' => $this->website, - 'enable_portal' => $this->enable_portal, - 'currency_id' => $this->currency_id, - 'company_id' => $this->company_id, - 'facebook_id' => $this->facebook_id, - 'google_id' => $this->google_id, - 'github_id' => $this->github_id, - 'formatted_created_at' => $this->formattedCreatedAt, - 'avatar' => $this->avatar, - 'prefix' => $this->prefix, - 'tax_id' => $this->tax_id, - 'billing' => $this->when($this->billingAddress()->exists(), function () { - return new AddressResource($this->billingAddress); - }), - 'shipping' => $this->when($this->shippingAddress()->exists(), function () { - return new AddressResource($this->shippingAddress); - }), - 'fields' => $this->when($this->fields()->exists(), function () { - return CustomFieldValueResource::collection($this->fields); - }), - 'company' => $this->when($this->company()->exists(), function () { - return new CompanyResource($this->company); - }), - 'currency' => $this->when($this->currency()->exists(), function () { - return new CurrencyResource($this->currency); - }), - ]; - } -} diff --git a/app/Domains/Contacts/Http/Resources/CustomerResource.php b/app/Domains/Contacts/Http/Resources/CustomerResource.php deleted file mode 100644 index ae98f7ca..00000000 --- a/app/Domains/Contacts/Http/Resources/CustomerResource.php +++ /dev/null @@ -1,66 +0,0 @@ - $this->id, - 'name' => $this->name, - 'email' => $this->email, - 'phone' => $this->phone, - 'contact_name' => $this->contact_name, - 'company_name' => $this->company_name, - 'website' => $this->website, - 'enable_portal' => $this->enable_portal, - 'password_added' => $this->password ? true : false, - 'currency_id' => $this->currency_id, - 'company_id' => $this->company_id, - 'facebook_id' => $this->facebook_id, - 'google_id' => $this->google_id, - 'github_id' => $this->github_id, - 'created_at' => $this->created_at, - 'formatted_created_at' => $this->formattedCreatedAt, - 'updated_at' => $this->updated_at, - 'avatar' => $this->avatar, - 'due_amount' => $this->due_amount, - 'base_due_amount' => $this->base_due_amount, - 'invoice_due_amount' => $this->invoice_due_amount, - 'base_invoice_due_amount' => $this->base_invoice_due_amount, - 'available_credit' => $this->available_credit, - 'base_available_credit' => $this->base_available_credit, - 'account_balance' => $this->account_balance, - 'base_account_balance' => $this->base_account_balance, - 'prefix' => $this->prefix, - 'tax_id' => $this->tax_id, - 'billing' => $this->when($this->billingAddress()->exists(), function () { - return new AddressResource($this->billingAddress); - }), - 'shipping' => $this->when($this->shippingAddress()->exists(), function () { - return new AddressResource($this->shippingAddress); - }), - 'fields' => $this->when($this->fields()->exists(), function () { - return CustomFieldValueResource::collection($this->fields); - }), - 'company' => $this->when($this->company()->exists(), function () { - return new CompanyResource($this->company); - }), - 'currency' => $this->when($this->currency()->exists(), function () { - return new CurrencyResource($this->currency); - }), - ]; - } -} diff --git a/app/Domains/Contacts/Models/Address.php b/app/Domains/Contacts/Models/Address.php deleted file mode 100644 index 522880a0..00000000 --- a/app/Domains/Contacts/Models/Address.php +++ /dev/null @@ -1,59 +0,0 @@ -country) { - return null; - } - - try { - return Countries::getName( - $this->country->code, - app()->getLocale() - ); - } catch (\Exception $e) { - return $this->country->name; - } - } - - public function user(): BelongsTo - { - return $this->belongsTo(User::class); - } - - public function customer(): BelongsTo - { - return $this->belongsTo(Customer::class); - } - - public function company(): BelongsTo - { - return $this->belongsTo(Company::class); - } - - public function country(): BelongsTo - { - return $this->belongsTo(Country::class); - } -} diff --git a/app/Domains/Contacts/Models/Country.php b/app/Domains/Contacts/Models/Country.php deleted file mode 100644 index 05c8606c..00000000 --- a/app/Domains/Contacts/Models/Country.php +++ /dev/null @@ -1,19 +0,0 @@ -hasMany(Address::class); - } -} diff --git a/app/Domains/Contacts/Models/Customer.php b/app/Domains/Contacts/Models/Customer.php deleted file mode 100644 index 3b634af1..00000000 --- a/app/Domains/Contacts/Models/Customer.php +++ /dev/null @@ -1,257 +0,0 @@ - 'boolean', - ]; - } - - public function getFormattedCreatedAtAttribute($value) - { - $dateFormat = CompanySetting::getSetting('carbon_date_format', $this->company_id); - - return Carbon::parse($this->created_at)->translatedFormat($dateFormat); - } - - public function setPasswordAttribute($value) - { - if ($value != null) { - $this->attributes['password'] = bcrypt($value); - } - } - - public function estimates(): HasMany - { - return $this->hasMany(Estimate::class); - } - - public function expenses(): HasMany - { - return $this->hasMany(Expense::class); - } - - public function invoices(): HasMany - { - return $this->hasMany(Invoice::class); - } - - public function payments(): HasMany - { - return $this->hasMany(Payment::class); - } - - public function emailLogs(): MorphMany - { - return $this->morphMany(EmailLog::class, 'mailable'); - } - - public function addresses(): HasMany - { - return $this->hasMany(Address::class); - } - - public function recurringInvoices(): HasMany - { - return $this->hasMany(RecurringInvoice::class); - } - - public function currency(): BelongsTo - { - return $this->belongsTo(Currency::class); - } - - public function creator(): BelongsTo - { - return $this->belongsTo(Customer::class, 'creator_id'); - } - - public function company(): BelongsTo - { - return $this->belongsTo(Company::class); - } - - public function billingAddress(): HasOne - { - return $this->hasOne(Address::class)->where('type', Address::BILLING_TYPE); - } - - public function shippingAddress(): HasOne - { - return $this->hasOne(Address::class)->where('type', Address::SHIPPING_TYPE); - } - - public function sendPasswordResetNotification(mixed $token): void - { - $this->notify(new CustomerMailResetPasswordNotification($token)); - } - - public function getAvatarAttribute() - { - $avatar = $this->getMedia('customer_avatar')->first(); - - if ($avatar) { - return asset($avatar->getUrl()); - } - - return 0; - } - - public function scopePaginateData($query, $limit) - { - if ($limit == 'all') { - return $query->get(); - } - - return $query->paginate($limit); - } - - public function scopeWhereCompany($query) - { - return $query->where('customers.company_id', request()->header('company')); - } - - public function scopeWhereContactName($query, $contactName) - { - return $query->where('contact_name', 'LIKE', '%'.$contactName.'%'); - } - - public function scopeWhereDisplayName($query, $displayName) - { - return $query->where('name', 'LIKE', '%'.$displayName.'%'); - } - - public function scopeWhereOrder($query, $orderByField, $orderBy) - { - SafeOrderBy::apply($query, $orderByField, $orderBy); - } - - public function scopeWhereSearch($query, $search) - { - foreach (explode(' ', $search) as $term) { - $query->where(function ($query) use ($term) { - $query->where('name', 'LIKE', '%'.$term.'%') - ->orWhere('email', 'LIKE', '%'.$term.'%') - ->orWhere('phone', 'LIKE', '%'.$term.'%'); - }); - } - } - - public function scopeWherePhone($query, $phone) - { - return $query->where('phone', 'LIKE', '%'.$phone.'%'); - } - - public function scopeWhereCustomer($query, $customer_id) - { - $query->orWhere('customers.id', $customer_id); - } - - public function scopeApplyInvoiceFilters($query, array $filters) - { - $filters = collect($filters); - - if ($filters->get('from_date') && $filters->get('to_date')) { - $start = Carbon::createFromFormat('Y-m-d', $filters->get('from_date')); - $end = Carbon::createFromFormat('Y-m-d', $filters->get('to_date')); - $query->invoicesBetween($start, $end); - } - } - - public function scopeInvoicesBetween($query, $start, $end) - { - $query->whereHas('invoices', function ($query) use ($start, $end) { - $query->whereBetween( - 'invoice_date', - [$start->format('Y-m-d'), $end->format('Y-m-d')] - ); - }); - } - - public function scopeApplyFilters($query, array $filters) - { - $filters = collect($filters); - - if ($filters->get('search')) { - $query->whereSearch($filters->get('search')); - } - - if ($filters->get('contact_name')) { - $query->whereContactName($filters->get('contact_name')); - } - - if ($filters->get('display_name')) { - $query->whereDisplayName($filters->get('display_name')); - } - - if ($filters->get('customer_id')) { - $query->whereCustomer($filters->get('customer_id')); - } - - if ($filters->get('phone')) { - $query->wherePhone($filters->get('phone')); - } - - if ($filters->get('orderByField') || $filters->get('orderBy')) { - $field = $filters->get('orderByField') ? $filters->get('orderByField') : 'name'; - $orderBy = $filters->get('orderBy') ? $filters->get('orderBy') : 'asc'; - $query->whereOrder($field, $orderBy); - } - } -} diff --git a/app/Domains/Contacts/Notifications/CustomerMailResetPasswordNotification.php b/app/Domains/Contacts/Notifications/CustomerMailResetPasswordNotification.php deleted file mode 100644 index 1fb509ba..00000000 --- a/app/Domains/Contacts/Notifications/CustomerMailResetPasswordNotification.php +++ /dev/null @@ -1,62 +0,0 @@ -company->slug}/customer/reset/password/".$this->token); - - return (new MailMessage) - ->subject('Reset Password Notification') - ->line('Hello! You are receiving this email because we received a password reset request for your account.') - ->action('Reset Password', $link) - ->line('This password reset link will expire in '.config('auth.passwords.users.expire').' minutes') - ->line('If you did not request a password reset, no further action is required.'); - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - */ - public function toArray($notifiable): array - { - return [ - // - ]; - } -} diff --git a/app/Domains/Contacts/Policies/CustomerPolicy.php b/app/Domains/Contacts/Policies/CustomerPolicy.php deleted file mode 100644 index b126ce95..00000000 --- a/app/Domains/Contacts/Policies/CustomerPolicy.php +++ /dev/null @@ -1,125 +0,0 @@ -hasCompany($customer->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can create models. - * - * @return mixed - */ - public function create(User $user): bool - { - if (BouncerFacade::can('create-customer', Customer::class)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can update the model. - * - * @return mixed - */ - public function update(User $user, Customer $customer): bool - { - if (BouncerFacade::can('edit-customer', $customer) && $user->hasCompany($customer->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can delete the model. - * - * @return mixed - */ - public function delete(User $user, Customer $customer): bool - { - if (BouncerFacade::can('delete-customer', $customer) && $user->hasCompany($customer->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can restore the model. - * - * @return mixed - */ - public function restore(User $user, Customer $customer): bool - { - if (BouncerFacade::can('delete-customer', $customer) && $user->hasCompany($customer->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can permanently delete the model. - * - * @return mixed - */ - public function forceDelete(User $user, Customer $customer): bool - { - if (BouncerFacade::can('delete-customer', $customer) && $user->hasCompany($customer->company_id)) { - return true; - } - - return false; - } - - /** - * Determine whether the user can delete models. - * - * @return mixed - */ - public function deleteMultiple(User $user) - { - if (BouncerFacade::can('delete-customer', Customer::class)) { - return true; - } - - return false; - } -}