Skip to content

Commit

Permalink
Merge pull request #43 from kamgrzeski/release_v_1_0_3
Browse files Browse the repository at this point in the history
chore: release 1.0.3
  • Loading branch information
kamgrzeski authored Oct 17, 2024
2 parents 9563560 + 68b4ca1 commit b83ec0e
Show file tree
Hide file tree
Showing 168 changed files with 4,163 additions and 39,879 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/CRM/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function processShowClientDetails(ClientsModel $client): \Illuminate\View
public function processRenderUpdateForm(ClientsModel $client): \Illuminate\View\View
{
// Return the view for updating the client record.
return view('crm.clients.edit')->with(['client' => $this->clientService->loadClientDetails($client)]);
return view('crm.clients.update')->with(['client' => $this->clientService->loadClientDetails($client)]);
}

/**
Expand Down Expand Up @@ -116,7 +116,7 @@ public function processUpdateClient(ClientUpdateRequest $request, ClientsModel $
$this->dispatchSync(new UpdateClientJob($request->validated(), $client));

// Redirect to the clients page with a success message.
return redirect()->back()->with('message_success', $this->getMessage('messages.client_update'));
return redirect()->to('clients')->with('message_success', $this->getMessage('messages.client_update'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/CRM/CompaniesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function processListOfCompanies(): \Illuminate\View\View
public function processRenderUpdateForm(CompaniesModel $company): \Illuminate\View\View
{
// Return view with company and clients
return view('crm.companies.edit')->with([
return view('crm.companies.update')->with([
'company' => $company,
'clients' => ClientsQueries::getAll()
]);
Expand Down
11 changes: 8 additions & 3 deletions app/Http/Controllers/CRM/DealsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function processListOfDeals(): \Illuminate\View\View
public function processRenderUpdateForm(DealsModel $deal): \Illuminate\View\View
{
// Load the deal record for editing.
return view('crm.deals.edit')->with([
return view('crm.deals.update')->with([
'deal' => $deal,
'companies' => CompaniesQueries::getAll(),
]);
Expand Down Expand Up @@ -163,7 +163,7 @@ public function processDeleteDeal(DealsModel $deal): \Illuminate\Http\RedirectRe
public function processSetIsActive(DealsModel $deal): \Illuminate\Http\RedirectResponse
{
// Update the deal status.
$this->dispatchSync(new UpdateDealJob(['is_active' => $deal->is_active], $deal));
$this->dispatchSync(new UpdateDealJob(['is_active' => ! $deal->is_active], $deal));

// Log the action.
$this->dispatchSync(new StoreSystemLogJob('Deals has been enabled with id: ' . $deal->id, 201, auth()->user()));
Expand All @@ -189,7 +189,7 @@ public function processStoreDealTerms(StoreDealTermRequest $request, DealsModel
$this->dispatchSync(new StoreSystemLogJob('Deals terms has been added.', 201, auth()->user()));

// Redirect back with a success message.
return redirect()->back()->with('message_success', $this->getMessage('messages.deal_term_store'));
return redirect()->route('deals.view', $deal)->with('message_success', $this->getMessage('messages.deal_term_store'));
}

/**
Expand Down Expand Up @@ -223,4 +223,9 @@ public function processDeleteDealTerm(DealsTermsModel $dealTerm): \Illuminate\Ht
// Redirect back with a success message.
return redirect()->back()->with('message_success', $this->getMessage('messages.deal_term_delete'));
}

public function processRenderTermCreateForm(DealsModel $deal)
{
return view('crm.deals.terms.create')->with(['deal' => $deal]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/CRM/EmployeesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function processListOfEmployees(): \Illuminate\View\View
public function processRenderUpdateForm(EmployeesModel $employee): \Illuminate\View\View
{
// Load the employee record details and the clients data to be used in the form.
return view('crm.employees.edit')->with([
return view('crm.employees.update')->with([
'employee' => $employee,
'clients' => ClientsQueries::getAll()
]);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/CRM/FinancesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public function processListOfFinances()
public function processRenderUpdateForm(FinancesModel $finance)
{
// Return the view with the finance record and the companies.
return view('crm.finances.edit')->with([
return view('crm.finances.update')->with([
'finance' => $finance,
'companies' => CompaniesQueries::getAll(true)
'companies' => CompaniesQueries::getAll()
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/CRM/ProductsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function processShowProductsDetails(ProductsModel $product): \Illuminate\
public function processRenderUpdateForm(ProductsModel $product): \Illuminate\View\View
{
// Load the product details and render the update form.
return view('crm.products.edit')->with(['product' => $product]);
return view('crm.products.update')->with(['product' => $product]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/CRM/SalesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function processShowSalesDetails(SalesModel $sale): \Illuminate\View\View
public function processRenderUpdateForm(SalesModel $sale): \Illuminate\View\View
{
// Load the sale record details and the products data to be used in the form.
return view('crm.sales.edit')->with([
return view('crm.sales.update')->with([
'sale' => $sale,
'products' => ProductsQueries::getAll()
]);
Expand Down
11 changes: 4 additions & 7 deletions app/Http/Controllers/CRM/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use App\Jobs\UpdateSettingsJob;
use App\Queries\SettingsQueries;
use App\Queries\SystemLogsQueries;
use App\Services\SettingsService;
use Illuminate\Foundation\Bus\DispatchesJobs;

/**
Expand All @@ -20,18 +19,13 @@ class SettingsController extends Controller
{
use DispatchesJobs;

private SettingsService $settingsService;

/**
* SettingsController constructor.
*
* @param SettingsService $settingsService
*/
public function __construct(SettingsService $settingsService)
public function __construct()
{
$this->middleware(self::MIDDLEWARE_AUTH);

$this->settingsService = $settingsService;
}

/**
Expand Down Expand Up @@ -65,6 +59,9 @@ public function processUpdateSettings(SettingsStoreRequest $request): \Illuminat
// Dispatch the StoreSystemLogJob to store the system log
$this->dispatchSync(new StoreSystemLogJob('SettingsModel has been changed.', 201, auth()->user()));

//forgot cache of loading circle
cache()->forget('loadingCircle');

// Redirect back with a success message
return redirect()->back()->with('message_success', $this->getMessage('messages.settings_update'));
}
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/CRM/TasksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(EmployeesService $employeesService)
public function processRenderCreateForm(): \Illuminate\View\View
{
// Load the employees for the task.
return view('crm.tasks.create')->with(['employees' => $this->employeesService->loadEmployees(true)]);
return view('crm.tasks.create')->with(['employees' => $this->employeesService->loadEmployees()]);
}

/**
Expand Down Expand Up @@ -77,7 +77,7 @@ public function processShowTasksDetails(TasksModel $task): \Illuminate\View\View
public function processRenderUpdateForm(TasksModel $task): \Illuminate\View\View
{
// Load the task record for editing.
return view('crm.tasks.edit')->with([
return view('crm.tasks.update')->with([
'task' => $task,
'employees' => $this->employeesService->loadEmployees()
]);
Expand Down Expand Up @@ -153,7 +153,7 @@ public function processDeleteTask(TasksModel $task): \Illuminate\Http\RedirectRe
public function processTaskSetIsActive(TasksModel $task): \Illuminate\Http\RedirectResponse
{
// Update the task status.
$this->dispatchSync(new UpdateTaskJob(['is_active' => $task->is_active], $task));
$this->dispatchSync(new UpdateTaskJob(['is_active' => ! $task->is_active], $task));

// Log the task status change.
$this->dispatchSync(new StoreSystemLogJob('Tasks has been enabled with id: ' . $task->id, 201, auth()->user()));
Expand Down
23 changes: 16 additions & 7 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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\Services\CalculateCashService;
Expand All @@ -17,7 +18,6 @@
use App\Services\DealsService;
use App\Services\EmployeesService;
use App\Services\GraphDataService;
use App\Services\SettingsService;
use App\Services\TasksService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Cache;
Expand All @@ -31,7 +31,6 @@ class DashboardController extends Controller
private EmployeesService $employeesService;
private DealsService $dealsService;
private TasksService $tasksService;
private SettingsService $settingsService;

public function __construct()
{
Expand All @@ -43,7 +42,6 @@ public function __construct()
$this->employeesService = new EmployeesService();
$this->dealsService = new DealsService();
$this->tasksService = new TasksService();
$this->settingsService = new SettingsService();
}

/**
Expand All @@ -61,10 +59,10 @@ public function index(): \Illuminate\View\View
[
'tasksGraphData' => $graph->taskGraphData(),
'itemsCountGraphData' => $graph->itemsCountGraphData(),
'dataWithAllTasks' => $this->tasksService->formatTasks(),
'dataWithAllCompanies' => $this->companiesService->loadCompaniesByCreatedAt(),
'dataWithAllProducts' => ProductsQueries::getProductsByCreatedAt(),
'currency' => $this->settingsService->loadSettingValue(self::CURRENCY)
'tasks' => $this->tasksService->formatTasks(),
'companies' => $this->companiesService->loadCompaniesByCreatedAt()->take(10),
'products' => ProductsQueries::getProductsByCreatedAt()->take(10),
'currency' => SettingsQueries::getSettingValue(self::CURRENCY)
]
);
}
Expand Down Expand Up @@ -99,6 +97,17 @@ private function storeInCacheUsableVariables(): void
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'));

// currency
Cache::put('currency', SettingsQueries::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'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/DealStoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function rules()
'name' => 'required|string',
'start_time' => 'required',
'end_time' => 'required',
'companies_id' => 'required|integer',
'company_id' => 'required|integer',
];
}
}
2 changes: 1 addition & 1 deletion app/Http/Requests/DealUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function rules()
'name' => 'required|string',
'start_time' => 'required',
'end_time' => 'required',
'companies_id' => 'required|integer',
'company_id' => 'required|integer',
];
}
}
2 changes: 1 addition & 1 deletion app/Http/Requests/FinanceStoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function rules()
{
return [
'name' => 'required|string',
'companies_id' => 'required|integer',
'company_id' => 'required|integer',
'description' => 'required|string',
'type' => 'required|string',
'gross' => 'required|string',
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/FinanceUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function rules()
{
return [
'name' => 'required|string',
'companies_id' => 'required|integer',
'company_id' => 'required|integer',
'description' => 'required|string',
'type' => 'required|string',
'gross' => 'required|string',
Expand Down
1 change: 0 additions & 1 deletion app/Jobs/StoreSystemLogJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs;

use App\Models\AdminModel;
use App\Models\SystemLogsModel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Auth\Authenticatable;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/DealsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DealsModel extends Model
{
use SoftDeletes, BelongsToCompany, HasManyDealTerms;

protected $fillable = ['name', 'companies_id', 'is_active'];
protected $fillable = ['name', 'company_id', 'is_active'];

protected $table = 'deals';
protected $dates = ['deleted_at'];
Expand Down
3 changes: 1 addition & 2 deletions app/Models/EmployeesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class EmployeesModel extends Model
use SoftDeletes, HasManyCompanies, BelongsToDeal, BelongsToClient, HasManyTasks;

protected $fillable = [
'first_name',
'last_name',
'full_name',
'email',
'phone',
'company_id',
Expand Down
3 changes: 2 additions & 1 deletion app/Models/FinancesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class FinancesModel extends Model
use SoftDeletes, BelongsToCompany;

protected $fillable = [
'companies_id',
'name',
'company_id',
'gross',
'net',
'vat',
Expand Down
5 changes: 0 additions & 5 deletions app/Models/SettingsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,4 @@
class SettingsModel extends Model
{
protected $table = 'settings';

public static function getSettingValue(string $key)
{
return self::where('key', $key)->get()->last()?->value;
}
}
6 changes: 1 addition & 5 deletions app/Queries/CompaniesQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ class CompaniesQueries
/**
* Get all companies.
*
* @param bool $createForm Whether to return companies in a format suitable for form creation.
* @return \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Collection
*/
public static function getAll(bool $createForm = false): \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Collection
public static function getAll(): \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Collection
{
if($createForm) {
return CompaniesModel::pluck('name', 'id');
}
return CompaniesModel::all()->sortBy('created_at');
}

Expand Down
10 changes: 10 additions & 0 deletions app/Queries/SettingsQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ public static function getAll(): \Illuminate\Database\Eloquent\Collection
{
return SettingsModel::all();
}

public static function getByKey(string $key)
{
return SettingsModel::where('key', $key)->get()->last();
}

public static function getSettingValue(string $key)
{
return SettingsModel::where('key', $key)->get()->last()->value;
}
}
2 changes: 1 addition & 1 deletion app/Relations/Has/HasManySales.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ trait HasManySales

public function sales(): HasMany
{
return $this->hasMany(SalesModel::class);
return $this->hasMany(SalesModel::class, 'product_id');
}
}
Loading

0 comments on commit b83ec0e

Please sign in to comment.