diff --git a/app/Entities/Projects/ProjectPresenter.php b/app/Entities/Projects/ProjectPresenter.php index 0d47c60..fbd3e9f 100644 --- a/app/Entities/Projects/ProjectPresenter.php +++ b/app/Entities/Projects/ProjectPresenter.php @@ -3,6 +3,7 @@ namespace App\Entities\Projects; use Laracasts\Presenter\Presenter; +use ProjectStatus; class ProjectPresenter extends Presenter { @@ -18,7 +19,7 @@ class ProjectPresenter extends Presenter public function status() { - return getProjectStatusesList($this->entity->status_id); + return ProjectStatus::getNameById($this->entity->status_id); } public function workDuration() diff --git a/app/Entities/Projects/ProjectsRepository.php b/app/Entities/Projects/ProjectsRepository.php index cf7419c..4066797 100755 --- a/app/Entities/Projects/ProjectsRepository.php +++ b/app/Entities/Projects/ProjectsRepository.php @@ -5,6 +5,7 @@ namespace App\Entities\Projects; use App\Entities\BaseRepository; use App\Entities\Partners\Customer; use DB; +use ProjectStatus; /** * Projects Repository Class @@ -20,7 +21,7 @@ class ProjectsRepository extends BaseRepository public function getProjects($q, $statusId) { - $statusIds = array_keys(getProjectStatusesList()); + $statusIds = array_keys(ProjectStatus::toArray()); return $this->model->latest() ->where(function ($query) use ($q, $statusId, $statusIds) { @@ -41,7 +42,7 @@ class ProjectsRepository extends BaseRepository DB::beginTransaction(); if (isset($projectData['customer_id']) == false || $projectData['customer_id'] == '') { - $customer = $this->createNewCustomer($projectData['customer_name'], $projectData['customer_email']); + $customer = $this->createNewCustomer($projectData['customer_name'], $projectData['customer_email']); $projectData['customer_id'] = $customer->id; } unset($projectData['customer_name']); @@ -59,9 +60,9 @@ class ProjectsRepository extends BaseRepository public function createNewCustomer($customerName, $customerEmail) { - $newCustomer = new Customer; - $newCustomer->name = $customerName; - $newCustomer->email = $customerEmail; + $newCustomer = new Customer; + $newCustomer->name = $customerName; + $newCustomer->email = $customerEmail; $newCustomer->save(); return $newCustomer; @@ -103,7 +104,7 @@ class ProjectsRepository extends BaseRepository public function updateStatus($statusId, $projectId) { - $project = $this->requireById($projectId); + $project = $this->requireById($projectId); $project->status_id = $statusId; $project->save(); @@ -114,7 +115,7 @@ class ProjectsRepository extends BaseRepository { $featureOrder = explode(',', $sortedData); foreach ($featureOrder as $order => $featureId) { - $feature = $this->requireFeatureById($featureId); + $feature = $this->requireFeatureById($featureId); $feature->position = $order + 1; $feature->save(); } diff --git a/app/Http/Controllers/Projects/ProjectsController.php b/app/Http/Controllers/Projects/ProjectsController.php index 503a521..84e7a33 100755 --- a/app/Http/Controllers/Projects/ProjectsController.php +++ b/app/Http/Controllers/Projects/ProjectsController.php @@ -52,9 +52,8 @@ class ProjectsController extends Controller public function edit($projectId) { $project = $this->repo->requireById($projectId); - $statuses = getProjectStatusesList(); $customers = $this->repo->getCustomersList(); - return view('projects.edit', compact('project', 'statuses', 'customers')); + return view('projects.edit', compact('project', 'customers')); } public function update(UpdateRequest $request, $projectId) diff --git a/app/helpers.php b/app/helpers.php index f4e72e6..f2c9702 100755 --- a/app/helpers.php +++ b/app/helpers.php @@ -194,21 +194,6 @@ function html_link_to_route($name, $title = null, $parameters = [], $attributes return app('html')->decode(link_to_route($name, $title, $parameters, $attributes)); } -function getProjectStatusesList($statusId = null) -{ - $statuses = [1 => 'Planned', 'On Progress', 'Done', 'Closed', 'Canceled', 'On Hold']; - - if (is_null($statusId)) { - return $statuses; - } - - if (array_key_exists($statusId, $statuses)) { - return $statuses[$statusId]; - } - - return null; -} - function dateDifference($date1, $date2, $differenceFormat = '%a') { $datetime1 = date_create($date1); diff --git a/config/app.php b/config/app.php index 38033dd..8045828 100644 --- a/config/app.php +++ b/config/app.php @@ -215,6 +215,7 @@ return [ // Reference Facades 'PaymentType' => App\Entities\Payments\Type::class, 'SubscriptionType' => App\Entities\Subscriptions\Type::class, + 'ProjectStatus' => App\Entities\Projects\Status::class, ], ]; diff --git a/resources/views/projects/edit.blade.php b/resources/views/projects/edit.blade.php index 58a93ca..cc35319 100755 --- a/resources/views/projects/edit.blade.php +++ b/resources/views/projects/edit.blade.php @@ -35,7 +35,7 @@