update
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\User;
|
||||
use PDF;
|
||||
use App\Models\Cawangan;
|
||||
use App\Models\JenisEmas;
|
||||
use App\Models\JenisKarat;
|
||||
|
||||
use App\Models\Simulasi;
|
||||
use App\Models\SimulasiBid;
|
||||
use App\Models\SimulasiBidMarhun;
|
||||
use App\Models\SimKarat;
|
||||
use App\Models\SimKarat_temp;
|
||||
use App\Models\CawanganSimulasi;
|
||||
|
||||
|
||||
use App\Models\Lelong;
|
||||
use App\Models\CawanganLelong;
|
||||
use App\Models\LelongBid;
|
||||
use App\Models\LelongBidMarhun;
|
||||
use App\Models\LelKarat;
|
||||
use App\Models\LelKarat_temp;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
|
||||
public function biditem()
|
||||
{
|
||||
$currentdate = Carbon::now();
|
||||
$currentdate = $currentdate->toDateString();
|
||||
// dd($currentdate->toDateString());
|
||||
$lelong = Lelong::where('tarikh_lelong','=',$currentdate)->get();
|
||||
|
||||
$arrayID = [];
|
||||
foreach($lelong as $data)
|
||||
{
|
||||
array_push($arrayID,$data->id);
|
||||
}
|
||||
$lelongbid = LelongBid::whereIn('lelong_id',$arrayID)
|
||||
->join('lelongbidmarhun','lelongbid.id','=','lelongbidmarhun.lelongbid_id')
|
||||
->get();
|
||||
|
||||
$surat = LelongBid::whereIn('lelong_id',$arrayID)->get();
|
||||
|
||||
if(sizeof($lelongbid)!=0)
|
||||
{
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'lelong' => $lelong,
|
||||
'surat' => $surat,
|
||||
'item' => $lelongbid
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'No Data',
|
||||
], 401);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -335,14 +335,19 @@ class LelongController extends Controller
|
||||
{
|
||||
$lelong = Lelong::where('id','=',$id)->first();
|
||||
$lelong->masatamat_lelong = '2021-12-20 04:51:50';
|
||||
$lelong->sts_lelong = 1;
|
||||
$lelong->save();
|
||||
|
||||
return redirect()->route('lelong.senarailelong')
|
||||
->with('success','Lelongan bermula');
|
||||
}
|
||||
|
||||
public function refresh()
|
||||
public function refresh($id)
|
||||
{
|
||||
$lelong = Lelong::where('id','=',$id)->first();
|
||||
$lelong->masakemaskini_data = '2021-12-20 04:51:50';
|
||||
$lelong->save();
|
||||
|
||||
return redirect()->route('lelong.senarailelong')
|
||||
->with('success','Kemaskini Berjaya');
|
||||
}
|
||||
|
||||
@@ -65,8 +65,6 @@ class SimulasiController extends Controller
|
||||
->where('taglel','=',0)
|
||||
->where('lelong_tawarruq','=',1)
|
||||
->get();
|
||||
|
||||
|
||||
|
||||
$cawangan = Cawangan::all();
|
||||
// dd($cawangan);
|
||||
@@ -164,7 +162,7 @@ class SimulasiController extends Controller
|
||||
$simmarhun->berat = $marhun->berat;
|
||||
$simmarhun->harga = $karat->harga;
|
||||
$simmarhun->n_marhun = $marhun->berat * $karat->harga;
|
||||
$simmarhun->hargaasas = floatval(number_format($val,2));
|
||||
$simmarhun->hargaasas = $val;
|
||||
$simmarhun->save();
|
||||
}
|
||||
}
|
||||
@@ -185,10 +183,10 @@ class SimulasiController extends Controller
|
||||
}
|
||||
elseif($request->caw && $request->caw != 'all')
|
||||
{
|
||||
$caw = $cawangan->where('id','=',$request->caw)->first();
|
||||
$caw = Cawangan::where('id','=',$request->caw)->first();
|
||||
$caw_simulasi = new CawanganSimulasi;
|
||||
$caw_simulasi->simulasi_id = $simulasi->id;
|
||||
$caw_simulasi->caw_id = $request->caw;
|
||||
$caw_simulasi->caw_id = $caw->id;
|
||||
$caw_simulasi->online = 'Online';
|
||||
$caw_simulasi->lokasi = $caw->lokasi;
|
||||
$caw_simulasi->save();
|
||||
@@ -199,7 +197,7 @@ class SimulasiController extends Controller
|
||||
{
|
||||
$simulasibid = new SimulasiBid;
|
||||
$simulasibid->simulasi_id = $simulasi->id;
|
||||
$simulasibid->caw_id = $caw_simulasi->id;
|
||||
$simulasibid->caw_id = $caw->id;
|
||||
$simulasibid->kodcaw = $data->kodcaw;
|
||||
$simulasibid->norujukan = $data->norujukan;
|
||||
$simulasibid->t_lelong = $t_lelong;
|
||||
@@ -242,6 +240,7 @@ class SimulasiController extends Controller
|
||||
$berat = $berat + $marhun->berat;
|
||||
|
||||
$simmarhun = new SimulasiBidMarhun;
|
||||
$simmarhun->simulasibid_id = $simulasibid->id;
|
||||
$simmarhun->bil = $marhun->bil;
|
||||
$simmarhun->marhun = $marhun->marhun;
|
||||
$simmarhun->nota = $marhun->nota;
|
||||
@@ -249,7 +248,7 @@ class SimulasiController extends Controller
|
||||
$simmarhun->berat = $marhun->berat;
|
||||
$simmarhun->harga = $karat->harga;
|
||||
$simmarhun->n_marhun = $marhun->berat * $karat->harga;
|
||||
$simmarhun->hargaasas = floatval(number_format($val,2));
|
||||
$simmarhun->hargaasas = $val;
|
||||
$simmarhun->save();
|
||||
}
|
||||
}
|
||||
@@ -272,8 +271,6 @@ class SimulasiController extends Controller
|
||||
dd('error');
|
||||
}
|
||||
|
||||
|
||||
|
||||
return redirect()->route('analisa.show',$simulasi->id);
|
||||
}
|
||||
|
||||
@@ -320,7 +317,7 @@ class SimulasiController extends Controller
|
||||
foreach($cawangansim as $cawsim)
|
||||
{
|
||||
$cawangan = Cawangan::where('id','=',$cawsim->caw_id)->first();
|
||||
$databid = SimulasiBid::where('caw_id','=',$cawsim->caw_id)->get();
|
||||
$databid = SimulasiBid::where('simulasi_id','=',$simulasi_id)->get();
|
||||
|
||||
$packet = 0;
|
||||
$berat = 0;
|
||||
|
||||
@@ -18,5 +18,6 @@ class Lelong extends Model
|
||||
'harga_emas_asas',
|
||||
'jbg',
|
||||
'cajlelong',
|
||||
'sts_lelong'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ return [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
'api' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|
||||
@@ -23,6 +23,7 @@ class CreateLelongsTable extends Migration
|
||||
$table->string('harga_emas_asas');
|
||||
$table->string('jbg');
|
||||
$table->integer('cajlelong');
|
||||
$table->integer('sts_lelong')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<td>{{ $lel->cajlelong }}</td>
|
||||
<td class="text-center">
|
||||
@hasrole('jurulelong')
|
||||
<a href="{{ route('lelong.refresh') }}"><i class="fas fa-sync-alt"></i></a>
|
||||
<a href="{{ route('lelong.refresh',$lel->id) }}"><i class="fas fa-sync-alt"></i></a>
|
||||
@if(!$lel->masatamat_lelong)
|
||||
<a class="startlelong" href="{{ route('lelong.start',$lel->id) }}"><i class="fa fa-play"></i></a>
|
||||
@else
|
||||
|
||||
+42
-1
@@ -15,5 +15,46 @@ use Illuminate\Support\Facades\Route;
|
||||
*/
|
||||
|
||||
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
// dd();
|
||||
return response()->json($request->user());
|
||||
});
|
||||
|
||||
Route::post('/login', function (Request $request) {
|
||||
$request->validate([
|
||||
'username' => 'required|string',
|
||||
'password' => 'required|string',
|
||||
]);
|
||||
|
||||
$credentials = $request->only('username', 'password');
|
||||
|
||||
|
||||
if (Auth::guard('api')->attempt($credentials,true)) {
|
||||
$auth_user = Auth::guard('api')->user();
|
||||
|
||||
// dd($auth_user);
|
||||
$user_login['name'] = $auth_user['name'];
|
||||
$user_login['username'] = $auth_user['username'];
|
||||
$user_login['password'] = $auth_user['password'];
|
||||
$user_login['icno'] = $auth_user['nokp'];
|
||||
$user_login['apitoken'] = $auth_user['remember_token'];
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'user' => $user_login
|
||||
]);
|
||||
} else {
|
||||
//if authentication is unsuccessfull, notice how I return json parameters
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid Email or Password',
|
||||
], 401);
|
||||
}
|
||||
});
|
||||
|
||||
Route::get('/item','ApiController@biditem');
|
||||
|
||||
// Route::get('/item',['as'=>'lelong.biditem','uses'=>'LelongController@biditem']);
|
||||
// Route::get('/lelongstop/{id}',['as'=>'lelong.stop','uses'=>'LelongController@stop']);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ Route::group(['prefix'=>'lelong'], function () {
|
||||
});
|
||||
|
||||
Route::group(['middleware' => ['permission:import']], function () {
|
||||
Route::get('/refresh',['as'=>'lelong.refresh','uses'=>'LelongController@refresh']);
|
||||
Route::get('/refresh/{id}',['as'=>'lelong.refresh','uses'=>'LelongController@refresh']);
|
||||
});
|
||||
|
||||
Route::group(['middleware' => ['permission:kemaskinihargaasas']], function () {
|
||||
|
||||
Reference in New Issue
Block a user