Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/hrms.ncriptech.com/app/Services/Task/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php namespace App\Services\Task; use App\Models\Management\Notes; use App\Services\Core\BaseService; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use App\Models\TaskManagement\TaskNote; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Facades\Validator; use App\Helpers\CoreApp\Traits\DateHandler; use App\Helpers\CoreApp\Traits\CurrencyTrait; use App\Helpers\CoreApp\Traits\ApiReturnFormatTrait; use App\Helpers\CoreApp\Traits\InvoiceGenerateTrait; use App\Models\coreApp\Relationship\RelationshipTrait; class TaskNoteService extends BaseService { use RelationshipTrait, DateHandler, InvoiceGenerateTrait, CurrencyTrait, ApiReturnFormatTrait; public function __construct(TaskNote $notes) { $this->model = $notes; } // store the public function store($request) { $validator = Validator::make(\request()->all(), [ 'description' => 'required', ]); if ($validator->fails()) { return $this->responseWithError(_trans('Description field is required'), 'id', 404); } DB::beginTransaction(); try { $task = DB::table('tasks')->where('id', $request->task_id)->first(); if (!$task) { return $this->responseWithError(_trans('message.Task not found'), [], 400); } $data = [ 'company_id' => getCurrentCompany(), 'branch_id' => getCurrentBranch(), 'task_id' => $request->task_id, 'description' => $request->description, 'user_id' => auth()->user()->id, 'show_to_customer' => @$request->show_to_customer == 1 ? 33 : 22, 'last_activity' => date('Y-m-d H:i:s'), ]; $note = $this->model->create($data); \App\Models\TaskManagement\TaskActivity::CreateActivityLog(getCurrentCompany(), $request->task_id, auth()->id(), 'Created Notes', getCurrentBranch())->save(); DB::commit(); return $this->responseWithSuccess(_trans('message.Note created successfully.'), $note); } catch (\Throwable $th) { DB::rollBack(); return $this->responseExceptionError($th->getMessage(), [], 400); } } function update($request, $id) { $validator = Validator::make(\request()->all(), [ 'description' => 'required', ]); if ($validator->fails()) { return $this->responseWithError(_trans('message.Description field is required'), 'id', 404); } DB::beginTransaction(); try { $note = $this->model->where(['id' => $id, 'company_id' => getCurrentCompany(), 'branch_id' => getCurrentBranch()])->first(); if (!$note) { return $this->responseWithError(_trans('message.Note not found'), 'id', 404); } $note->description = $request->description; // $note->show_to_customer = @$request->show_to_customer == 1 ? 33 : 22; $note->last_activity = date('Y-m-d H:i:s', time()); $note->save(); \App\Models\TaskManagement\TaskActivity::CreateActivityLog(getCurrentCompany(), $note->task_id, auth()->id(), 'Updated Notes', getCurrentBranch())->save(); DB::commit(); return $this->responseWithSuccess(_trans('message.Note Updated successfully.'), $note); } catch (\Throwable $th) { DB::rollBack(); return $this->responseWithError($th->getMessage(), [], 400); } } function delete($id) { $note = $this->model->where(['id' => $id, 'company_id' => getCurrentCompany(), 'branch_id' => getCurrentBranch()])->first(); if (!$note) { return $this->responseWithError(_trans('message.Note not found'), 'id', 404); } try { \App\Models\TaskManagement\TaskActivity::CreateActivityLog(getCurrentCompany(), $note->task_id, auth()->id(), 'Deleted Notes', getCurrentBranch())->save(); $note->delete(); return $this->responseWithSuccess(_trans('message.Note Delete successfully.'), $note); } catch (\Throwable $th) { return $this->responseExceptionError($th->getMessage(), [], 400); } } }