fix api
This commit is contained in:
@@ -30,7 +30,7 @@ class AuthController extends Controller
|
||||
|
||||
if ($validator->fails()) {
|
||||
$errors = [
|
||||
'success' => "error",
|
||||
'success' => false,
|
||||
'message' => $validator->errors()
|
||||
];
|
||||
return response($errors, 201);
|
||||
@@ -73,7 +73,7 @@ class AuthController extends Controller
|
||||
|
||||
$token = $user->createToken('myapptoken')->plainTextToken;
|
||||
$response = [
|
||||
'success' => "success",
|
||||
'success' => true,
|
||||
'user' => $user,
|
||||
'token' => $token
|
||||
];
|
||||
|
||||
@@ -66,13 +66,24 @@ class LelongMobileController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function getListKarat(Request $request){
|
||||
public function getListKarat()
|
||||
{
|
||||
|
||||
$getKarat = LelKarat::all();
|
||||
|
||||
// $lelongBidder = lelongBidder::all();
|
||||
|
||||
return response()->json($getKarat);
|
||||
$activeLelong = Lelong::where('sts_lelong', '=', 1)->first();
|
||||
if (isset($activeLelong)) {
|
||||
$getKarat = LelKarat::where('lelong_id', '=' ,$activeLelong['id'])->get();
|
||||
|
||||
$updatedDateTime = $getKarat[0]['updated_at']->toDateTimeString();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'karat' => $getKarat,
|
||||
'update_time' => $updatedDateTime
|
||||
], 201);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
], 201);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -315,7 +326,6 @@ class LelongMobileController extends Controller
|
||||
|
||||
public function listSuratLelong(Request $request)
|
||||
{
|
||||
|
||||
$currentdate = Carbon::now();
|
||||
$currentdate = $currentdate->toDateString();
|
||||
|
||||
@@ -323,10 +333,10 @@ class LelongMobileController extends Controller
|
||||
->where('tarikh_lelong', '=', $currentdate)
|
||||
->where('caw_id', '=', $request->caw_id)
|
||||
->where('status_online', '=', 1)
|
||||
->get()->toArray();
|
||||
->first();
|
||||
|
||||
foreach ($lelong as $index1 => $lel) {
|
||||
$lelongbid = LelongBid::where('lelong_id', $lel['lelong_id'])
|
||||
if ($lelong) {
|
||||
$lelongbid = LelongBid::where('lelong_id', $lelong['lelong_id'])
|
||||
->where('caw_id', '=', $request->caw_id)
|
||||
->select('id', 'kodcaw')
|
||||
->get();
|
||||
@@ -350,21 +360,23 @@ class LelongMobileController extends Controller
|
||||
$listLelong = [];
|
||||
foreach ($arrayDiff2 as $index => $data) {
|
||||
|
||||
$lelongbid = LelongBid::where('id', $data)->first()->toArray();
|
||||
$lelongbid = LelongBid::
|
||||
// join('filemarhun', 'lelongbid.id', '=', 'filemarhun.lelongbid_id')
|
||||
where('id', $data)
|
||||
// ->where('photo_type', 1)
|
||||
->first()->toArray();
|
||||
$lelongbidmarhun = LelongBidMarhun::where('lelongbid_id', $lelongbid['id'])->get()->toArray();
|
||||
foreach ($lelongbidmarhun as $index1 => $marhun) {
|
||||
$marhunDesc = JenisEmas::where('marhun', $marhun['marhun'])->first()->toArray();
|
||||
$lelongbidmarhun[$index1]['marhun_desc'] = $marhunDesc['descpt'];
|
||||
}
|
||||
|
||||
|
||||
$lelongbid['lelongbidmarhun'] = $lelongbidmarhun;
|
||||
|
||||
array_push($listLelong, $lelongbid);
|
||||
$lelong[$index1]['lelongbid'] = $listLelong;
|
||||
}
|
||||
}
|
||||
$lelong['lelongbid'] = $listLelong;
|
||||
|
||||
if ($lelong) {
|
||||
return response()->json(
|
||||
['success' => true, 'message' => $lelong],
|
||||
201
|
||||
@@ -700,8 +712,8 @@ class LelongMobileController extends Controller
|
||||
$currentdate = $currentdate->toDateString();
|
||||
|
||||
$lelong = Lelong::join('cawangan_lelong', 'lelong.id', '=', 'cawangan_lelong.lelong_id')
|
||||
->join('cawangan', 'cawangan_lelong.caw_id', '=', 'cawangan.id')
|
||||
->where('tarikh_lelong', '=', $currentdate)
|
||||
->join('cawangan', 'cawangan_lelong.caw_id', '=', 'cawangan.id')
|
||||
->where('tarikh_lelong', '=', $currentdate)
|
||||
->select(
|
||||
'lelong.id as lelong_id',
|
||||
'lelong.tarikh_lelong',
|
||||
@@ -710,12 +722,11 @@ class LelongMobileController extends Controller
|
||||
'cawangan_lelong.masamula_lelong',
|
||||
'cawangan_lelong.masatamat_lelong',
|
||||
)
|
||||
->get()->toArray();
|
||||
|
||||
if ($lelong) {
|
||||
->get();
|
||||
if ($lelong->isNotEmpty()) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'lelong' => $lelong
|
||||
'lelong' => $lelong,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
|
||||
@@ -47,4 +47,8 @@ class LelongBid extends Model
|
||||
public function cawanganLelong(){
|
||||
return $this->hasOne(CawanganLelong::class, 'caw_id','caw_id');
|
||||
}
|
||||
|
||||
public function fileMarhunMain() {
|
||||
return $this->hasOne(FileMarhun::class, 'lelongbidmarhun_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user