Browse Source

update delete & fillable

pull/1/head
wahyun 7 months ago
parent
commit
fb96003fd1
  1. 7
      app/Http/Controllers/ProjectController.php
  2. 4
      app/Models/Project.php

7
app/Http/Controllers/ProjectController.php

@ -13,6 +13,7 @@ use App\Models\{ReportActivityMaterial,ProjectToChecklistK3,FolderDocumentProyek
use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\{Artisan,DB}; use Illuminate\Support\Facades\{Artisan,DB};
use App\Helpers\MasterFunctionsHelper; use App\Helpers\MasterFunctionsHelper;
use Carbon\Carbon;
const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1"; const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1";
@ -178,9 +179,11 @@ class ProjectController extends Controller
{ {
DB::beginTransaction(); DB::beginTransaction();
$data = Project::find($id); $data = Project::find($id);
$dateNow = Carbon::now();
if ($data) { if ($data) {
$this->deleteRelative($id, $company_id); // $this->deleteRelative($id, $company_id);
if ($data->delete()) { // if ($data->delete()) {
if ($data->update(['deleted_at' => $dateNow, 'deleted_by_id' => $this->currentId])) {
DB::commit(); DB::commit();
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200); return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
} else { } else {

4
app/Models/Project.php

@ -52,6 +52,8 @@ class Project extends Model
'updated_at', 'updated_at',
'updated_by', 'updated_by',
'created_by_id', 'created_by_id',
'company_id' 'company_id',
'deleted_at',
'deleted_by_id'
]; ];
} }

Loading…
Cancel
Save