function logsession
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\LogSession;
|
||||
use App\Cawangan;
|
||||
use App\Logsession as AppLogsession;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class LogController extends Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function logSession($kodcaw, Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
|
||||
$logsession = Logsession::on('mysql7')->where('kodcaw', '=', $kodcaw)
|
||||
->create([
|
||||
'nama' => $request->nama,
|
||||
'nokp' => $request->nokp,
|
||||
'kodcaw' => $request->kodcaw,
|
||||
'email' => $request->email,
|
||||
'taraf' => $request->taraf,
|
||||
|
||||
]);
|
||||
|
||||
|
||||
return response()->json($logsession);
|
||||
}
|
||||
|
||||
public function checkNokpSession($kodcaw, $nokp, $tarikh)
|
||||
{
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
||||
|
||||
$checknokp = Logsession::on('mysql7')->where('kodcaw', '=', $kodcaw)
|
||||
->where('nokp', '=', $nokp)
|
||||
->where('created_at','LIKE',"%{$tarikh}%")
|
||||
->get();
|
||||
|
||||
if (sizeof($checknokp) != 0) {
|
||||
$newnokp = $nokp;
|
||||
} else {
|
||||
|
||||
$newnokp = 'NULL';
|
||||
}
|
||||
return response()->json($newnokp);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Logsession extends Model
|
||||
{
|
||||
protected $table = 'logusers';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['nama','kodcaw','nokp','taraf','email'];
|
||||
|
||||
public $timestamps = true;
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
// protected $hidden = [];
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateLogusersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
//return;
|
||||
|
||||
Schema::create('logusers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('kodcaw')->nullable();
|
||||
$table->string('nokp')->nullable();
|
||||
$table->string('taraf')->nullable();
|
||||
$table->string('nama')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('logusers');
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,10 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->get('search/lelong',['uses'=>'LelongController@searchBlockLelong']);
|
||||
$router->get('hapus/gadai/null',['uses'=>'GadaiController@hapusGadaiNull']);
|
||||
|
||||
///Log session
|
||||
$router->post('logsession/{kodcaw}',['uses'=>'LogController@logSession']);
|
||||
$router->get('checknokp/{kodcaw}/{nokp}/{tarikh}',['uses'=>'LogController@checkNokpSession']);
|
||||
|
||||
//Tebus API
|
||||
$router->get('tebustawarruq/{kodcaw}/{norujukan}',['uses'=>'TebusController@tebusTawarruq']);
|
||||
$router->get('upahtawarruq/{kodcaw}/{norujukan}',['uses'=>'TebusController@upahTawarruq']);
|
||||
|
||||
Reference in New Issue
Block a user