You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
68 lines
1.9 KiB
<?php |
|
|
|
namespace App\Http\Controllers; |
|
|
|
use Illuminate\Http\Request; |
|
use App\Models\ProjectCharter; |
|
|
|
class ProjectCharterController extends Controller |
|
{ |
|
public function add(Request $request) |
|
{ |
|
|
|
$data = $request->all(); |
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
$result = ProjectCharter::create($data); |
|
|
|
if($result){ |
|
return response()->json(['status'=>'success','message'=>'add data project charter successfully!','code'=>200], 200); |
|
}else{ |
|
return response()->json(['status'=>'failed','message'=>'add data project charter failed!','code'=>400], 400); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
public function update(Request $request, $id) |
|
{ |
|
if(!$id || (int) $id < 0 || $id==""){ |
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
} |
|
|
|
$data = ProjectCharter::find($id); |
|
|
|
if($data){ |
|
$result = $data->update($request->all()); |
|
}else{ |
|
return response()->json(['status'=>'failed','message'=>'data project not found!','code'=>400], 400); |
|
die(); |
|
} |
|
|
|
|
|
if($result){ |
|
return response()->json(['status'=>'success','message'=>'data project successfully updated!','code'=>200], 200); |
|
}else{ |
|
return response()->json(['status'=>'failed','message'=>'data project failed updated!','code'=>400], 400); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function search(Request $request) |
|
{ |
|
$payload = $request->all(); |
|
$dataBuilder = $this->setUpPayload($payload, 'project_charter'); |
|
$builder = $dataBuilder['builder']; |
|
$countBuilder = $dataBuilder['count']; |
|
$dataGet = $builder->get(); |
|
$totalRecord = $countBuilder->count(); |
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
|
} |
|
|
|
|
|
}
|
|
|