From b98e6dca6a315aa95d852b59a7b8a440beb99c06 Mon Sep 17 00:00:00 2001 From: Kamil Grzechulski Date: Tue, 26 Nov 2024 17:25:26 +0100 Subject: [PATCH] chore: refactor controllers, queries, relations --- app/Http/Controllers/CRM/ClientController.php | 28 ++++----- .../Controllers/CRM/CompaniesController.php | 50 +++++---------- app/Http/Controllers/CRM/DealsController.php | 54 ++++++++-------- .../Controllers/CRM/EmployeesController.php | 37 +++++------ .../Controllers/CRM/FinancesController.php | 32 +++++----- .../Controllers/CRM/ProductsController.php | 42 +++++-------- app/Http/Controllers/CRM/SalesController.php | 50 +++++---------- .../Controllers/CRM/SettingsController.php | 17 ++--- app/Http/Controllers/CRM/TasksController.php | 32 +++++----- app/Http/Controllers/Controller.php | 3 - app/Http/Controllers/DashboardController.php | 62 +++++++++---------- app/Jobs/ChangePasswordJob.php | 6 +- app/Jobs/Client/StoreClientJob.php | 10 +-- app/Jobs/Client/UpdateClientJob.php | 6 +- app/Jobs/Company/StoreCompanyJob.php | 10 +-- app/Jobs/Company/UpdateCompanyJob.php | 6 +- app/Jobs/Deal/StoreDealJob.php | 10 +-- app/Jobs/Deal/StoreDealTermJob.php | 10 +-- app/Jobs/Deal/UpdateDealJob.php | 6 +- app/Jobs/Employee/StoreEmployeeJob.php | 10 +-- app/Jobs/Employee/UpdateEmployeeJob.php | 6 +- app/Jobs/Finance/StoreFinanceJob.php | 10 +-- app/Jobs/Finance/UpdateFinanceJob.php | 6 +- app/Jobs/Product/StoreProductJob.php | 10 +-- app/Jobs/Product/UpdateProductJob.php | 6 +- app/Jobs/Sale/StoreSaleJob.php | 10 +-- app/Jobs/Sale/UpdateSaleJob.php | 6 +- app/Jobs/StoreSystemLogJob.php | 4 +- app/Jobs/Task/StoreTaskJob.php | 10 +-- app/Jobs/Task/UpdateTaskJob.php | 6 +- app/Jobs/UpdateSettingsJob.php | 4 +- .../{ClientsQueries.php => ClientQueries.php} | 18 +++--- ...ompaniesQueries.php => CompanyQueries.php} | 20 +++--- .../{DealsQueries.php => DealQueries.php} | 16 ++--- ...ployeesQueries.php => EmployeeQueries.php} | 16 ++--- ...FinancesQueries.php => FinanceQueries.php} | 12 ++-- ...ProductsQueries.php => ProductQueries.php} | 16 ++--- .../{SalesQueries.php => SaleQueries.php} | 14 ++--- ...SettingsQueries.php => SettingQueries.php} | 13 ++-- ...emLogsQueries.php => SystemLogQueries.php} | 12 ++-- .../{TasksQueries.php => TaskQueries.php} | 20 +++--- app/Relations/Belongs/BelongsToClient.php | 4 +- app/Relations/Belongs/BelongsToCompany.php | 4 +- app/Relations/Belongs/BelongsToDeal.php | 4 +- app/Relations/Belongs/BelongsToEmployee.php | 4 +- app/Relations/Belongs/BelongsToProduct.php | 4 +- app/Relations/Has/HasManyCompanies.php | 4 +- app/Relations/Has/HasManyDealTerms.php | 4 +- app/Relations/Has/HasManyDeals.php | 4 +- app/Relations/Has/HasManyEmployees.php | 4 +- app/Relations/Has/HasManyFinances.php | 6 +- app/Relations/Has/HasManySales.php | 4 +- app/Relations/Has/HasManyTasks.php | 4 +- app/Services/CalculateCashService.php | 38 ++++++------ app/Services/ClientService.php | 18 +++--- app/Services/CompaniesService.php | 8 +-- app/Services/DealsService.php | 16 ++--- app/Services/EmployeesService.php | 14 ++--- app/Services/GraphDataService.php | 16 ++--- app/Services/TasksService.php | 12 ++-- config/auth.php | 2 +- resources/views/crm/clients/index.blade.php | 23 ++++--- resources/views/crm/finances/show.blade.php | 22 ++++--- resources/views/crm/products/index.blade.php | 24 ++++--- resources/views/crm/products/show.blade.php | 12 ++-- resources/views/crm/products/update.blade.php | 12 ++-- resources/views/crm/sales/index.blade.php | 20 +++--- routes/web.php | 20 +++--- 68 files changed, 487 insertions(+), 536 deletions(-) rename app/Queries/{ClientsQueries.php => ClientQueries.php} (71%) rename app/Queries/{CompaniesQueries.php => CompanyQueries.php} (71%) rename app/Queries/{DealsQueries.php => DealQueries.php} (70%) rename app/Queries/{EmployeesQueries.php => EmployeeQueries.php} (68%) rename app/Queries/{FinancesQueries.php => FinanceQueries.php} (69%) rename app/Queries/{ProductsQueries.php => ProductQueries.php} (74%) rename app/Queries/{SalesQueries.php => SaleQueries.php} (74%) rename app/Queries/{SettingsQueries.php => SettingQueries.php} (58%) rename app/Queries/{SystemLogsQueries.php => SystemLogQueries.php} (74%) rename app/Queries/{TasksQueries.php => TaskQueries.php} (73%) diff --git a/app/Http/Controllers/CRM/ClientController.php b/app/Http/Controllers/CRM/ClientController.php index 53f2365..a681d56 100644 --- a/app/Http/Controllers/CRM/ClientController.php +++ b/app/Http/Controllers/CRM/ClientController.php @@ -8,8 +8,8 @@ use App\Jobs\Client\StoreClientJob; use App\Jobs\Client\UpdateClientJob; use App\Jobs\StoreSystemLogJob; -use App\Models\ClientsModel; -use App\Queries\ClientsQueries; +use App\Models\Client; +use App\Queries\ClientQueries; use App\Services\ClientService; use Illuminate\Foundation\Bus\DispatchesJobs; @@ -30,8 +30,6 @@ class ClientController extends Controller */ public function __construct(ClientService $clientService) { - $this->middleware(self::MIDDLEWARE_AUTH); - $this->clientService = $clientService; } @@ -49,10 +47,10 @@ public function processRenderCreateForm(): \Illuminate\View\View /** * Show the details of a specific client record. * - * @param ClientsModel $client + * @param Client $client * @return \Illuminate\View\View */ - public function processShowClientDetails(ClientsModel $client): \Illuminate\View\View + public function processShowClientDetails(Client $client): \Illuminate\View\View { // Return the view with the client details. return view('crm.clients.show')->with(['client' => $this->clientService->loadClientDetails($client)]); @@ -61,10 +59,10 @@ public function processShowClientDetails(ClientsModel $client): \Illuminate\View /** * Render the form for updating an existing client record. * - * @param ClientsModel $client + * @param Client $client * @return \Illuminate\View\View */ - public function processRenderUpdateForm(ClientsModel $client): \Illuminate\View\View + public function processRenderUpdateForm(Client $client): \Illuminate\View\View { // Return the view for updating the client record. return view('crm.clients.update')->with(['client' => $this->clientService->loadClientDetails($client)]); @@ -79,7 +77,7 @@ public function processListOfClients(): \Illuminate\View\View { // Return the view with the paginated list of clients. return view('crm.clients.index')->with([ - 'clients' => ClientsQueries::getPaginate() + 'clients' => ClientQueries::getPaginate() ]); } @@ -106,11 +104,11 @@ public function processStoreClient(ClientStoreRequest $request): \Illuminate\Htt * Update an existing client record. * * @param ClientUpdateRequest $request - * @param ClientsModel $client + * @param Client $client * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processUpdateClient(ClientUpdateRequest $request, ClientsModel $client) + public function processUpdateClient(ClientUpdateRequest $request, Client $client) { // UpdateClientJob is a job that updates the client model. $this->dispatchSync(new UpdateClientJob($request->validated(), $client)); @@ -122,11 +120,11 @@ public function processUpdateClient(ClientUpdateRequest $request, ClientsModel $ /** * Delete a client record. * - * @param ClientsModel $client + * @param Client $client * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processDeleteClient(ClientsModel $client): \Illuminate\Http\RedirectResponse + public function processDeleteClient(Client $client): \Illuminate\Http\RedirectResponse { // Delete the client model. $client->delete(); @@ -138,11 +136,11 @@ public function processDeleteClient(ClientsModel $client): \Illuminate\Http\Redi /** * Set the active status of a client record. * - * @param ClientsModel $client + * @param Client $client * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processClientSetIsActive(ClientsModel $client): \Illuminate\Http\RedirectResponse + public function processClientSetIsActive(Client $client): \Illuminate\Http\RedirectResponse { // UpdateClientJob is a job that updates the client model. $this->dispatchSync(new UpdateClientJob(['is_active' => ! $client->is_active], $client)); diff --git a/app/Http/Controllers/CRM/CompaniesController.php b/app/Http/Controllers/CRM/CompaniesController.php index 35b2726..cf50f24 100644 --- a/app/Http/Controllers/CRM/CompaniesController.php +++ b/app/Http/Controllers/CRM/CompaniesController.php @@ -8,11 +8,9 @@ use App\Jobs\Company\StoreCompanyJob; use App\Jobs\Company\UpdateCompanyJob; use App\Jobs\StoreSystemLogJob; -use App\Models\CompaniesModel; -use App\Queries\ClientsQueries; -use App\Queries\CompaniesQueries; -use App\Services\CompaniesService; -use App\Services\DealsService; +use App\Models\Company; +use App\Queries\ClientQueries; +use App\Queries\CompanyQueries; use Illuminate\Foundation\Bus\DispatchesJobs; /** @@ -23,22 +21,6 @@ class CompaniesController extends Controller { use DispatchesJobs; - private CompaniesService $companiesService; - private DealsService $dealsService; - - /** - * CompaniesController constructor. - * - * @param CompaniesService $companiesService - * @param DealsService $dealsService - */ - public function __construct(CompaniesService $companiesService, DealsService $dealsService) - { - $this->middleware(self::MIDDLEWARE_AUTH); - - $this->companiesService = $companiesService; - $this->dealsService = $dealsService; - } /** * Render the form for creating a new company record. @@ -48,16 +30,16 @@ public function __construct(CompaniesService $companiesService, DealsService $de public function processRenderCreateForm(): \Illuminate\View\View { // Return view with clients. - return view('crm.companies.create')->with(['clients' => ClientsQueries::getAll()]); + return view('crm.companies.create')->with(['clients' => ClientQueries::getAll()]); } /** * Show the details of a specific company record. * - * @param CompaniesModel $company + * @param Company $company * @return \Illuminate\View\View */ - public function processViewCompanyDetails(CompaniesModel $company): \Illuminate\View\View + public function processViewCompanyDetails(Company $company): \Illuminate\View\View { // Return view with company details. return view('crm.companies.show')->with(['company' => $company]); @@ -72,22 +54,22 @@ public function processListOfCompanies(): \Illuminate\View\View { // Return view with companies pagination. return view('crm.companies.index')->with([ - 'companies' => CompaniesQueries::getPaginate() + 'companies' => CompanyQueries::getPaginate() ]); } /** * Render the form for updating an existing company record. * - * @param CompaniesModel $company + * @param Company $company * @return \Illuminate\View\View */ - public function processRenderUpdateForm(CompaniesModel $company): \Illuminate\View\View + public function processRenderUpdateForm(Company $company): \Illuminate\View\View { // Return view with company and clients return view('crm.companies.update')->with([ 'company' => $company, - 'clients' => ClientsQueries::getAll() + 'clients' => ClientQueries::getAll() ]); } @@ -114,11 +96,11 @@ public function processStoreCompany(CompanyStoreRequest $request): \Illuminate\H * Update an existing company record. * * @param CompanyUpdateRequest $request - * @param CompaniesModel $company + * @param Company $company * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processUpdateCompany(CompanyUpdateRequest $request, CompaniesModel $company): \Illuminate\Http\RedirectResponse + public function processUpdateCompany(CompanyUpdateRequest $request, Company $company): \Illuminate\Http\RedirectResponse { // Update company. $this->dispatchSync(new UpdateCompanyJob($request->validated(), $company)); @@ -130,11 +112,11 @@ public function processUpdateCompany(CompanyUpdateRequest $request, CompaniesMod /** * Delete a company record. * - * @param CompaniesModel $company + * @param Company $company * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processDeleteCompany(CompaniesModel $company): \Illuminate\Http\RedirectResponse + public function processDeleteCompany(Company $company): \Illuminate\Http\RedirectResponse { // Check if company has deals. if ($company->deals()->count() > 0) { @@ -154,11 +136,11 @@ public function processDeleteCompany(CompaniesModel $company): \Illuminate\Http\ /** * Set the active status of a company record. * - * @param CompaniesModel $company + * @param Company $company * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processCompanySetIsActive(CompaniesModel $company): \Illuminate\Http\RedirectResponse + public function processCompanySetIsActive(Company $company): \Illuminate\Http\RedirectResponse { // Update company status. $this->dispatchSync(new UpdateCompanyJob(['is_active' => ! $company->is_active], $company)); diff --git a/app/Http/Controllers/CRM/DealsController.php b/app/Http/Controllers/CRM/DealsController.php index fe88fc9..4f1b5ea 100644 --- a/app/Http/Controllers/CRM/DealsController.php +++ b/app/Http/Controllers/CRM/DealsController.php @@ -10,10 +10,10 @@ use App\Jobs\Deal\StoreDealTermJob; use App\Jobs\Deal\UpdateDealJob; use App\Jobs\StoreSystemLogJob; -use App\Models\DealsModel; -use App\Models\DealsTermsModel; -use App\Queries\CompaniesQueries; -use App\Queries\DealsQueries; +use App\Models\Deal; +use App\Models\DealTerm; +use App\Queries\CompanyQueries; +use App\Queries\DealQueries; use App\Services\DealsService; use Illuminate\Foundation\Bus\DispatchesJobs; @@ -34,8 +34,6 @@ class DealsController extends Controller */ public function __construct(DealsService $dealsService) { - $this->middleware(self::MIDDLEWARE_AUTH); - $this->dealsService = $dealsService; } @@ -47,21 +45,21 @@ public function __construct(DealsService $dealsService) public function processRenderCreateForm(): \Illuminate\View\View { // Load the companies for the dropdown. - return view('crm.deals.create')->with(['companies' => CompaniesQueries::getAll()]); + return view('crm.deals.create')->with(['companies' => CompanyQueries::getAll()]); } /** * Show the details of a specific deal record. * - * @param DealsModel $deal + * @param Deal $deal * @return \Illuminate\View\View */ - public function processShowDealsDetails(DealsModel $deal): \Illuminate\View\View + public function processShowDealsDetails(Deal $deal): \Illuminate\View\View { // Load the deal record details. return view('crm.deals.show')->with([ 'deal' => $deal, - 'companies' => CompaniesQueries::getAll() + 'companies' => CompanyQueries::getAll() ]); } @@ -74,22 +72,22 @@ public function processListOfDeals(): \Illuminate\View\View { // Load the deal records with pagination. return view('crm.deals.index')->with([ - 'deals' => DealsQueries::getPaginate() + 'deals' => DealQueries::getPaginate() ]); } /** * Render the form for updating an existing deal record. * - * @param DealsModel $deal + * @param Deal $deal * @return \Illuminate\View\View */ - public function processRenderUpdateForm(DealsModel $deal): \Illuminate\View\View + public function processRenderUpdateForm(Deal $deal): \Illuminate\View\View { // Load the deal record for editing. return view('crm.deals.update')->with([ 'deal' => $deal, - 'companies' => CompaniesQueries::getAll(), + 'companies' => CompanyQueries::getAll(), ]); } @@ -116,11 +114,11 @@ public function processStoreDeal(DealStoreRequest $request): \Illuminate\Http\Re * Update an existing deal record. * * @param DealUpdateRequest $request - * @param DealsModel $deal + * @param Deal $deal * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processUpdateDeal(DealUpdateRequest $request, DealsModel $deal) + public function processUpdateDeal(DealUpdateRequest $request, Deal $deal) { // Update the deal record. $this->dispatchSync(new UpdateDealJob($request->validated(), $deal)); @@ -132,11 +130,11 @@ public function processUpdateDeal(DealUpdateRequest $request, DealsModel $deal) /** * Delete a deal record. * - * @param DealsModel $deal + * @param Deal $deal * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processDeleteDeal(DealsModel $deal): \Illuminate\Http\RedirectResponse + public function processDeleteDeal(Deal $deal): \Illuminate\Http\RedirectResponse { // Check if the deal has any deal terms. if ($deal->dealTerms()->count() > 0) { @@ -156,11 +154,11 @@ public function processDeleteDeal(DealsModel $deal): \Illuminate\Http\RedirectRe /** * Set the active status of a deal record. * - * @param DealsModel $deal + * @param Deal $deal * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processSetIsActive(DealsModel $deal): \Illuminate\Http\RedirectResponse + public function processSetIsActive(Deal $deal): \Illuminate\Http\RedirectResponse { // Update the deal status. $this->dispatchSync(new UpdateDealJob(['is_active' => ! $deal->is_active], $deal)); @@ -176,11 +174,11 @@ public function processSetIsActive(DealsModel $deal): \Illuminate\Http\RedirectR * Store new deal terms. * * @param StoreDealTermRequest $request - * @param DealsModel $deal + * @param Deal $deal * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processStoreDealTerms(StoreDealTermRequest $request, DealsModel $deal): \Illuminate\Http\RedirectResponse + public function processStoreDealTerms(StoreDealTermRequest $request, Deal $deal): \Illuminate\Http\RedirectResponse { // Store the deal terms. $this->dispatchSync(new StoreDealTermJob($request->validated(), $deal)); @@ -195,11 +193,11 @@ public function processStoreDealTerms(StoreDealTermRequest $request, DealsModel /** * Generate deal terms in PDF format. * - * @param DealsTermsModel $dealTerm - * @param DealsModel $deal + * @param DealTerm $dealTerm + * @param Deal $deal * @return mixed */ - public function processGenerateDealTermsInPDF(DealsTermsModel $dealTerm, DealsModel $deal): mixed + public function processGenerateDealTermsInPDF(DealTerm $dealTerm, Deal $deal): mixed { // Load the deal terms in PDF format. return $this->dealsService->loadGenerateDealTermsInPDF($dealTerm, $deal); @@ -208,11 +206,11 @@ public function processGenerateDealTermsInPDF(DealsTermsModel $dealTerm, DealsMo /** * Delete a deal term record. * - * @param DealsTermsModel $dealTerm + * @param DealTerm $dealTerm * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processDeleteDealTerm(DealsTermsModel $dealTerm): \Illuminate\Http\RedirectResponse + public function processDeleteDealTerm(DealTerm $dealTerm): \Illuminate\Http\RedirectResponse { // Check if the deal term has been used in any deal $dealTerm->delete(); @@ -224,7 +222,7 @@ public function processDeleteDealTerm(DealsTermsModel $dealTerm): \Illuminate\Ht return redirect()->back()->with('message_success', $this->getMessage('messages.deal_term_delete')); } - public function processRenderTermCreateForm(DealsModel $deal) + public function processRenderTermCreateForm(Deal $deal) { return view('crm.deals.terms.create')->with(['deal' => $deal]); } diff --git a/app/Http/Controllers/CRM/EmployeesController.php b/app/Http/Controllers/CRM/EmployeesController.php index ada2fba..1cc4342 100644 --- a/app/Http/Controllers/CRM/EmployeesController.php +++ b/app/Http/Controllers/CRM/EmployeesController.php @@ -7,9 +7,9 @@ use App\Jobs\Employee\StoreEmployeeJob; use App\Jobs\Employee\UpdateEmployeeJob; use App\Jobs\StoreSystemLogJob; -use App\Models\EmployeesModel; -use App\Queries\ClientsQueries; -use App\Queries\EmployeesQueries; +use App\Models\Employee; +use App\Queries\ClientQueries; +use App\Queries\EmployeeQueries; use App\Http\Controllers\Controller; use Illuminate\Foundation\Bus\DispatchesJobs; @@ -22,11 +22,6 @@ class EmployeesController extends Controller { use DispatchesJobs; - public function __construct() - { - $this->middleware(self::MIDDLEWARE_AUTH); - } - /** * Render the form for creating a new employee record. * @@ -35,16 +30,16 @@ public function __construct() public function processRenderCreateForm(): \Illuminate\View\View { // Load the clients data to be used in the form. - return view('crm.employees.create')->with(['clients' => ClientsQueries::getAll()]); + return view('crm.employees.create')->with(['clients' => ClientQueries::getAll()]); } /** * Show the details of a specific employee record. * - * @param EmployeesModel $employee + * @param Employee $employee * @return \Illuminate\View\View */ - public function processShowEmployeeDetails(EmployeesModel $employee): \Illuminate\View\View + public function processShowEmployeeDetails(Employee $employee): \Illuminate\View\View { // Load the employee record details. return view('crm.employees.show')->with(['employee' => $employee]); @@ -59,22 +54,22 @@ public function processListOfEmployees(): \Illuminate\View\View { // Load the employee records and render the list page. return view('crm.employees.index')->with([ - 'employees' => EmployeesQueries::getPaginate() + 'employees' => EmployeeQueries::getPaginate() ]); } /** * Render the form for updating an existing employee record. * - * @param EmployeesModel $employee + * @param Employee $employee * @return \Illuminate\View\View */ - public function processRenderUpdateForm(EmployeesModel $employee): \Illuminate\View\View + public function processRenderUpdateForm(Employee $employee): \Illuminate\View\View { // Load the employee record details and the clients data to be used in the form. return view('crm.employees.update')->with([ 'employee' => $employee, - 'clients' => ClientsQueries::getAll() + 'clients' => ClientQueries::getAll() ]); } @@ -101,11 +96,11 @@ public function processStoreEmployee(EmployeeStoreRequest $request): \Illuminate * Update an existing employee record. * * @param EmployeeUpdateRequest $request - * @param EmployeesModel $employee + * @param Employee $employee * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processUpdateEmployee(EmployeeUpdateRequest $request, EmployeesModel $employee): \Illuminate\Http\RedirectResponse + public function processUpdateEmployee(EmployeeUpdateRequest $request, Employee $employee): \Illuminate\Http\RedirectResponse { // Dispatch the job to update the employee record. $this->dispatchSync(new UpdateEmployeeJob($request->validated(), $employee)); @@ -117,11 +112,11 @@ public function processUpdateEmployee(EmployeeUpdateRequest $request, EmployeesM /** * Delete an employee record. * - * @param EmployeesModel $employee + * @param Employee $employee * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processDeleteEmployee(EmployeesModel $employee): \Illuminate\Http\RedirectResponse + public function processDeleteEmployee(Employee $employee): \Illuminate\Http\RedirectResponse { // Check if the employee has any tasks assigned. if ($employee->tasks()->count() > 0) { @@ -141,11 +136,11 @@ public function processDeleteEmployee(EmployeesModel $employee): \Illuminate\Htt /** * Set the active status of an employee record. * - * @param EmployeesModel $employee + * @param Employee $employee * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processEmployeeSetIsActive(EmployeesModel $employee): \Illuminate\Http\RedirectResponse + public function processEmployeeSetIsActive(Employee $employee): \Illuminate\Http\RedirectResponse { // Dispatch the job to update the employee record. $this->dispatchSync(new UpdateEmployeeJob(['is_active' => ! $employee->is_active], $employee)); diff --git a/app/Http/Controllers/CRM/FinancesController.php b/app/Http/Controllers/CRM/FinancesController.php index 1398f4b..b8ef9cd 100644 --- a/app/Http/Controllers/CRM/FinancesController.php +++ b/app/Http/Controllers/CRM/FinancesController.php @@ -8,9 +8,9 @@ use App\Jobs\Finance\StoreFinanceJob; use App\Jobs\Finance\UpdateFinanceJob; use App\Jobs\StoreSystemLogJob; -use App\Models\FinancesModel; -use App\Queries\CompaniesQueries; -use App\Queries\FinancesQueries; +use App\Models\Finance; +use App\Queries\CompanyQueries; +use App\Queries\FinanceQueries; use Illuminate\Foundation\Bus\DispatchesJobs; /** @@ -30,16 +30,16 @@ class FinancesController extends Controller public function processRenderCreateForm() { // Return the view with the companies. - return view('crm.finances.create')->with(['companies' => CompaniesQueries::getAll(true)]); + return view('crm.finances.create')->with(['companies' => CompanyQueries::getAll(true)]); } /** * Show the details of a specific finance record. * - * @param FinancesModel $finance + * @param Finance $finance * @return \Illuminate\View\View */ - public function processShowFinancesDetails(FinancesModel $finance) + public function processShowFinancesDetails(Finance $finance) { // Return the view with the finance record. return view('crm.finances.show')->with(['finance' => $finance]); @@ -54,22 +54,22 @@ public function processListOfFinances() { // Return the view with the finances and the pagination. return view('crm.finances.index')->with([ - 'finances' => FinancesQueries::getPaginate() + 'finances' => FinanceQueries::getPaginate() ]); } /** * Render the form for updating an existing finance record. * - * @param FinancesModel $finance + * @param Finance $finance * @return \Illuminate\View\View */ - public function processRenderUpdateForm(FinancesModel $finance) + public function processRenderUpdateForm(Finance $finance) { // Return the view with the finance record and the companies. return view('crm.finances.update')->with([ 'finance' => $finance, - 'companies' => CompaniesQueries::getAll() + 'companies' => CompanyQueries::getAll() ]); } @@ -96,11 +96,11 @@ public function processStoreFinance(FinanceStoreRequest $request) * Update an existing finance record. * * @param FinanceUpdateRequest $request - * @param FinancesModel $finance + * @param Finance $finance * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processUpdateFinance(FinanceUpdateRequest $request, FinancesModel $finance) + public function processUpdateFinance(FinanceUpdateRequest $request, Finance $finance) { // UpdateFinanceJob is a job that updates the finance model. $this->dispatchSync(new UpdateFinanceJob($request->validated(), $finance)); @@ -112,11 +112,11 @@ public function processUpdateFinance(FinanceUpdateRequest $request, FinancesMode /** * Delete a finance record. * - * @param FinancesModel $finance + * @param Finance $finance * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processDeleteFinance(FinancesModel $finance) + public function processDeleteFinance(Finance $finance) { // Check if the finance record has companies. $finance->delete(); @@ -131,11 +131,11 @@ public function processDeleteFinance(FinancesModel $finance) /** * Set the active status of a finance record. * - * @param FinancesModel $finance + * @param Finance $finance * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processFinanceSetIsActive(FinancesModel $finance) + public function processFinanceSetIsActive(Finance $finance) { // UpdateFinanceJob is a job that updates the finance model. $this->dispatchSync(new UpdateFinanceJob(['is_active' => ! $finance->is_active], $finance)); diff --git a/app/Http/Controllers/CRM/ProductsController.php b/app/Http/Controllers/CRM/ProductsController.php index 8a75035..969a944 100644 --- a/app/Http/Controllers/CRM/ProductsController.php +++ b/app/Http/Controllers/CRM/ProductsController.php @@ -8,9 +8,8 @@ use App\Jobs\Product\StoreProductJob; use App\Jobs\Product\UpdateProductJob; use App\Jobs\StoreSystemLogJob; -use App\Models\ProductsModel; -use App\Queries\ProductsQueries; -use App\Services\ProductsService; +use App\Models\Product; +use App\Queries\ProductQueries; use Illuminate\Foundation\Bus\DispatchesJobs; /** @@ -21,19 +20,6 @@ class ProductsController extends Controller { use DispatchesJobs; - private ProductsService $productsService; - - /** - * ProductsController constructor. - * - * @param ProductsService $productsService - */ - public function __construct(ProductsService $productsService) - { - $this->middleware(self::MIDDLEWARE_AUTH); - - $this->productsService = $productsService; - } /** * Render the form for creating a new product record. @@ -49,10 +35,10 @@ public function processRenderCreateForm(): \Illuminate\View\View /** * Show the details of a specific product record. * - * @param ProductsModel $product + * @param Product $product * @return \Illuminate\View\View */ - public function processShowProductsDetails(ProductsModel $product): \Illuminate\View\View + public function processShowProductsDetails(Product $product): \Illuminate\View\View { // Load the product details and render the show page. return view('crm.products.show')->with(['product' => $product]); @@ -61,13 +47,13 @@ public function processShowProductsDetails(ProductsModel $product): \Illuminate\ /** * Render the form for updating an existing product record. * - * @param ProductsModel $product + * @param Product $product * @return \Illuminate\View\View */ - public function processRenderUpdateForm(ProductsModel $product): \Illuminate\View\View + public function processRenderUpdateForm(Product $product): \Illuminate\View\View { // Load the product details and render the update form. - return view('crm.products.update')->with(['product' => $product]); + return view('crm.products.update')->with(['product' => $product, 'products' => ProductQueries::getAll()]); } /** @@ -79,7 +65,7 @@ public function processListOfProducts(): \Illuminate\View\View { // Load the products with pagination. return view('crm.products.index')->with([ - 'products' => ProductsQueries::getPaginate() + 'products' => ProductQueries::getPaginate() ]); } @@ -106,11 +92,11 @@ public function processStoreProduct(ProductStoreRequest $request): \Illuminate\H * Update an existing product record. * * @param ProductUpdateRequest $request - * @param ProductsModel $product + * @param Product $product * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processUpdateProduct(ProductUpdateRequest $request, ProductsModel $product): \Illuminate\Http\RedirectResponse + public function processUpdateProduct(ProductUpdateRequest $request, Product $product): \Illuminate\Http\RedirectResponse { // Update the product. $this->dispatchSync(new UpdateProductJob($request->validated(), $product)); @@ -122,11 +108,11 @@ public function processUpdateProduct(ProductUpdateRequest $request, ProductsMode /** * Delete a product record. * - * @param ProductsModel $product + * @param Product $product * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processDeleteProduct(ProductsModel $product): \Illuminate\Http\RedirectResponse + public function processDeleteProduct(Product $product): \Illuminate\Http\RedirectResponse { // Check if the product has any sales records. if ($product->sales()->count() > 0) { @@ -146,11 +132,11 @@ public function processDeleteProduct(ProductsModel $product): \Illuminate\Http\R /** * Set the active status of a product record. * - * @param ProductsModel $product + * @param Product $product * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processProductSetIsActive(ProductsModel $product): \Illuminate\Http\RedirectResponse + public function processProductSetIsActive(Product $product): \Illuminate\Http\RedirectResponse { // Update the product's active status. $this->dispatchSync(new UpdateProductJob(['is_active' => $product->is_active], $product)); diff --git a/app/Http/Controllers/CRM/SalesController.php b/app/Http/Controllers/CRM/SalesController.php index 74cccef..91f3c44 100644 --- a/app/Http/Controllers/CRM/SalesController.php +++ b/app/Http/Controllers/CRM/SalesController.php @@ -8,11 +8,9 @@ use App\Jobs\Sale\StoreSaleJob; use App\Jobs\Sale\UpdateSaleJob; use App\Jobs\StoreSystemLogJob; -use App\Models\SalesModel; -use App\Queries\ProductsQueries; -use App\Queries\SalesQueries; -use App\Services\ProductsService; -use App\Services\SalesService; +use App\Models\Sale; +use App\Queries\ProductQueries; +use App\Queries\SaleQueries; use Illuminate\Foundation\Bus\DispatchesJobs; /** @@ -23,22 +21,6 @@ class SalesController extends Controller { use DispatchesJobs; - private SalesService $salesService; - private ProductsService $productsService; - - /** - * SalesController constructor. - * - * @param SalesService $salesService - * @param ProductsService $productsService - */ - public function __construct(SalesService $salesService, ProductsService $productsService) - { - $this->middleware(self::MIDDLEWARE_AUTH); - - $this->salesService = $salesService; - $this->productsService = $productsService; - } /** * Render the form for creating a new sale record. @@ -48,16 +30,16 @@ public function __construct(SalesService $salesService, ProductsService $product public function processRenderCreateForm(): \Illuminate\View\View { // Load the products data to be used in the form. - return view('crm.sales.create')->with(['products' => ProductsQueries::getAll()]); + return view('crm.sales.create')->with(['products' => ProductQueries::getAll()]); } /** * Show the details of a specific sale record. * - * @param SalesModel $sale + * @param Sale $sale * @return \Illuminate\View\View */ - public function processShowSalesDetails(SalesModel $sale): \Illuminate\View\View + public function processShowSalesDetails(Sale $sale): \Illuminate\View\View { // Load the sale record details. return view('crm.sales.show')->with(['sale' => $sale]); @@ -66,15 +48,15 @@ public function processShowSalesDetails(SalesModel $sale): \Illuminate\View\View /** * Render the form for updating an existing sale record. * - * @param SalesModel $sale + * @param Sale $sale * @return \Illuminate\View\View */ - public function processRenderUpdateForm(SalesModel $sale): \Illuminate\View\View + public function processRenderUpdateForm(Sale $sale): \Illuminate\View\View { // Load the sale record details and the products data to be used in the form. return view('crm.sales.update')->with([ 'sale' => $sale, - 'products' => ProductsQueries::getAll() + 'products' => ProductQueries::getAll() ]); } @@ -87,7 +69,7 @@ public function processListOfSales(): \Illuminate\View\View { // Load the sale records with pagination. return view('crm.sales.index')->with([ - 'sales' => SalesQueries::getPaginate() + 'sales' => SaleQueries::getPaginate() ]); } @@ -114,11 +96,11 @@ public function processStoreSale(SaleStoreRequest $request): \Illuminate\Http\Re * Update an existing sale record. * * @param SaleUpdateRequest $request - * @param SalesModel $sale + * @param Sale $sale * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processUpdateSale(SaleUpdateRequest $request, SalesModel $sale): \Illuminate\Http\RedirectResponse + public function processUpdateSale(SaleUpdateRequest $request, Sale $sale): \Illuminate\Http\RedirectResponse { // Dispatch the job to update the sale record. $this->dispatchSync(new UpdateSaleJob($request->validated(), $sale)); @@ -130,11 +112,11 @@ public function processUpdateSale(SaleUpdateRequest $request, SalesModel $sale): /** * Delete a sale record. * - * @param SalesModel $sale + * @param Sale $sale * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processDeleteSale(SalesModel $sale): \Illuminate\Http\RedirectResponse + public function processDeleteSale(Sale $sale): \Illuminate\Http\RedirectResponse { // Delete the sale record. $sale->delete(); @@ -149,11 +131,11 @@ public function processDeleteSale(SalesModel $sale): \Illuminate\Http\RedirectRe /** * Set the active status of a sale record. * - * @param SalesModel $sale + * @param Sale $sale * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processSaleSetIsActive(SalesModel $sale): \Illuminate\Http\RedirectResponse + public function processSaleSetIsActive(Sale $sale): \Illuminate\Http\RedirectResponse { // Dispatch the job to update the sale record. $this->dispatchSync(new UpdateSaleJob(['is_active' => ! $sale->is_active], $sale)); diff --git a/app/Http/Controllers/CRM/SettingsController.php b/app/Http/Controllers/CRM/SettingsController.php index 00c1d2f..8aa5a2e 100644 --- a/app/Http/Controllers/CRM/SettingsController.php +++ b/app/Http/Controllers/CRM/SettingsController.php @@ -6,8 +6,8 @@ use App\Http\Requests\SettingsStoreRequest; use App\Jobs\StoreSystemLogJob; use App\Jobs\UpdateSettingsJob; -use App\Queries\SettingsQueries; -use App\Queries\SystemLogsQueries; +use App\Queries\SettingQueries; +use App\Queries\SystemLogQueries; use Illuminate\Foundation\Bus\DispatchesJobs; /** @@ -19,15 +19,6 @@ class SettingsController extends Controller { use DispatchesJobs; - /** - * SettingsController constructor. - * - */ - public function __construct() - { - $this->middleware(self::MIDDLEWARE_AUTH); - } - /** * List all settings and system logs with pagination. * @@ -36,8 +27,8 @@ public function __construct() public function processListOfSettings(): \Illuminate\View\View { return view('crm.settings.index')->with([ - 'settings' => SettingsQueries::getAll(), - 'logs' => SystemLogsQueries::getPaginate() + 'settings' => SettingQueries::getAll(), + 'logs' => SystemLogQueries::getPaginate() ]); } diff --git a/app/Http/Controllers/CRM/TasksController.php b/app/Http/Controllers/CRM/TasksController.php index 22317de..bc850ef 100644 --- a/app/Http/Controllers/CRM/TasksController.php +++ b/app/Http/Controllers/CRM/TasksController.php @@ -8,8 +8,8 @@ use App\Jobs\StoreSystemLogJob; use App\Jobs\Task\StoreTaskJob; use App\Jobs\Task\UpdateTaskJob; -use App\Models\TasksModel; -use App\Queries\TasksQueries; +use App\Models\Task; +use App\Queries\TaskQueries; use App\Services\EmployeesService; use Illuminate\Http\RedirectResponse; @@ -29,8 +29,6 @@ class TasksController extends Controller */ public function __construct(EmployeesService $employeesService) { - $this->middleware(self::MIDDLEWARE_AUTH); - $this->employeesService = $employeesService; } @@ -53,16 +51,16 @@ public function processRenderCreateForm(): \Illuminate\View\View public function processListOfTasks(): \Illuminate\View\View { // Load the tasks with pagination. - return view('crm.tasks.index')->with(['tasks' => TasksQueries::getPaginate()]); + return view('crm.tasks.index')->with(['tasks' => TaskQueries::getPaginate()]); } /** * Show the details of a specific task record. * - * @param TasksModel $task + * @param Task $task * @return \Illuminate\View\View */ - public function processShowTasksDetails(TasksModel $task): \Illuminate\View\View + public function processShowTasksDetails(Task $task): \Illuminate\View\View { // Load the task record. return view('crm.tasks.show')->with(['task' => $task]); @@ -71,10 +69,10 @@ public function processShowTasksDetails(TasksModel $task): \Illuminate\View\View /** * Render the form for updating an existing task record. * - * @param TasksModel $task + * @param Task $task * @return \Illuminate\View\View */ - public function processRenderUpdateForm(TasksModel $task): \Illuminate\View\View + public function processRenderUpdateForm(Task $task): \Illuminate\View\View { // Load the task record for editing. return view('crm.tasks.update')->with([ @@ -106,11 +104,11 @@ public function processStoreTask(TaskStoreRequest $request): \Illuminate\Http\Re * Update an existing task record. * * @param TaskUpdateRequest $request - * @param TasksModel $task + * @param Task $task * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processUpdateTask(TaskUpdateRequest $request, TasksModel $task): \Illuminate\Http\RedirectResponse + public function processUpdateTask(TaskUpdateRequest $request, Task $task): \Illuminate\Http\RedirectResponse { // Update task. $this->dispatchSync(new UpdateTaskJob($request->validated(), $task)); @@ -122,11 +120,11 @@ public function processUpdateTask(TaskUpdateRequest $request, TasksModel $task): /** * Delete a task record. * - * @param TasksModel $task + * @param Task $task * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processDeleteTask(TasksModel $task): \Illuminate\Http\RedirectResponse + public function processDeleteTask(Task $task): \Illuminate\Http\RedirectResponse { // Check if the task is completed. if (! $task->completed) { @@ -146,11 +144,11 @@ public function processDeleteTask(TasksModel $task): \Illuminate\Http\RedirectRe /** * Set the active status of a task record. * - * @param TasksModel $task + * @param Task $task * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function processTaskSetIsActive(TasksModel $task): \Illuminate\Http\RedirectResponse + public function processTaskSetIsActive(Task $task): \Illuminate\Http\RedirectResponse { // Update the task status. $this->dispatchSync(new UpdateTaskJob(['is_active' => ! $task->is_active], $task)); @@ -165,11 +163,11 @@ public function processTaskSetIsActive(TasksModel $task): \Illuminate\Http\Redir /** * Set a task record to complete. * - * @param TasksModel $task + * @param Task $task * @return RedirectResponse * @throws \Exception */ - public function processSetTaskToCompleted(TasksModel $task): \Illuminate\Http\RedirectResponse + public function processSetTaskToCompleted(Task $task): \Illuminate\Http\RedirectResponse { // Update the task to complete. $this->dispatchSync(new UpdateTaskJob(['completed' => ! $task->completed], $task)); diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index a67561d..6c805dd 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -11,7 +11,4 @@ class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests, Language; - - const CURRENCY = 'currency'; - const MIDDLEWARE_AUTH = 'auth'; } diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 43a980d..482f3fe 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -2,16 +2,17 @@ namespace App\Http\Controllers; -use App\Queries\ClientsQueries; -use App\Queries\CompaniesQueries; -use App\Queries\DealsQueries; -use App\Queries\EmployeesQueries; -use App\Queries\FinancesQueries; -use App\Queries\ProductsQueries; -use App\Queries\SalesQueries; -use App\Queries\SettingsQueries; -use App\Queries\SystemLogsQueries; -use App\Queries\TasksQueries; +use App\Enums\Settings; +use App\Queries\ClientQueries; +use App\Queries\CompanyQueries; +use App\Queries\DealQueries; +use App\Queries\EmployeeQueries; +use App\Queries\FinanceQueries; +use App\Queries\ProductQueries; +use App\Queries\SaleQueries; +use App\Queries\SettingQueries; +use App\Queries\SystemLogQueries; +use App\Queries\TaskQueries; use App\Services\CalculateCashService; use App\Services\ClientService; use App\Services\CompaniesService; @@ -34,8 +35,6 @@ class DashboardController extends Controller public function __construct() { - $this->middleware(self::MIDDLEWARE_AUTH); - $this->clientService = new ClientService(); $this->companiesService = new CompaniesService(); $this->calculateCashService = new CalculateCashService(); @@ -61,8 +60,8 @@ public function index(): \Illuminate\View\View 'itemsCountGraphData' => $graph->itemsCountGraphData(), 'tasks' => $this->tasksService->formatTasks(), 'companies' => $this->companiesService->loadCompaniesByCreatedAt()->take(10), - 'products' => ProductsQueries::getProductsByCreatedAt()->take(10), - 'currency' => SettingsQueries::getSettingValue(self::CURRENCY) + 'products' => ProductQueries::getProductsByCreatedAt()->take(10), + 'currency' => SettingQueries::getSettingValue(Settings::CURRENCY->value) ] ); } @@ -74,40 +73,39 @@ public function index(): \Illuminate\View\View */ private function storeInCacheUsableVariables(): void { - Cache::put('countClients', ClientsQueries::getCountAll(), env('CACHE_TIME')); - Cache::put('deactivatedClients', ClientsQueries::getDeactivated(), env('CACHE_TIME')); + Cache::put('countClients', ClientQueries::getCountAll(), env('CACHE_TIME')); + Cache::put('deactivatedClients', ClientQueries::getDeactivated(), env('CACHE_TIME')); Cache::put('clientsInLatestMonth', $this->clientService->loadClientsInLatestMonth(), env('CACHE_TIME')); - Cache::put('countCompanies', CompaniesQueries::countAll(), env('CACHE_TIME')); - Cache::put('countEmployees', EmployeesQueries::countAll(), env('CACHE_TIME')); - Cache::put('countDeals', DealsQueries::countAll(), env('CACHE_TIME')); - Cache::put('countFinances', FinancesQueries::countAll(), env('CACHE_TIME')); - Cache::put('countProducts', ProductsQueries::countAll(), env('CACHE_TIME')); - Cache::put('countTasks', TasksQueries::countAll(), env('CACHE_TIME')); - Cache::put('countSales', SalesQueries::countAll(), env('CACHE_TIME')); - Cache::put('deactivatedCompanies', CompaniesQueries::getDeactivated(), env('CACHE_TIME')); + Cache::put('countCompanies', CompanyQueries::countAll(), env('CACHE_TIME')); + Cache::put('countEmployees', EmployeeQueries::countAll(), env('CACHE_TIME')); + Cache::put('countDeals', DealQueries::countAll(), env('CACHE_TIME')); + Cache::put('countFinances', FinanceQueries::countAll(), env('CACHE_TIME')); + Cache::put('countProducts', ProductQueries::countAll(), env('CACHE_TIME')); + Cache::put('countTasks', TaskQueries::countAll(), env('CACHE_TIME')); + Cache::put('countSales', SaleQueries::countAll(), env('CACHE_TIME')); + Cache::put('deactivatedCompanies', CompanyQueries::getDeactivated(), env('CACHE_TIME')); Cache::put('todayIncome', $this->calculateCashService->loadCountTodayIncome(), env('CACHE_TIME')); Cache::put('yesterdayIncome', $this->calculateCashService->loadCountYesterdayIncome(), env('CACHE_TIME')); Cache::put('cashTurnover', $this->calculateCashService->loadCountCashTurnover(), env('CACHE_TIME')); Cache::put('countAllRowsInDb', $this->calculateCashService->loadCountAllRowsInDb(), env('CACHE_TIME')); - Cache::put('countSystemLogs', SystemLogsQueries::countAll(), env('CACHE_TIME')); + Cache::put('countSystemLogs', SystemLogQueries::countAll(), env('CACHE_TIME')); Cache::put('companiesInLatestMonth', $this->companiesService->loadCompaniesInLatestMonth(), env('CACHE_TIME')); Cache::put('employeesInLatestMonth', $this->employeesService->loadEmployeesInLatestMonth(), env('CACHE_TIME')); - Cache::put('deactivatedEmployees', EmployeesQueries::getDeactivated(), env('CACHE_TIME')); - Cache::put('deactivatedDeals', DealsQueries::getDeactivated(), env('CACHE_TIME')); + Cache::put('deactivatedEmployees', EmployeeQueries::getDeactivated(), env('CACHE_TIME')); + Cache::put('deactivatedDeals', DealQueries::getDeactivated(), env('CACHE_TIME')); Cache::put('dealsInLatestMonth', $this->dealsService->loadDealsInLatestMonth(), env('CACHE_TIME')); Cache::put('completedTasks', $this->tasksService->loadCompletedTasks(), env('CACHE_TIME')); Cache::put('uncompletedTasks', $this->tasksService->loadUncompletedTasks(), env('CACHE_TIME')); - //loading circle - Cache::put('loadingCircle', SettingsQueries::getSettingValue('loading_circle'), env('CACHE_TIME')); + Cache::put('loadingCircle', SettingQueries::getSettingValue('loading_circle'), env('CACHE_TIME')); // currency - Cache::put('currency', SettingsQueries::getSettingValue('currency'), env('CACHE_TIME')); + Cache::put('currency', SettingQueries::getSettingValue('currency'), env('CACHE_TIME')); // last deploy time and version - Cache::put('lastDeployTime', SettingsQueries::getSettingValue('last_deploy_time'), env('CACHE_TIME')); - Cache::put('lastDeployVersion', SettingsQueries::getSettingValue('last_deploy_version'), env('CACHE_TIME')); + Cache::put('lastDeployTime', SettingQueries::getSettingValue('last_deploy_time'), env('CACHE_TIME')); + Cache::put('lastDeployVersion', SettingQueries::getSettingValue('last_deploy_version'), env('CACHE_TIME')); } /** diff --git a/app/Jobs/ChangePasswordJob.php b/app/Jobs/ChangePasswordJob.php index 38a0afa..12bb765 100644 --- a/app/Jobs/ChangePasswordJob.php +++ b/app/Jobs/ChangePasswordJob.php @@ -2,7 +2,7 @@ namespace App\Jobs; -use App\Models\AdminModel; +use App\Models\Administrator; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -17,14 +17,14 @@ class ChangePasswordJob implements ShouldQueue private string $oldPassword; private string $newPassword; private string $confirmNewPassword; - private AdminModel $adminModel; + private Administrator $adminModel; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, AdminModel $adminModel) + public function __construct(array $validatedData, Administrator $adminModel) { $this->oldPassword = $validatedData['old_password']; $this->newPassword = $validatedData['new_password']; diff --git a/app/Jobs/Client/StoreClientJob.php b/app/Jobs/Client/StoreClientJob.php index 57fd70d..53e06cc 100644 --- a/app/Jobs/Client/StoreClientJob.php +++ b/app/Jobs/Client/StoreClientJob.php @@ -2,8 +2,8 @@ namespace App\Jobs\Client; -use App\Models\AdminModel; -use App\Models\ClientsModel; +use App\Models\Administrator; +use App\Models\Client; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -15,14 +15,14 @@ class StoreClientJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private AdminModel $admin; + private Administrator $admin; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, AdminModel $admin) + public function __construct(array $validatedData, Administrator $admin) { $this->validatedData = $validatedData; $this->admin = $admin; @@ -35,7 +35,7 @@ public function __construct(array $validatedData, AdminModel $admin) */ public function handle() { - $model = new ClientsModel(); + $model = new Client(); foreach($this->validatedData as $key => $value) { $model->$key = $value; diff --git a/app/Jobs/Client/UpdateClientJob.php b/app/Jobs/Client/UpdateClientJob.php index 6578bc4..48364a9 100644 --- a/app/Jobs/Client/UpdateClientJob.php +++ b/app/Jobs/Client/UpdateClientJob.php @@ -2,7 +2,7 @@ namespace App\Jobs\Client; -use App\Models\ClientsModel; +use App\Models\Client; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -14,14 +14,14 @@ class UpdateClientJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private ClientsModel $client; + private Client $client; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, ClientsModel $client) + public function __construct(array $validatedData, Client $client) { $this->validatedData = $validatedData; $this->client = $client; diff --git a/app/Jobs/Company/StoreCompanyJob.php b/app/Jobs/Company/StoreCompanyJob.php index 4a93238..39b9aed 100644 --- a/app/Jobs/Company/StoreCompanyJob.php +++ b/app/Jobs/Company/StoreCompanyJob.php @@ -2,8 +2,8 @@ namespace App\Jobs\Company; -use App\Models\AdminModel; -use App\Models\CompaniesModel; +use App\Models\Administrator; +use App\Models\Company; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; @@ -16,14 +16,14 @@ class StoreCompanyJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private AdminModel $admin; + private Administrator $admin; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, AdminModel $admin) + public function __construct(array $validatedData, Administrator $admin) { $this->validatedData = $validatedData; $this->admin = $admin; @@ -36,7 +36,7 @@ public function __construct(array $validatedData, AdminModel $admin) */ public function handle(): void { - $model = new CompaniesModel(); + $model = new Company(); foreach ($this->validatedData as $key => $value) { $model->$key = $value; diff --git a/app/Jobs/Company/UpdateCompanyJob.php b/app/Jobs/Company/UpdateCompanyJob.php index 35a8ced..f1e7e64 100644 --- a/app/Jobs/Company/UpdateCompanyJob.php +++ b/app/Jobs/Company/UpdateCompanyJob.php @@ -2,7 +2,7 @@ namespace App\Jobs\Company; -use App\Models\CompaniesModel; +use App\Models\Company; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; @@ -15,14 +15,14 @@ class UpdateCompanyJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private CompaniesModel $company; + private Company $company; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, CompaniesModel $company) + public function __construct(array $validatedData, Company $company) { $this->validatedData = $validatedData; $this->company = $company; diff --git a/app/Jobs/Deal/StoreDealJob.php b/app/Jobs/Deal/StoreDealJob.php index 9c0e704..f7599fc 100644 --- a/app/Jobs/Deal/StoreDealJob.php +++ b/app/Jobs/Deal/StoreDealJob.php @@ -2,8 +2,8 @@ namespace App\Jobs\Deal; -use App\Models\AdminModel; -use App\Models\DealsModel; +use App\Models\Administrator; +use App\Models\Deal; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; @@ -16,14 +16,14 @@ class StoreDealJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private AdminModel $admin; + private Administrator $admin; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, AdminModel $admin) + public function __construct(array $validatedData, Administrator $admin) { $this->validatedData = $validatedData; $this->admin = $admin; @@ -36,7 +36,7 @@ public function __construct(array $validatedData, AdminModel $admin) */ public function handle(): void { - $model = new DealsModel(); + $model = new Deal(); foreach ($this->validatedData as $key => $value) { $model->$key = $value; diff --git a/app/Jobs/Deal/StoreDealTermJob.php b/app/Jobs/Deal/StoreDealTermJob.php index b30d099..48777b5 100644 --- a/app/Jobs/Deal/StoreDealTermJob.php +++ b/app/Jobs/Deal/StoreDealTermJob.php @@ -2,8 +2,8 @@ namespace App\Jobs\Deal; -use App\Models\DealsModel; -use App\Models\DealsTermsModel; +use App\Models\Deal; +use App\Models\DealTerm; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; @@ -16,14 +16,14 @@ class StoreDealTermJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private DealsModel $deal; + private Deal $deal; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, DealsModel $deal) + public function __construct(array $validatedData, Deal $deal) { $this->validatedData = $validatedData; $this->deal = $deal; @@ -36,7 +36,7 @@ public function __construct(array $validatedData, DealsModel $deal) */ public function handle(): void { - $model = new DealsTermsModel(); + $model = new DealTerm(); foreach ($this->validatedData as $key => $value) { $model->$key = $value; diff --git a/app/Jobs/Deal/UpdateDealJob.php b/app/Jobs/Deal/UpdateDealJob.php index bdadd03..8fbe91d 100644 --- a/app/Jobs/Deal/UpdateDealJob.php +++ b/app/Jobs/Deal/UpdateDealJob.php @@ -2,7 +2,7 @@ namespace App\Jobs\Deal; -use App\Models\DealsModel; +use App\Models\Deal; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -13,14 +13,14 @@ class UpdateDealJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private DealsModel $deal; + private Deal $deal; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, DealsModel $deal) + public function __construct(array $validatedData, Deal $deal) { $this->validatedData = $validatedData; $this->deal = $deal; diff --git a/app/Jobs/Employee/StoreEmployeeJob.php b/app/Jobs/Employee/StoreEmployeeJob.php index 280780b..65d1524 100644 --- a/app/Jobs/Employee/StoreEmployeeJob.php +++ b/app/Jobs/Employee/StoreEmployeeJob.php @@ -2,8 +2,8 @@ namespace App\Jobs\Employee; -use App\Models\AdminModel; -use App\Models\EmployeesModel; +use App\Models\Administrator; +use App\Models\Employee; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -15,14 +15,14 @@ class StoreEmployeeJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private AdminModel $admin; + private Administrator $admin; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, AdminModel $admin) + public function __construct(array $validatedData, Administrator $admin) { $this->validatedData = $validatedData; $this->admin = $admin; @@ -35,7 +35,7 @@ public function __construct(array $validatedData, AdminModel $admin) */ public function handle(): void { - $model = new EmployeesModel(); + $model = new Employee(); foreach ($this->validatedData as $key => $value) { $model->$key = $value; diff --git a/app/Jobs/Employee/UpdateEmployeeJob.php b/app/Jobs/Employee/UpdateEmployeeJob.php index c4b0c00..2ef7761 100644 --- a/app/Jobs/Employee/UpdateEmployeeJob.php +++ b/app/Jobs/Employee/UpdateEmployeeJob.php @@ -2,7 +2,7 @@ namespace App\Jobs\Employee; -use App\Models\EmployeesModel; +use App\Models\Employee; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -13,14 +13,14 @@ class UpdateEmployeeJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private EmployeesModel $employee; + private Employee $employee; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, EmployeesModel $employee) + public function __construct(array $validatedData, Employee $employee) { $this->validatedData = $validatedData; $this->employee = $employee; diff --git a/app/Jobs/Finance/StoreFinanceJob.php b/app/Jobs/Finance/StoreFinanceJob.php index b2eef33..1ce8bec 100644 --- a/app/Jobs/Finance/StoreFinanceJob.php +++ b/app/Jobs/Finance/StoreFinanceJob.php @@ -2,8 +2,8 @@ namespace App\Jobs\Finance; -use App\Models\AdminModel; -use App\Models\FinancesModel; +use App\Models\Administrator; +use App\Models\Finance; use App\Services\FinancesService; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -16,14 +16,14 @@ class StoreFinanceJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private AdminModel $admin; + private Administrator $admin; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, AdminModel $admin) + public function __construct(array $validatedData, Administrator $admin) { $this->validatedData = $validatedData; $this->admin = $admin; @@ -39,7 +39,7 @@ public function handle(): void $financesHelper = new FinancesService(); $dataToInsert = $financesHelper->loadCalculateNetAndVatByGivenGross($this->validatedData['gross']); - $model = new FinancesModel(); + $model = new Finance(); foreach ($this->validatedData as $key => $value) { $model->$key = $value; diff --git a/app/Jobs/Finance/UpdateFinanceJob.php b/app/Jobs/Finance/UpdateFinanceJob.php index c80ef5d..1ec3653 100644 --- a/app/Jobs/Finance/UpdateFinanceJob.php +++ b/app/Jobs/Finance/UpdateFinanceJob.php @@ -2,7 +2,7 @@ namespace App\Jobs\Finance; -use App\Models\FinancesModel; +use App\Models\Finance; use App\Services\FinancesService; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -15,14 +15,14 @@ class UpdateFinanceJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private FinancesModel $finance; + private Finance $finance; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, FinancesModel $finance) + public function __construct(array $validatedData, Finance $finance) { $this->validatedData = $validatedData; $this->finance = $finance; diff --git a/app/Jobs/Product/StoreProductJob.php b/app/Jobs/Product/StoreProductJob.php index 205d0cd..acbd7bd 100644 --- a/app/Jobs/Product/StoreProductJob.php +++ b/app/Jobs/Product/StoreProductJob.php @@ -2,8 +2,8 @@ namespace App\Jobs\Product; -use App\Models\AdminModel; -use App\Models\ProductsModel; +use App\Models\Administrator; +use App\Models\Product; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -15,14 +15,14 @@ class StoreProductJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private AdminModel $admin; + private Administrator $admin; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, AdminModel $admin) + public function __construct(array $validatedData, Administrator $admin) { $this->validatedData = $validatedData; $this->admin = $admin; @@ -35,7 +35,7 @@ public function __construct(array $validatedData, AdminModel $admin) */ public function handle(): void { - $model = new ProductsModel(); + $model = new Product(); foreach ($this->validatedData as $key => $value) { $model->$key = $value; diff --git a/app/Jobs/Product/UpdateProductJob.php b/app/Jobs/Product/UpdateProductJob.php index 76c944f..f3eea17 100644 --- a/app/Jobs/Product/UpdateProductJob.php +++ b/app/Jobs/Product/UpdateProductJob.php @@ -2,7 +2,7 @@ namespace App\Jobs\Product; -use App\Models\ProductsModel; +use App\Models\Product; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -13,14 +13,14 @@ class UpdateProductJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private ProductsModel $product; + private Product $product; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, ProductsModel $product) + public function __construct(array $validatedData, Product $product) { $this->validatedData = $validatedData; $this->product = $product; diff --git a/app/Jobs/Sale/StoreSaleJob.php b/app/Jobs/Sale/StoreSaleJob.php index 0c797e2..3313cbb 100644 --- a/app/Jobs/Sale/StoreSaleJob.php +++ b/app/Jobs/Sale/StoreSaleJob.php @@ -2,8 +2,8 @@ namespace App\Jobs\Sale; -use App\Models\AdminModel; -use App\Models\SalesModel; +use App\Models\Administrator; +use App\Models\Sale; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; @@ -16,14 +16,14 @@ class StoreSaleJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private AdminModel $admin; + private Administrator $admin; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, AdminModel $admin) + public function __construct(array $validatedData, Administrator $admin) { $this->validatedData = $validatedData; $this->admin = $admin; @@ -36,7 +36,7 @@ public function __construct(array $validatedData, AdminModel $admin) */ public function handle(): void { - $model = new SalesModel(); + $model = new Sale(); foreach ($this->validatedData as $key => $value) { $model->$key = $value; diff --git a/app/Jobs/Sale/UpdateSaleJob.php b/app/Jobs/Sale/UpdateSaleJob.php index e6a3a03..7825818 100644 --- a/app/Jobs/Sale/UpdateSaleJob.php +++ b/app/Jobs/Sale/UpdateSaleJob.php @@ -2,7 +2,7 @@ namespace App\Jobs\Sale; -use App\Models\SalesModel; +use App\Models\Sale; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -13,14 +13,14 @@ class UpdateSaleJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private SalesModel $sale; + private Sale $sale; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, SalesModel $sale) + public function __construct(array $validatedData, Sale $sale) { $this->validatedData = $validatedData; $this->sale = $sale; diff --git a/app/Jobs/StoreSystemLogJob.php b/app/Jobs/StoreSystemLogJob.php index 33606fe..96355f9 100644 --- a/app/Jobs/StoreSystemLogJob.php +++ b/app/Jobs/StoreSystemLogJob.php @@ -2,7 +2,7 @@ namespace App\Jobs; -use App\Models\SystemLogsModel; +use App\Models\SystemLog; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -39,7 +39,7 @@ public function handle(): void { $userInformation = $this->authUser->getUserInformation(); - $model = new SystemLogsModel(); + $model = new SystemLog(); $model->admin_id = $this->authUser->id; $model->actions = $this->actions; diff --git a/app/Jobs/Task/StoreTaskJob.php b/app/Jobs/Task/StoreTaskJob.php index be275db..54b4546 100644 --- a/app/Jobs/Task/StoreTaskJob.php +++ b/app/Jobs/Task/StoreTaskJob.php @@ -2,8 +2,8 @@ namespace App\Jobs\Task; -use App\Models\AdminModel; -use App\Models\TasksModel; +use App\Models\Administrator; +use App\Models\Task; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; @@ -16,14 +16,14 @@ class StoreTaskJob implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private array $validatedData; - private AdminModel $admin; + private Administrator $admin; /** * Create a new job instance. * * @return void */ - public function __construct(array $validatedData, AdminModel $admin) + public function __construct(array $validatedData, Administrator $admin) { $this->validatedData = $validatedData; $this->admin = $admin; @@ -36,7 +36,7 @@ public function __construct(array $validatedData, AdminModel $admin) */ public function handle(): void { - $model = new TasksModel(); + $model = new Task(); foreach ($this->validatedData as $key => $value) { $model->$key = $value; diff --git a/app/Jobs/Task/UpdateTaskJob.php b/app/Jobs/Task/UpdateTaskJob.php index 1825bdc..19bd38a 100644 --- a/app/Jobs/Task/UpdateTaskJob.php +++ b/app/Jobs/Task/UpdateTaskJob.php @@ -2,7 +2,7 @@ namespace App\Jobs\Task; -use App\Models\TasksModel; +use App\Models\Task; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -13,7 +13,7 @@ class UpdateTaskJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - private TasksModel $task; + private Task $task; private array $validatedData; /** @@ -21,7 +21,7 @@ class UpdateTaskJob implements ShouldQueue * * @return void */ - public function __construct(array $validatedData, TasksModel $task) + public function __construct(array $validatedData, Task $task) { $this->validatedData = $validatedData; $this->task = $task; diff --git a/app/Jobs/UpdateSettingsJob.php b/app/Jobs/UpdateSettingsJob.php index 0d4520c..3f5b2cd 100644 --- a/app/Jobs/UpdateSettingsJob.php +++ b/app/Jobs/UpdateSettingsJob.php @@ -2,7 +2,7 @@ namespace App\Jobs; -use App\Models\SettingsModel; +use App\Models\Setting; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -33,7 +33,7 @@ public function __construct(array $validatedData) public function handle(): void { foreach($this->validatedData as $key => $value) { - SettingsModel::where('key', $key)->update([ + Setting::where('key', $key)->update([ 'value' => $value, 'updated_at' => now() ]); diff --git a/app/Queries/ClientsQueries.php b/app/Queries/ClientQueries.php similarity index 71% rename from app/Queries/ClientsQueries.php rename to app/Queries/ClientQueries.php index 9816695..eed8175 100644 --- a/app/Queries/ClientsQueries.php +++ b/app/Queries/ClientQueries.php @@ -2,15 +2,15 @@ namespace App\Queries; -use App\Models\ClientsModel; -use App\Models\SettingsModel; +use App\Models\Client; +use App\Models\Setting; /** * Class ClientsQueries * * Query class for handling operations related to the ClientsModel. */ -class ClientsQueries +class ClientQueries { /** * Get all clients. @@ -19,7 +19,7 @@ class ClientsQueries */ public static function getAll(): \Illuminate\Database\Eloquent\Collection { - return ClientsModel::all(); + return Client::all(); } /** @@ -29,8 +29,8 @@ public static function getAll(): \Illuminate\Database\Eloquent\Collection */ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginator { - return ClientsModel::orderByDesc('id') - ->paginate(SettingsModel::where('key', 'pagination_size') + return Client::orderByDesc('id') + ->paginate(Setting::where('key', 'pagination_size') ->get()->last()->value); } @@ -41,7 +41,7 @@ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginato */ public static function getDeactivated(): int { - return ClientsModel::where('is_active', '=', 0)->count(); + return Client::where('is_active', '=', 0)->count(); } /** @@ -51,7 +51,7 @@ public static function getDeactivated(): int */ public static function getCountAll(): int { - return ClientsModel::all()->count(); + return Client::all()->count(); } /** @@ -61,6 +61,6 @@ public static function getCountAll(): int */ public static function getCountAllInLatestMonth(): int { - return ClientsModel::where('created_at', '>=', now()->subMonth())->count(); + return Client::where('created_at', '>=', now()->subMonth())->count(); } } diff --git a/app/Queries/CompaniesQueries.php b/app/Queries/CompanyQueries.php similarity index 71% rename from app/Queries/CompaniesQueries.php rename to app/Queries/CompanyQueries.php index 9b0cafc..e2b5655 100644 --- a/app/Queries/CompaniesQueries.php +++ b/app/Queries/CompanyQueries.php @@ -2,15 +2,15 @@ namespace App\Queries; -use App\Models\CompaniesModel; -use App\Models\SettingsModel; +use App\Models\Company; +use App\Models\Setting; /** * Class CompaniesQueries * * Query class for handling operations related to the CompaniesModel. */ -class CompaniesQueries +class CompanyQueries { /** * Get all companies. @@ -19,7 +19,7 @@ class CompaniesQueries */ public static function getAll(): \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Collection { - return CompaniesModel::all()->sortBy('created_at'); + return Company::all()->sortBy('created_at'); } /** @@ -29,8 +29,8 @@ public static function getAll(): \Illuminate\Support\Collection|\Illuminate\Data */ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginator { - return CompaniesModel::orderByDesc('id') - ->paginate(SettingsModel::where('key', 'pagination_size') + return Company::orderByDesc('id') + ->paginate(Setting::where('key', 'pagination_size') ->get()->last()->value); } @@ -41,7 +41,7 @@ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginato */ public static function getDeactivated(): int { - return CompaniesModel::where('is_active', '=', 0)->count(); + return Company::where('is_active', '=', 0)->count(); } /** @@ -51,7 +51,7 @@ public static function getDeactivated(): int */ public static function getCompaniesSortedByCreatedAt(): \Illuminate\Support\Collection { - return CompaniesModel::all()->sortBy('created_at', 0, true)->slice(0, 5); + return Company::all()->sortBy('created_at', 0, true)->slice(0, 5); } /** @@ -61,7 +61,7 @@ public static function getCompaniesSortedByCreatedAt(): \Illuminate\Support\Coll */ public static function countAll(): int { - return CompaniesModel::all()->count(); + return Company::all()->count(); } /** @@ -71,6 +71,6 @@ public static function countAll(): int */ public static function getCompaniesInLatestMonth(): int { - return CompaniesModel::where('created_at', '>=', now()->subMonth())->count(); + return Company::where('created_at', '>=', now()->subMonth())->count(); } } diff --git a/app/Queries/DealsQueries.php b/app/Queries/DealQueries.php similarity index 70% rename from app/Queries/DealsQueries.php rename to app/Queries/DealQueries.php index df34954..2d00424 100644 --- a/app/Queries/DealsQueries.php +++ b/app/Queries/DealQueries.php @@ -2,15 +2,15 @@ namespace App\Queries; -use App\Models\DealsModel; -use App\Models\SettingsModel; +use App\Models\Deal; +use App\Models\Setting; /** * Class DealsQueries * * Query class for handling operations related to the DealsModel. */ -class DealsQueries +class DealQueries { /** * Get all deals created in the latest month. @@ -19,7 +19,7 @@ class DealsQueries */ public static function getDealsInLatestMonth(): \Illuminate\Database\Eloquent\Collection { - return DealsModel::where('created_at', '>=', now()->subMonth())->get(); + return Deal::where('created_at', '>=', now()->subMonth())->get(); } /** @@ -29,7 +29,7 @@ public static function getDealsInLatestMonth(): \Illuminate\Database\Eloquent\Co */ public static function countAll(): int { - return DealsModel::all()->count(); + return Deal::all()->count(); } /** @@ -39,7 +39,7 @@ public static function countAll(): int */ public static function getDeactivated(): int { - return DealsModel::where('is_active', '=', 0)->count(); + return Deal::where('is_active', '=', 0)->count(); } /** @@ -49,8 +49,8 @@ public static function getDeactivated(): int */ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginator { - return DealsModel::orderByDesc('id') - ->paginate(SettingsModel::where('key', 'pagination_size') + return Deal::orderByDesc('id') + ->paginate(Setting::where('key', 'pagination_size') ->get()->last()->value); } } diff --git a/app/Queries/EmployeesQueries.php b/app/Queries/EmployeeQueries.php similarity index 68% rename from app/Queries/EmployeesQueries.php rename to app/Queries/EmployeeQueries.php index e52ac76..2e44e81 100644 --- a/app/Queries/EmployeesQueries.php +++ b/app/Queries/EmployeeQueries.php @@ -2,15 +2,15 @@ namespace App\Queries; -use App\Models\EmployeesModel; -use App\Models\SettingsModel; +use App\Models\Employee; +use App\Models\Setting; /** * Class EmployeesQueries * * Query class for handling operations related to the EmployeesModel. */ -class EmployeesQueries +class EmployeeQueries { /** * Get the count of all deactivated employees. @@ -19,7 +19,7 @@ class EmployeesQueries */ public static function getDeactivated(): int { - return EmployeesModel::where('is_active', '=', 0)->count(); + return Employee::where('is_active', '=', 0)->count(); } /** @@ -29,7 +29,7 @@ public static function getDeactivated(): int */ public static function getEmployeesInLatestMonth(): float { - return EmployeesModel::where('created_at', '>=', now()->subMonth())->count(); + return Employee::where('created_at', '>=', now()->subMonth())->count(); } /** @@ -39,7 +39,7 @@ public static function getEmployeesInLatestMonth(): float */ public static function countAll(): int { - return EmployeesModel::all()->count(); + return Employee::all()->count(); } /** @@ -49,8 +49,8 @@ public static function countAll(): int */ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginator { - return EmployeesModel::orderByDesc('id') - ->paginate(SettingsModel::where('key', 'pagination_size') + return Employee::orderByDesc('id') + ->paginate(Setting::where('key', 'pagination_size') ->get()->last()->value); } } diff --git a/app/Queries/FinancesQueries.php b/app/Queries/FinanceQueries.php similarity index 69% rename from app/Queries/FinancesQueries.php rename to app/Queries/FinanceQueries.php index cfab71d..2c7a1f8 100644 --- a/app/Queries/FinancesQueries.php +++ b/app/Queries/FinanceQueries.php @@ -2,15 +2,15 @@ namespace App\Queries; -use App\Models\FinancesModel; -use App\Models\SettingsModel; +use App\Models\Finance; +use App\Models\Setting; /** * Class FinancesQueries * * Query class for handling operations related to the FinancesModel. */ -class FinancesQueries +class FinanceQueries { /** * Get the count of all finance records. @@ -19,7 +19,7 @@ class FinancesQueries */ public static function countAll(): int { - return FinancesModel::count(); + return Finance::count(); } /** @@ -29,8 +29,8 @@ public static function countAll(): int */ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginator { - return FinancesModel::orderByDesc('id') - ->paginate(SettingsModel::where('key', 'pagination_size') + return Finance::orderByDesc('id') + ->paginate(Setting::where('key', 'pagination_size') ->get()->last()->value); } } diff --git a/app/Queries/ProductsQueries.php b/app/Queries/ProductQueries.php similarity index 74% rename from app/Queries/ProductsQueries.php rename to app/Queries/ProductQueries.php index 264a063..5a7ef60 100644 --- a/app/Queries/ProductsQueries.php +++ b/app/Queries/ProductQueries.php @@ -2,15 +2,15 @@ namespace App\Queries; -use App\Models\ProductsModel; -use App\Models\SettingsModel; +use App\Models\Product; +use App\Models\Setting; /** * Class ProductsQueries * * Query class for handling operations related to the ProductsModel. */ -class ProductsQueries +class ProductQueries { /** * Get the count of all products. @@ -19,7 +19,7 @@ class ProductsQueries */ public static function countAll() { - return ProductsModel::count(); + return Product::count(); } /** @@ -29,7 +29,7 @@ public static function countAll() */ public static function getProductsByCreatedAt(): \Illuminate\Database\Eloquent\Collection { - return ProductsModel::orderBy('created_at', 'desc')->get(); + return Product::orderBy('created_at', 'desc')->get(); } /** @@ -39,8 +39,8 @@ public static function getProductsByCreatedAt(): \Illuminate\Database\Eloquent\C */ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginator { - return ProductsModel::orderByDesc('id') - ->paginate(SettingsModel::where('key', 'pagination_size') + return Product::orderByDesc('id') + ->paginate(Setting::where('key', 'pagination_size') ->get()->last()->value); } @@ -51,6 +51,6 @@ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginato */ public static function getAll(): \Illuminate\Database\Eloquent\Collection { - return ProductsModel::all(); + return Product::all(); } } diff --git a/app/Queries/SalesQueries.php b/app/Queries/SaleQueries.php similarity index 74% rename from app/Queries/SalesQueries.php rename to app/Queries/SaleQueries.php index b3e85f0..bf0233b 100644 --- a/app/Queries/SalesQueries.php +++ b/app/Queries/SaleQueries.php @@ -2,15 +2,15 @@ namespace App\Queries; -use App\Models\SalesModel; -use App\Models\SettingsModel; +use App\Models\Sale; +use App\Models\Setting; /** * Class SalesQueries * * Query class for handling operations related to the SalesModel. */ -class SalesQueries +class SaleQueries { /** * Get the count of all sales. @@ -19,7 +19,7 @@ class SalesQueries */ public static function countAll(): int { - return SalesModel::count(); + return Sale::count(); } /** @@ -29,7 +29,7 @@ public static function countAll(): int */ public static function getSalesSortedByCreatedAt(): \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Collection { - return SalesModel::all()->sortBy('created_at'); + return Sale::all()->sortBy('created_at'); } /** @@ -39,8 +39,8 @@ public static function getSalesSortedByCreatedAt(): \Illuminate\Support\Collecti */ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginator { - return SalesModel::orderByDesc('id') - ->paginate(SettingsModel::where('key', 'pagination_size') + return Sale::orderByDesc('id') + ->paginate(Setting::where('key', 'pagination_size') ->get()->last()->value); } } diff --git a/app/Queries/SettingsQueries.php b/app/Queries/SettingQueries.php similarity index 58% rename from app/Queries/SettingsQueries.php rename to app/Queries/SettingQueries.php index d3ee0bb..5ba05ac 100644 --- a/app/Queries/SettingsQueries.php +++ b/app/Queries/SettingQueries.php @@ -2,14 +2,14 @@ namespace App\Queries; -use App\Models\SettingsModel; +use App\Models\Setting; /** * Class SettingsQueries * * Query class for handling operations related to the SettingsModel. */ -class SettingsQueries +class SettingQueries { /** * Get all settings. @@ -18,16 +18,11 @@ class SettingsQueries */ public static function getAll(): \Illuminate\Database\Eloquent\Collection { - return SettingsModel::all(); - } - - public static function getByKey(string $key) - { - return SettingsModel::where('key', $key)->get()->last(); + return Setting::all(); } public static function getSettingValue(string $key) { - return SettingsModel::where('key', $key)->get()->last()->value; + return Setting::where('key', $key)->get()->last()->value; } } diff --git a/app/Queries/SystemLogsQueries.php b/app/Queries/SystemLogQueries.php similarity index 74% rename from app/Queries/SystemLogsQueries.php rename to app/Queries/SystemLogQueries.php index de7b8fc..5c69f7f 100644 --- a/app/Queries/SystemLogsQueries.php +++ b/app/Queries/SystemLogQueries.php @@ -2,15 +2,15 @@ namespace App\Queries; -use App\Models\SettingsModel; -use App\Models\SystemLogsModel; +use App\Models\Setting; +use App\Models\SystemLog; /** * Class SystemLogsQueries * * Query class for handling operations related to the SystemLogsModel. */ -class SystemLogsQueries +class SystemLogQueries { /** * Get the count of all system logs. @@ -19,7 +19,7 @@ class SystemLogsQueries */ public static function countAll(): int { - return SystemLogsModel::count(); + return SystemLog::count(); } /** @@ -29,7 +29,7 @@ public static function countAll(): int */ public static function getAll(): \Illuminate\Database\Eloquent\Collection { - return SystemLogsModel::all(); + return SystemLog::all(); } /** @@ -39,7 +39,7 @@ public static function getAll(): \Illuminate\Database\Eloquent\Collection */ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginator { - return SystemLogsModel::paginate(SettingsModel::where('key', 'pagination_size') + return SystemLog::paginate(Setting::where('key', 'pagination_size') ->get()->last()->value); } } diff --git a/app/Queries/TasksQueries.php b/app/Queries/TaskQueries.php similarity index 73% rename from app/Queries/TasksQueries.php rename to app/Queries/TaskQueries.php index 7c776bf..4780d81 100644 --- a/app/Queries/TasksQueries.php +++ b/app/Queries/TaskQueries.php @@ -2,8 +2,8 @@ namespace App\Queries; -use App\Models\SettingsModel; -use App\Models\TasksModel; +use App\Models\Setting; +use App\Models\Task; use Illuminate\Support\Collection; /** @@ -11,7 +11,7 @@ * * Query class for handling operations related to the TasksModel. */ -class TasksQueries +class TaskQueries { /** * Get paginated list of tasks. @@ -20,8 +20,8 @@ class TasksQueries */ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginator { - return TasksModel::orderByDesc('id') - ->paginate(SettingsModel::where('key', 'pagination_size') + return Task::orderByDesc('id') + ->paginate(Setting::where('key', 'pagination_size') ->get()->last()->value); } @@ -32,7 +32,7 @@ public static function getPaginate(): \Illuminate\Pagination\LengthAwarePaginato */ public static function countAll(): int { - return TasksModel::count(); + return Task::count(); } /** @@ -42,7 +42,7 @@ public static function countAll(): int */ public static function getCountCompleted(): int { - return TasksModel::where('completed', '=', 1) + return Task::where('completed', '=', 1) ->count(); } @@ -53,7 +53,7 @@ public static function getCountCompleted(): int */ public static function getAllUncompletedTasks(): int { - return TasksModel::where('completed', '=', 0) + return Task::where('completed', '=', 0) ->count(); } @@ -65,7 +65,7 @@ public static function getAllUncompletedTasks(): int */ public static function getEmployeesTaskCount(mixed $id): int { - return TasksModel::where('employee_id', $id)->get()->count(); + return Task::where('employee_id', $id)->get()->count(); } /** @@ -75,6 +75,6 @@ public static function getEmployeesTaskCount(mixed $id): int */ public static function getAllForFormat(): \Illuminate\Support\Collection { - return TasksModel::all()->sortBy('created_at', 0, true)->slice(0, 5); + return Task::all()->sortBy('created_at', 0, true)->slice(0, 5); } } diff --git a/app/Relations/Belongs/BelongsToClient.php b/app/Relations/Belongs/BelongsToClient.php index 7ed512f..6b58409 100644 --- a/app/Relations/Belongs/BelongsToClient.php +++ b/app/Relations/Belongs/BelongsToClient.php @@ -2,7 +2,7 @@ namespace App\Relations\Belongs; -use App\Models\ClientsModel; +use App\Models\Client; trait BelongsToClient { @@ -11,6 +11,6 @@ trait BelongsToClient */ public function client() { - return $this->belongsTo(ClientsModel::class); + return $this->belongsTo(Client::class); } } diff --git a/app/Relations/Belongs/BelongsToCompany.php b/app/Relations/Belongs/BelongsToCompany.php index 9848211..441c817 100644 --- a/app/Relations/Belongs/BelongsToCompany.php +++ b/app/Relations/Belongs/BelongsToCompany.php @@ -3,7 +3,7 @@ namespace App\Relations\Belongs; -use App\Models\CompaniesModel; +use App\Models\Company; trait BelongsToCompany { @@ -12,6 +12,6 @@ trait BelongsToCompany */ public function company() { - return $this->belongsTo(CompaniesModel::class); + return $this->belongsTo(Company::class); } } diff --git a/app/Relations/Belongs/BelongsToDeal.php b/app/Relations/Belongs/BelongsToDeal.php index d56bed9..dab382a 100644 --- a/app/Relations/Belongs/BelongsToDeal.php +++ b/app/Relations/Belongs/BelongsToDeal.php @@ -2,7 +2,7 @@ namespace App\Relations\Belongs; -use App\Models\DealsModel; +use App\Models\Deal; trait BelongsToDeal { @@ -11,6 +11,6 @@ trait BelongsToDeal */ public function deal() { - return $this->belongsTo(DealsModel::class); + return $this->belongsTo(Deal::class); } } diff --git a/app/Relations/Belongs/BelongsToEmployee.php b/app/Relations/Belongs/BelongsToEmployee.php index a59d0b9..f6d8b7c 100644 --- a/app/Relations/Belongs/BelongsToEmployee.php +++ b/app/Relations/Belongs/BelongsToEmployee.php @@ -2,7 +2,7 @@ namespace App\Relations\Belongs; -use App\Models\EmployeesModel; +use App\Models\Employee; trait BelongsToEmployee { @@ -11,6 +11,6 @@ trait BelongsToEmployee */ public function employee() { - return $this->belongsTo(EmployeesModel::class); + return $this->belongsTo(Employee::class); } } diff --git a/app/Relations/Belongs/BelongsToProduct.php b/app/Relations/Belongs/BelongsToProduct.php index bc0188a..cd038a6 100644 --- a/app/Relations/Belongs/BelongsToProduct.php +++ b/app/Relations/Belongs/BelongsToProduct.php @@ -2,7 +2,7 @@ namespace App\Relations\Belongs; -use App\Models\ProductsModel; +use App\Models\Product; trait BelongsToProduct { @@ -11,6 +11,6 @@ trait BelongsToProduct */ public function product() { - return $this->belongsTo(ProductsModel::class, 'product_id'); + return $this->belongsTo(Product::class, 'product_id'); } } diff --git a/app/Relations/Has/HasManyCompanies.php b/app/Relations/Has/HasManyCompanies.php index 4ee478a..ea3e813 100644 --- a/app/Relations/Has/HasManyCompanies.php +++ b/app/Relations/Has/HasManyCompanies.php @@ -2,13 +2,13 @@ namespace App\Relations\Has; -use App\Models\CompaniesModel; +use App\Models\Company; use Illuminate\Database\Eloquent\Relations\HasMany; trait HasManyCompanies { public function companies(): HasMany { - return $this->hasMany(CompaniesModel::class, 'client_id'); + return $this->hasMany(Company::class, 'client_id'); } } diff --git a/app/Relations/Has/HasManyDealTerms.php b/app/Relations/Has/HasManyDealTerms.php index a3fd964..98e014c 100644 --- a/app/Relations/Has/HasManyDealTerms.php +++ b/app/Relations/Has/HasManyDealTerms.php @@ -2,7 +2,7 @@ namespace App\Relations\Has; -use App\Models\DealsTermsModel; +use App\Models\DealTerm; use Illuminate\Database\Eloquent\Relations\HasMany; trait HasManyDealTerms @@ -12,6 +12,6 @@ trait HasManyDealTerms */ public function dealTerms(): HasMany { - return $this->hasMany(DealsTermsModel::class, 'deal_id'); + return $this->hasMany(DealTerm::class, 'deal_id'); } } diff --git a/app/Relations/Has/HasManyDeals.php b/app/Relations/Has/HasManyDeals.php index 1376ffd..516a33c 100644 --- a/app/Relations/Has/HasManyDeals.php +++ b/app/Relations/Has/HasManyDeals.php @@ -3,7 +3,7 @@ namespace App\Relations\Has; -use App\Models\DealsModel; +use App\Models\Deal; use Illuminate\Database\Eloquent\Relations\HasMany; trait HasManyDeals @@ -13,6 +13,6 @@ trait HasManyDeals */ public function deals(): HasMany { - return $this->hasMany(DealsModel::class, 'id'); + return $this->hasMany(Deal::class, 'id'); } } diff --git a/app/Relations/Has/HasManyEmployees.php b/app/Relations/Has/HasManyEmployees.php index c7464d3..2f9e8ba 100644 --- a/app/Relations/Has/HasManyEmployees.php +++ b/app/Relations/Has/HasManyEmployees.php @@ -3,7 +3,7 @@ namespace App\Relations\Has; -use App\Models\EmployeesModel; +use App\Models\Employee; use Illuminate\Database\Eloquent\Relations\HasMany; trait HasManyEmployees @@ -13,6 +13,6 @@ trait HasManyEmployees */ public function employees(): HasMany { - return $this->hasMany(EmployeesModel::class, 'client_id'); + return $this->hasMany(Employee::class, 'client_id'); } } diff --git a/app/Relations/Has/HasManyFinances.php b/app/Relations/Has/HasManyFinances.php index dd6e9b3..17e6f5b 100644 --- a/app/Relations/Has/HasManyFinances.php +++ b/app/Relations/Has/HasManyFinances.php @@ -3,8 +3,8 @@ namespace App\Relations\Has; -use App\Models\EmployeesModel; -use App\Models\FinancesModel; +use App\Models\Employee; +use App\Models\Finance; use Illuminate\Database\Eloquent\Relations\HasMany; trait HasManyFinances @@ -14,6 +14,6 @@ trait HasManyFinances */ public function finances(): HasMany { - return $this->hasMany(FinancesModel::class); + return $this->hasMany(Finance::class); } } diff --git a/app/Relations/Has/HasManySales.php b/app/Relations/Has/HasManySales.php index 29d05d2..cd6175d 100644 --- a/app/Relations/Has/HasManySales.php +++ b/app/Relations/Has/HasManySales.php @@ -2,7 +2,7 @@ namespace App\Relations\Has; -use App\Models\SalesModel; +use App\Models\Sale; use Illuminate\Database\Eloquent\Relations\HasMany; trait HasManySales @@ -10,6 +10,6 @@ trait HasManySales public function sales(): HasMany { - return $this->hasMany(SalesModel::class, 'product_id'); + return $this->hasMany(Sale::class, 'product_id'); } } diff --git a/app/Relations/Has/HasManyTasks.php b/app/Relations/Has/HasManyTasks.php index 412550d..d57b1b8 100644 --- a/app/Relations/Has/HasManyTasks.php +++ b/app/Relations/Has/HasManyTasks.php @@ -2,7 +2,7 @@ namespace App\Relations\Has; -use App\Models\TasksModel; +use App\Models\Task; use Illuminate\Database\Eloquent\Relations\HasMany; trait HasManyTasks @@ -10,6 +10,6 @@ trait HasManyTasks public function tasks(): HasMany { - return $this->hasMany(TasksModel::class, 'employee_id'); + return $this->hasMany(Task::class, 'employee_id'); } } diff --git a/app/Services/CalculateCashService.php b/app/Services/CalculateCashService.php index a59a359..01c3dde 100644 --- a/app/Services/CalculateCashService.php +++ b/app/Services/CalculateCashService.php @@ -2,11 +2,11 @@ namespace App\Services; -use App\Models\FinancesModel; -use App\Models\ProductsModel; -use App\Models\SalesModel; -use App\Models\TasksModel; -use App\Queries\SettingsQueries; +use App\Models\Finance; +use App\Models\Product; +use App\Models\Sale; +use App\Models\Task; +use App\Queries\SettingQueries; use Carbon\Carbon; use Cknow\Money\Money; use Illuminate\Support\Facades\DB; @@ -18,9 +18,9 @@ class CalculateCashService */ public function loadCountCashTurnover(): mixed { - $products = ProductsModel::all(); - $sales = SalesModel::all(); - $finances = FinancesModel::all(); + $products = Product::all(); + $sales = Sale::all(); + $finances = Finance::all(); $productSum = 0; $salesSum = 0; @@ -40,7 +40,7 @@ public function loadCountCashTurnover(): mixed $officialSum = $productSum + $salesSum + $financesSum; - return Money::{SettingsQueries::getSettingValue('currency')}($officialSum); + return Money::{SettingQueries::getSettingValue('currency')}($officialSum); } /** @@ -48,9 +48,9 @@ public function loadCountCashTurnover(): mixed */ public function loadCountTodayIncome(): mixed { - $products = ProductsModel::whereDate('created_at', Carbon::today())->get(); - $sales = SalesModel::whereDate('created_at', Carbon::today())->get(); - $finances = FinancesModel::whereDate('created_at', Carbon::today())->get(); + $products = Product::whereDate('created_at', Carbon::today())->get(); + $sales = Sale::whereDate('created_at', Carbon::today())->get(); + $finances = Finance::whereDate('created_at', Carbon::today())->get(); $productSum = 0; $salesSum = 0; $financesSum = 0; @@ -68,7 +68,7 @@ public function loadCountTodayIncome(): mixed $todayIncome = $productSum + $salesSum + $financesSum; - return Money::{SettingsQueries::getSettingValue('currency')}($todayIncome); + return Money::{SettingQueries::getSettingValue('currency')}($todayIncome); } /** @@ -76,9 +76,9 @@ public function loadCountTodayIncome(): mixed */ public function loadCountYesterdayIncome(): mixed { - $products = ProductsModel::whereDate('created_at', Carbon::yesterday())->get(); - $sales = SalesModel::whereDate('created_at', Carbon::yesterday())->get(); - $finances = FinancesModel::whereDate('created_at', Carbon::yesterday())->get(); + $products = Product::whereDate('created_at', Carbon::yesterday())->get(); + $sales = Sale::whereDate('created_at', Carbon::yesterday())->get(); + $finances = Finance::whereDate('created_at', Carbon::yesterday())->get(); $salesSum = 0; $productSum = 0; $financesSum = 0; @@ -95,7 +95,7 @@ public function loadCountYesterdayIncome(): mixed $yesterdayIncome = $productSum + $salesSum + $financesSum; - return Money::{SettingsQueries::getSettingValue('currency')}($yesterdayIncome); + return Money::{SettingQueries::getSettingValue('currency')}($yesterdayIncome); } /** @@ -124,7 +124,7 @@ public function loadTaskEveryMonth($isCompleted) { } if($isCompleted) { - $posts = TasksModel::where( 'created_at', '>=', $dates->keys()->first() )->where('completed', '=', 1) + $posts = Task::where( 'created_at', '>=', $dates->keys()->first() )->where('completed', '=', 1) ->groupBy( 'date' ) ->orderBy( 'date' ) ->get( [ @@ -133,7 +133,7 @@ public function loadTaskEveryMonth($isCompleted) { ] ) ->pluck( 'count', 'date' ); } else { - $posts = TasksModel::where( 'created_at', '>=', $dates->keys()->first() ) + $posts = Task::where( 'created_at', '>=', $dates->keys()->first() ) ->groupBy( 'date' ) ->orderBy( 'date' ) ->get( [ diff --git a/app/Services/ClientService.php b/app/Services/ClientService.php index f72e114..8ef2a56 100644 --- a/app/Services/ClientService.php +++ b/app/Services/ClientService.php @@ -2,9 +2,9 @@ namespace App\Services; -use App\Models\ClientsModel; -use App\Queries\ClientsQueries; -use App\Queries\SettingsQueries; +use App\Models\Client; +use App\Queries\ClientQueries; +use App\Queries\SettingQueries; use App\Traits\Language; use Cknow\Money\Money; @@ -20,12 +20,12 @@ class ClientService /** * Load details of a specific client. * - * @param ClientsModel $client - * @return ClientsModel + * @param Client $client + * @return Client */ - public function loadClientDetails(ClientsModel $client): ClientsModel + public function loadClientDetails(Client $client): Client { - $client->formattedBudget = Money::{SettingsQueries::getSettingValue('currency')}($client->budget); + $client->formattedBudget = Money::{SettingQueries::getSettingValue('currency')}($client->budget); return $client; } @@ -37,9 +37,9 @@ public function loadClientDetails(ClientsModel $client): ClientsModel */ public function loadClientsInLatestMonth(): float { - $clientsCountInLatestMonth = ClientsQueries::getCountAllInLatestMonth(); + $clientsCountInLatestMonth = ClientQueries::getCountAllInLatestMonth(); - $allClientCount = ClientsQueries::getCountAll(); + $allClientCount = ClientQueries::getCountAll(); return ($allClientCount / 100) * $clientsCountInLatestMonth; } diff --git a/app/Services/CompaniesService.php b/app/Services/CompaniesService.php index 7a2d558..577a117 100644 --- a/app/Services/CompaniesService.php +++ b/app/Services/CompaniesService.php @@ -2,7 +2,7 @@ namespace App\Services; -use App\Queries\CompaniesQueries; +use App\Queries\CompanyQueries; /** * Class CompaniesService @@ -18,7 +18,7 @@ class CompaniesService */ public function loadCompaniesByCreatedAt(): \Illuminate\Support\Collection { - return CompaniesQueries::getCompaniesSortedByCreatedAt(); + return CompanyQueries::getCompaniesSortedByCreatedAt(); } /** @@ -28,8 +28,8 @@ public function loadCompaniesByCreatedAt(): \Illuminate\Support\Collection */ public function loadCompaniesInLatestMonth(): float { - $companiesCount = CompaniesQueries::getCompaniesInLatestMonth(); - $allCompanies = CompaniesQueries::countAll(); + $companiesCount = CompanyQueries::getCompaniesInLatestMonth(); + $allCompanies = CompanyQueries::countAll(); return ($allCompanies / 100) * $companiesCount; } diff --git a/app/Services/DealsService.php b/app/Services/DealsService.php index 0730ec7..c62f4ed 100644 --- a/app/Services/DealsService.php +++ b/app/Services/DealsService.php @@ -2,9 +2,9 @@ namespace App\Services; -use App\Models\DealsModel; -use App\Models\DealsTermsModel; -use App\Queries\DealsQueries; +use App\Models\Deal; +use App\Models\DealTerm; +use App\Queries\DealQueries; use Barryvdh\DomPDF\Facade\Pdf; /** @@ -21,8 +21,8 @@ class DealsService */ public function loadDealsInLatestMonth(): int { - $dealsInLatestMonth = DealsQueries::getDealsInLatestMonth(); - $allDeals = DealsQueries::countAll(); + $dealsInLatestMonth = DealQueries::getDealsInLatestMonth(); + $allDeals = DealQueries::countAll(); return ($allDeals / 100) * count($dealsInLatestMonth); } @@ -30,11 +30,11 @@ public function loadDealsInLatestMonth(): int /** * Generate a PDF of deal terms. * - * @param DealsTermsModel $dealTerm The deal terms to be included in the PDF. - * @param DealsModel $deal The deal associated with the terms. + * @param DealTerm $dealTerm The deal terms to be included in the PDF. + * @param Deal $deal The deal associated with the terms. * @return \Illuminate\Http\Response */ - public function loadGenerateDealTermsInPDF(DealsTermsModel $dealTerm, DealsModel $deal): \Illuminate\Http\Response + public function loadGenerateDealTermsInPDF(DealTerm $dealTerm, Deal $deal): \Illuminate\Http\Response { $data = [ 'body' => $dealTerm->body diff --git a/app/Services/EmployeesService.php b/app/Services/EmployeesService.php index 9daf79f..f7d2d0a 100644 --- a/app/Services/EmployeesService.php +++ b/app/Services/EmployeesService.php @@ -2,9 +2,9 @@ namespace App\Services; -use App\Models\EmployeesModel; -use App\Queries\EmployeesQueries; -use App\Queries\TasksQueries; +use App\Models\Employee; +use App\Queries\EmployeeQueries; +use App\Queries\TaskQueries; use Illuminate\Support\Arr; /** @@ -20,10 +20,10 @@ class EmployeesService */ public function loadEmployees(): \Illuminate\Support\Collection { - $employees = EmployeesModel::orderBy('created_at')->get(); + $employees = Employee::orderBy('created_at')->get(); foreach($employees as $key => $employee) { - Arr::add($employees[$key], 'taskCount', TasksQueries::getEmployeesTaskCount($employee->id)); + Arr::add($employees[$key], 'taskCount', TaskQueries::getEmployeesTaskCount($employee->id)); } return $employees; @@ -36,8 +36,8 @@ public function loadEmployees(): \Illuminate\Support\Collection */ public function loadEmployeesInLatestMonth(): int { - $employeesCountInLatestMonth = EmployeesQueries::getEmployeesInLatestMonth(); - $allEmployees = EmployeesQueries::countAll(); + $employeesCountInLatestMonth = EmployeeQueries::getEmployeesInLatestMonth(); + $allEmployees = EmployeeQueries::countAll(); return ($allEmployees / 100) * $employeesCountInLatestMonth; } diff --git a/app/Services/GraphDataService.php b/app/Services/GraphDataService.php index 55a8b3d..78f5ac5 100644 --- a/app/Services/GraphDataService.php +++ b/app/Services/GraphDataService.php @@ -2,10 +2,10 @@ namespace App\Services; -use App\Queries\DealsQueries; -use App\Queries\FinancesQueries; -use App\Queries\ProductsQueries; -use App\Queries\SalesQueries; +use App\Queries\DealQueries; +use App\Queries\FinanceQueries; +use App\Queries\ProductQueries; +use App\Queries\SaleQueries; class GraphDataService { @@ -59,22 +59,22 @@ public function itemsCountGraphData(): mixed [ "label" => "Products", 'backgroundColor' => ['rgba(227, 67, 51, 1)', 'rgba(54, 162, 235, 0.2)'], - 'data' => [ProductsQueries::countAll()] + 'data' => [ProductQueries::countAll()] ], [ "label" => "Sales", 'backgroundColor' => ['rgba(228, 115, 45, 1)', 'rgba(54, 162, 235, 0.3)'], - 'data' => [SalesQueries::countAll()] + 'data' => [SaleQueries::countAll()] ], [ "label" => "Finances", 'backgroundColor' => ['rgba(249, 195, 100, 1)', 'rgba(54, 162, 235, 0.3)'], - 'data' => [FinancesQueries::countAll()] + 'data' => [FinanceQueries::countAll()] ], [ "label" => "Deal", 'backgroundColor' => ['rgba(92, 141, 93, 1)', 'rgba(54, 162, 235, 0.3)'], - 'data' => [DealsQueries::countAll()] + 'data' => [DealQueries::countAll()] ] ]) ->options([]); diff --git a/app/Services/TasksService.php b/app/Services/TasksService.php index 5a20053..0f44d5f 100644 --- a/app/Services/TasksService.php +++ b/app/Services/TasksService.php @@ -2,7 +2,7 @@ namespace App\Services; -use App\Queries\TasksQueries; +use App\Queries\TaskQueries; /** * Class TasksService @@ -18,8 +18,8 @@ class TasksService */ public function loadCompletedTasks(): string { - $countCompletedTasks = TasksQueries::getCountCompleted(); - $countAllTasks = TasksQueries::countAll(); + $countCompletedTasks = TaskQueries::getCountCompleted(); + $countAllTasks = TaskQueries::countAll(); $percentage = round(($countCompletedTasks / $countAllTasks) * 100); @@ -33,8 +33,8 @@ public function loadCompletedTasks(): string */ public function loadUncompletedTasks(): string { - $uncompletedTasksCount = TasksQueries::getAllUncompletedTasks(); - $countAllTasks = TasksQueries::countAll(); + $uncompletedTasksCount = TaskQueries::getAllUncompletedTasks(); + $countAllTasks = TaskQueries::countAll(); $percentage = round(($uncompletedTasksCount / $countAllTasks) * 100); @@ -48,7 +48,7 @@ public function loadUncompletedTasks(): string */ public function formatTasks(): array { - $tasks = TasksQueries::getAllForFormat(); + $tasks = TaskQueries::getAllForFormat(); $arrayWithFormattedTasks = []; diff --git a/config/auth.php b/config/auth.php index 5856733..a8406c2 100644 --- a/config/auth.php +++ b/config/auth.php @@ -62,7 +62,7 @@ 'providers' => [ 'users' => [ 'driver' => 'eloquent', - 'model' => env('AUTH_MODEL', App\Models\AdminModel::class), + 'model' => env('AUTH_MODEL', App\Models\Administrator::class), ], // 'users' => [ diff --git a/resources/views/crm/clients/index.blade.php b/resources/views/crm/clients/index.blade.php index 4cde709..8cf8e0b 100644 --- a/resources/views/crm/clients/index.blade.php +++ b/resources/views/crm/clients/index.blade.php @@ -18,7 +18,8 @@

Client lists

- @@ -49,33 +50,39 @@ {{ $client->email }} {{ $client->section }} -
@csrf
- + More info - + Edit -
+ @csrf @method('DELETE') -
diff --git a/resources/views/crm/finances/show.blade.php b/resources/views/crm/finances/show.blade.php index cdbfda6..747f2d5 100644 --- a/resources/views/crm/finances/show.blade.php +++ b/resources/views/crm/finances/show.blade.php @@ -21,7 +21,8 @@
@csrf @method('DELETE') -
@@ -33,7 +34,9 @@
  • - + Basic information
  • @@ -67,8 +70,9 @@ Gross - @@ -76,8 +80,9 @@ Net - @@ -85,8 +90,9 @@ Vat - diff --git a/resources/views/crm/products/index.blade.php b/resources/views/crm/products/index.blade.php index 32ebf83..6238579 100644 --- a/resources/views/crm/products/index.blade.php +++ b/resources/views/crm/products/index.blade.php @@ -18,7 +18,8 @@

    Product lists

    - @@ -47,8 +48,9 @@ {{ $product->category }} {{ $product->count }} - @@ -56,25 +58,31 @@
    @csrf
    - + More info - + Edit -
    + @csrf @method('DELETE') -
    diff --git a/resources/views/crm/products/show.blade.php b/resources/views/crm/products/show.blade.php index 5e0ff42..355683a 100644 --- a/resources/views/crm/products/show.blade.php +++ b/resources/views/crm/products/show.blade.php @@ -21,7 +21,8 @@
    @csrf @method('DELETE') -
    @@ -33,7 +34,9 @@
    diff --git a/resources/views/crm/sales/index.blade.php b/resources/views/crm/sales/index.blade.php index ff193d6..7658d83 100644 --- a/resources/views/crm/sales/index.blade.php +++ b/resources/views/crm/sales/index.blade.php @@ -18,7 +18,8 @@

    Sale lists

    - @@ -47,8 +48,9 @@ {{ $sale->name }} {{ $sale->quantity }} - @@ -59,25 +61,29 @@
    @csrf
    - + More info - + Edit
    @csrf @method('DELETE') -
    diff --git a/routes/web.php b/routes/web.php index 9f1dd9b..d880e5c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -31,9 +31,9 @@ Route::post('password/reset/process', [AuthController::class, 'processChangePassword'])->name('password.reset.process'); Route::get('/', [DashboardController::class, 'index'])->name('home'); -Route::get('/reload-info', [DashboardController::class, 'processReloadInformation'])->name('reload.info'); +Route::get('/reload-info', [DashboardController::class, 'processReloadInformation'])->name('reload.info')->middleware('auth'); -Route::group(['prefix' => 'clients'], function () { +Route::group(['prefix' => 'clients', 'middleware' => 'auth'], function () { Route::get('/', [ClientController::class, 'processListOfClients'])->name('clients.index'); Route::get('create', [ClientController::class, 'processRenderCreateForm'])->name('clients.create.form'); Route::get('update/{client}', [ClientController::class, 'processRenderUpdateForm'])->name('clients.update.form'); @@ -44,7 +44,7 @@ Route::post('set-active/{client}', [ClientController::class, 'processClientSetIsActive'])->name('clients.set.active'); }); -Route::group(['prefix' => 'companies'], function () { +Route::group(['prefix' => 'companies', 'middleware' => 'auth'], function () { Route::get('/', [CompaniesController::class, 'processListOfCompanies'])->name('companies.index'); Route::get('create', [CompaniesController::class, 'processRenderCreateForm'])->name('companies.create.form'); Route::get('update/{company}', [CompaniesController::class, 'processRenderUpdateForm'])->name('companies.update.form'); @@ -55,7 +55,7 @@ Route::post('set-active/{company}', [CompaniesController::class, 'processCompanySetIsActive'])->name('companies.set.active'); }); -Route::group(['prefix' => 'deals'], function () { +Route::group(['prefix' => 'deals', 'middleware' => 'auth'], function () { Route::get('/', [DealsController::class, 'processListOfDeals'])->name('deals.index'); Route::get('create', [DealsController::class, 'processRenderCreateForm'])->name('deals.create.form'); Route::get('update/{deal}', [DealsController::class, 'processRenderUpdateForm'])->name('deals.update.form'); @@ -70,7 +70,7 @@ Route::post('terms/{dealTerm}/generate-pdf/{deal}', [DealsController::class, 'processGenerateDealTermsInPDF'])->name('deals.terms.generate-pdf'); }); -Route::group(['prefix' => 'employees'], function () { +Route::group(['prefix' => 'employees', 'middleware' => 'auth'], function () { Route::get('/', [EmployeesController::class, 'processListOfEmployees'])->name('employees.index'); Route::get('create', [EmployeesController::class, 'processRenderCreateForm'])->name('employees.create.form'); Route::get('update/{employee}', [EmployeesController::class, 'processRenderUpdateForm'])->name('employees.update.form'); @@ -81,7 +81,7 @@ Route::post('set-active/{employee}', [EmployeesController::class, 'processEmployeeSetIsActive'])->name('employees.set.active'); }); -Route::group(['prefix' => 'tasks'], function () { +Route::group(['prefix' => 'tasks', 'middleware' => 'auth'], function () { Route::get('/', [TasksController::class, 'processListOfTasks'])->name('tasks.index'); Route::get('create', [TasksController::class, 'processRenderCreateForm'])->name('tasks.create.form'); Route::get('update/{task}', [TasksController::class, 'processRenderUpdateForm'])->name('tasks.update.form'); @@ -93,7 +93,7 @@ Route::patch('completed/{task}', [TasksController::class, 'processSetTaskToCompleted'])->name('tasks.complete'); }); -Route::group(['prefix' => 'sales'], function () { +Route::group(['prefix' => 'sales', 'middleware' => 'auth'], function () { Route::get('/', [SalesController::class, 'processListOfSales'])->name('sales.index'); Route::get('create', [SalesController::class, 'processRenderCreateForm'])->name('sales.create.form'); Route::get('update/{sale}', [SalesController::class, 'processRenderUpdateForm'])->name('sales.update.form'); @@ -105,7 +105,7 @@ }); -Route::group(['prefix' => 'products'], function () { +Route::group(['prefix' => 'products', 'middleware' => 'auth'], function () { Route::get('/', [ProductsController::class, 'processListOfProducts'])->name('products.index'); Route::get('create', [ProductsController::class, 'processRenderCreateForm'])->name('products.create.form'); Route::get('update/{product}', [ProductsController::class, 'processRenderUpdateForm'])->name('products.update.form'); @@ -116,7 +116,7 @@ Route::post('set-active/{product}', [ProductsController::class, 'processProductSetIsActive'])->name('products.set.active'); }); -Route::group(['prefix' => 'finances'], function () { +Route::group(['prefix' => 'finances', 'middleware' => 'auth'], function () { Route::get('/', [FinancesController::class, 'processListOfFinances'])->name('finances.index'); Route::get('create', [FinancesController::class, 'processRenderCreateForm'])->name('finances.create.form'); Route::get('update/{finance}', [FinancesController::class, 'processRenderUpdateForm'])->name('finances.update.form'); @@ -127,7 +127,7 @@ Route::post('set-active/{finance}', [FinancesController::class, 'processFinanceSetIsActive'])->name('finances.set.active'); }); -Route::group(['prefix' => 'settings'], function () { +Route::group(['prefix' => 'settings', 'middleware' => 'auth'], function () { Route::get('/', [SettingsController::class, 'processListOfSettings'])->name('settings.index'); Route::put('update', [SettingsController::class, 'processUpdateSettings'])->name('settings.update'); });