Browse Source

update delete & fillable

pull/1/head
wahyun 9 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\Support\Facades\{Artisan,DB};
use App\Helpers\MasterFunctionsHelper;
use Carbon\Carbon;
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();
$data = Project::find($id);
$dateNow = Carbon::now();
if ($data) {
$this->deleteRelative($id, $company_id);
if ($data->delete()) {
// $this->deleteRelative($id, $company_id);
// if ($data->delete()) {
if ($data->update(['deleted_at' => $dateNow, 'deleted_by_id' => $this->currentId])) {
DB::commit();
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
} else {

4
app/Models/Project.php

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

Loading…
Cancel
Save