7bc405060c
Build Docker Image / build-backend (push) Successful in 22s
Co-authored-by: ISMAIL MASSERAN <topaz@ISMAILs-Macbook.local> Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local> Co-authored-by: afrina <afrina@koppkb.com> Reviewed-on: #11
53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Cawangan;
|
|
use App\Feature;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CawanganController extends Controller
|
|
{
|
|
|
|
public function showAllCawangans()
|
|
{
|
|
return response()->json(Cawangan::on('mysql7')->get());
|
|
}
|
|
|
|
public function showOneCawangan($code_cawangan)
|
|
{
|
|
$cawangan = Cawangan::on('mysql7')
|
|
->where('kodcaw','=',$code_cawangan)
|
|
->first();
|
|
|
|
if (!$cawangan) {
|
|
return response()->json($cawangan);
|
|
}
|
|
|
|
$data = $cawangan->toArray();
|
|
$data['features'] = Feature::mapFor($code_cawangan);
|
|
|
|
return response()->json($data);
|
|
}
|
|
|
|
public function create(Request $request)
|
|
{
|
|
$cawangan = Cawangan::create($request->all());
|
|
|
|
return response()->json($cawangan, 201);
|
|
}
|
|
|
|
public function update($id, Request $request)
|
|
{
|
|
$cawangan = Cawangan::findOrFail($id);
|
|
$cawangan->update($request->all());
|
|
|
|
return response()->json($cawangan, 200);
|
|
}
|
|
|
|
public function delete($id)
|
|
{
|
|
Cawangan::findOrFail($id)->delete();
|
|
return response('Deleted Successfully', 200);
|
|
}
|
|
} |