update aso

This commit is contained in:
2023-06-19 10:50:29 +07:00
parent b550349835
commit ff89f2ac8b
2 changed files with 41 additions and 4 deletions

View File

@@ -218,19 +218,24 @@ class CorporateService
if (!empty($row['budget']) && !in_array($budget_aso)) {
throw new ImportRowException(__('plan.MAX_FREQUENCY'), 0, null, $row);
}
// if (empty($row['limit_free_tc'])){
// throw new ImportRowException(__('plan.REQUIRED', [
// 'attribute' => 'Limit Free TC'
// ]), 0, null, $row);
// }
}
public function handleBenefitRow(Corporate $corporate, $row)
{
try {
// $row['limit_free_tc'] = 0;
$benefit_data = $row;
$this->validateBenefitRow($benefit_data, $corporate->id);
$benefit_data["corporate_id"] = $corporate->id;
$plan = $corporate->plans()
->where('corporate_plan_id', $benefit_data['plan_code'])
->first();
// $corporate->plans->where('corporate_plan_id', $benefit_data['plan_code'])->first();
$benefit_data['plan_code'] = $plan->id;
$benefit = Benefit::updateOrCreate([
@@ -241,10 +246,10 @@ class CorporateService
'service_code' => $plan->service_code,
'description' => $benefit_data['description'],
]);
$corporateBenefit = $corporate->corporateBenefits()->updateOrCreate([
'benefit_id' => $benefit->id,
'plan_id' => $plan->id
'plan_id' => $plan->id,
'corporate_id' => $corporate->id,
], $benefit_data);
return $corporateBenefit;

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('corporate_benefits', function (Blueprint $table) {
$table->string('limit_free_tc', 255)->nullable()->default(null)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('corporate_benefits', function (Blueprint $table) {
$table->integer('limit_free_tc')->change();
});
}
};