Update insert
This commit is contained in:
@@ -55,36 +55,40 @@ class RequestLogController extends Controller
|
|||||||
{
|
{
|
||||||
//insert data to organization
|
//insert data to organization
|
||||||
try {
|
try {
|
||||||
// Memulai transaksi
|
if(!$request->id_provider)
|
||||||
DB::beginTransaction();
|
{
|
||||||
|
// Memulai transaksi
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
// Insert data ke tabel organizations
|
// Insert data ke tabel organizations
|
||||||
$organization_id = DB::table('organizations')
|
$organization_id = DB::table('organizations')
|
||||||
->insertGetId([
|
->insertGetId([
|
||||||
'name' => $request->name_provider,
|
'name' => $request->name_provider,
|
||||||
'code' => $request->name_provider,
|
'code' => $request->name_provider,
|
||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
'created_by' => auth()->user()->id
|
'created_by' => auth()->user()->id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Insert data ke tabel addresses
|
// Insert data ke tabel addresses
|
||||||
$address_id = DB::table('addresses')
|
$address_id = DB::table('addresses')
|
||||||
->insertGetId([
|
->insertGetId([
|
||||||
'text'=> $request->address_provider,
|
'text'=> $request->address_provider,
|
||||||
'addressable_type' => 'App\Models\Organization',
|
'addressable_type' => 'App\Models\Organization',
|
||||||
'addressable_id' => $organization_id,
|
'addressable_id' => $organization_id,
|
||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
'created_by' => auth()->user()->id
|
'created_by' => auth()->user()->id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Update main_address_id di tabel organizations
|
// Update main_address_id di tabel organizations
|
||||||
DB::table('organizations')
|
DB::table('organizations')
|
||||||
->where('organizations.id', '=', $organization_id)
|
->where('organizations.id', '=', $organization_id)
|
||||||
->update(['main_address_id' => $address_id]);
|
->update(['main_address_id' => $address_id]);
|
||||||
|
|
||||||
|
// Commit transaksi
|
||||||
|
DB::commit();
|
||||||
|
$request->merge(['organization_id' => $organization_id]);
|
||||||
|
}
|
||||||
|
|
||||||
// Commit transaksi
|
|
||||||
DB::commit();
|
|
||||||
$request->merge(['organization_id' => $organization_id]);
|
|
||||||
$requestLogControllerInstance = new PrimeCenterRequestLog();
|
$requestLogControllerInstance = new PrimeCenterRequestLog();
|
||||||
$response = $requestLogControllerInstance->createNew($request);
|
$response = $requestLogControllerInstance->createNew($request);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user