add api for all gadai by customer

This commit is contained in:
Zakwan Hamdan
2020-10-27 11:37:36 +08:00
parent 6cdce10db1
commit cf3555e593
4 changed files with 30 additions and 4 deletions
+20 -2
View File
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Gadai;
use App\Cawangan;
use Illuminate\Http\Request;
class GadaiController extends Controller
@@ -13,9 +14,26 @@ class GadaiController extends Controller
return response()->json(Gadai::all());
}
public function showOneGadai($id)
public function gadaiTransactionByCawanganAndDay($cawangan_code,$date){
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$cawangan_code)->first();
$gadaiTransaction = Gadai::on($cawangan['mysql'])->where('t_gadai','=',$date)->get();
return response()->json($gadaiTransaction);
}
public function showOneGadai($noic)
{
return response()->json(Gadai::find($id));
$cawangan_all = Cawangan::on('mysql7')->get();
$gadai_all = [];
foreach($cawangan_all as $index=>$cawangan){
$gadai = Gadai::on($cawangan['mysql'])->where('nokp','=',$noic)->get();
if(sizeof($gadai) != 0){
array_push($gadai_all,$gadai);
}
}
return response()->json($gadai_all);
}
public function create(Request $request)