diff --git a/Modules/Internal/Http/Controllers/Api/BenefitController.php b/Modules/Internal/Http/Controllers/Api/BenefitController.php index 9b4f8dfb..46204109 100755 --- a/Modules/Internal/Http/Controllers/Api/BenefitController.php +++ b/Modules/Internal/Http/Controllers/Api/BenefitController.php @@ -3,6 +3,7 @@ namespace Modules\Internal\Http\Controllers\Api; use App\Models\Benefit; +use App\Models\CorporateBenefit; use App\Models\MemberBenefit; use Illuminate\Contracts\Support\Renderable; use Illuminate\Http\Request; @@ -18,9 +19,10 @@ class BenefitController extends Controller */ public function index(Request $request, $corporate_id) { - $benefits = Benefit::query() + $benefits = CorporateBenefit::query() ->filter($request->all()) ->where('corporate_id', $corporate_id) + ->with('benefit') ->paginate() ->appends($request->all()); @@ -89,59 +91,59 @@ class BenefitController extends Controller public function memberBenefitImport(Request $request, $corporate_id) { - $request->validate([ - 'file' => 'required|file|mimes:xls,xlsx,csv,txt', - ]); - $file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName(); - $file = $request->file('file')->storeAs('temp', $file_name); + // $request->validate([ + // 'file' => 'required|file|mimes:xls,xlsx,csv,txt', + // ]); + // $file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName(); + // $file = $request->file('file')->storeAs('temp', $file_name); - $reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name)); - $reader->open(Storage::path('temp/'.$file_name)); + // $reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name)); + // $reader->open(Storage::path('temp/'.$file_name)); - $headers_map_to_table_fields = Benefit::$doc_headers_to_field_map; + // $headers_map_to_table_fields = Benefit::$doc_headers_to_field_map; - $imported_benefit_data = 0; - $failed_benefit_data = []; - foreach ($reader->getSheetIterator() as $sheet) { - $doc_headers_indexes = []; - foreach ($sheet->getRowIterator() as $index => $row) { - if ($index == 1) { // First Row Must be Header - foreach ($row->getCells() as $index => $cell) { - $doc_headers_indexes[$index] = rtrim($cell->getValue()); - } - } else { // Next Row Should be Data - $new_benefit_data = []; - foreach ($row->getCells() as $index => $cell) { - $new_benefit_data[$headers_map_to_table_fields[$doc_headers_indexes[$index]]] = $cell->getValue(); - } + // $imported_benefit_data = 0; + // $failed_benefit_data = []; + // foreach ($reader->getSheetIterator() as $sheet) { + // $doc_headers_indexes = []; + // foreach ($sheet->getRowIterator() as $index => $row) { + // if ($index == 1) { // First Row Must be Header + // foreach ($row->getCells() as $index => $cell) { + // $doc_headers_indexes[$index] = rtrim($cell->getValue()); + // } + // } else { // Next Row Should be Data + // $new_benefit_data = []; + // foreach ($row->getCells() as $index => $cell) { + // $new_benefit_data[$headers_map_to_table_fields[$doc_headers_indexes[$index]]] = $cell->getValue(); + // } - // $imported_plan_data[] = $new_row; // Insert to Array - // Create Directly - $new_benefit_data['corporate_id'] = $corporate_id; - try { - Benefit::updateOrCreate([ - 'corporate_id' => $corporate_id, - 'code' => $new_benefit_data['code'] - ], $new_benefit_data); + // // $imported_plan_data[] = $new_row; // Insert to Array + // // Create Directly + // $new_benefit_data['corporate_id'] = $corporate_id; + // try { + // Benefit::updateOrCreate([ + // 'corporate_id' => $corporate_id, + // 'code' => $new_benefit_data['code'] + // ], $new_benefit_data); - $imported_benefit_data++; - } catch(\Exception $e) { - $new_benefit_data['error'] = $e->getMessage(); - $failed_benefit_data[] = $new_benefit_data; - } - } - } + // $imported_benefit_data++; + // } catch(\Exception $e) { + // $new_benefit_data['error'] = $e->getMessage(); + // $failed_benefit_data[] = $new_benefit_data; + // } + // } + // } - break; //only read first sheet - } - $reader->close(); - Storage::delete('temp/'.$file_name); - // throw(404); + // break; //only read first sheet + // } + // $reader->close(); + // Storage::delete('temp/'.$file_name); + // // throw(404); - return [ - 'total_successed_row' => $imported_benefit_data, - 'total_failed_row' => count($failed_benefit_data), - 'failed_row' => $failed_benefit_data - ]; + // return [ + // 'total_successed_row' => $imported_benefit_data, + // 'total_failed_row' => count($failed_benefit_data), + // 'failed_row' => $failed_benefit_data + // ]; } } diff --git a/Modules/Internal/Http/Controllers/Api/CorporateController.php b/Modules/Internal/Http/Controllers/Api/CorporateController.php index 7e5a57db..835e948f 100755 --- a/Modules/Internal/Http/Controllers/Api/CorporateController.php +++ b/Modules/Internal/Http/Controllers/Api/CorporateController.php @@ -7,6 +7,7 @@ use App\Imports\PlansImport; use App\Models\Benefit; use App\Models\Claim; use App\Models\Corporate; +use App\Models\CorporateBenefit; use App\Models\Plan; use App\Models\Service; use App\Models\User; @@ -347,7 +348,7 @@ class CorporateController extends Controller // dd($request->toArray()); $file_name = now()->getPreciseTimestamp(3) . '-' . $request->file('file')->getClientOriginalName(); $file = $request->file('file')->storeAs('temp', $file_name); - $corporate = Corporate::findOrFail($corporate_id); + $corporate = Corporate::with(['plans'])->findOrFail($corporate_id); $import = new ImportService(); $import->read(Storage::path('temp/' . $file_name)); @@ -368,7 +369,7 @@ class CorporateController extends Controller if ($sheet->getName() == 'Plan') { $headers_map_to_table_fields = Plan::$doc_headers_to_field_map; } else if ($sheet->getName() == 'Benefit') { - $headers_map_to_table_fields = Benefit::$doc_headers_to_field_map; + $headers_map_to_table_fields = CorporateBenefit::$doc_headers_to_field_map; } // Write Header to File diff --git a/Modules/Internal/Services/CorporateService.php b/Modules/Internal/Services/CorporateService.php index eb337543..d9a2a5c5 100755 --- a/Modules/Internal/Services/CorporateService.php +++ b/Modules/Internal/Services/CorporateService.php @@ -5,6 +5,7 @@ namespace Modules\Internal\Services; use App\Exceptions\ImportRowException; use App\Models\Benefit; use App\Models\Corporate; +use App\Models\CorporateBenefit; use App\Models\Plan; use Box\Spout\Writer\Common\Creator\WriterEntityFactory; @@ -61,10 +62,10 @@ class CorporateService if (empty($row['plan_code'])) { throw new ImportRowException(__('benefit.PLAN_CODE_REQUIRED'), 0, null, $row); } - if (empty($row['benefit_code'])) { + if (empty($row['code'])) { throw new ImportRowException(__('benefit.BENEFIT_CODE_REQUIRED'), 0, null, $row); } - if (empty($row['code'])) { + if (empty($row['corporate_benefit_code'])) { throw new ImportRowException(__('benefit.CUSTOMER_BENEFIT_CODE_REQUIRED'), 0, null, $row); } if (empty($row['description'])) { @@ -86,20 +87,28 @@ class CorporateService try { $benefit_data = $row; $benefit_data["corporate_id"] = $corporate->id; - $this->validateBenefitRow($benefit_data); - $plan = Plan::where('corporate_id', $corporate->id)->where('corporate_plan_id', $benefit_data['plan_code'])->first(); + + $plan = $corporate->plans->where('corporate_plan_id', $benefit_data['plan_code'])->first(); $benefit_data['plan_code'] = $plan->id; $benefit = Benefit::updateOrCreate([ - 'service_code' => $benefit_data['service_code'], - 'plan_code' => $benefit_data['plan_code'], - 'corporate_id' => $corporate->id, 'code' => $benefit_data['code'], - ], $benefit_data); + 'service_code' => $plan->service_code, + ], [ + 'code' => $benefit_data['code'], + 'service_code' => $plan->service_code, + 'active' => true + ]); - return $benefit; + $corporateBenefit = $corporate->corporateBenefits()->updateOrCreate([ + 'benefit_id' => $benefit->id, + 'plan_id' => $plan->id + ], $benefit_data ); + + return $corporateBenefit; } catch (\Exception $e) { + dd($e->getMessage()); throw $e; } } diff --git a/app/Models/Benefit.php b/app/Models/Benefit.php index 9e8d80d0..2fae61df 100755 --- a/app/Models/Benefit.php +++ b/app/Models/Benefit.php @@ -12,156 +12,12 @@ class Benefit extends Model use HasFactory, SoftDeletes, Blameable; protected $fillable = [ - 'corporate_id', 'service_code', - 'plan_code', - 'benefit_code', 'code', 'description', - 'budget', - 'budget_conditions', - 'budget_code', - 'primary_benefit_code', - 'benefit_mode', - 'room_class_coverage', - 'max_bed_coverage', - 'tolerance_parameter', - 'max_room_class', - 'limit_amount', - 'area_limit', - 'shared_benefit', - 'shared_benefit_type', - 'msc', - 'genders', - 'min_age', - 'max_age', - 'max_frequency_period', - 'daily_frequency', - 'weekly_frequency', - 'monthly_frequency', - 'yearly_frequency', - 'custom_frequency_days', - 'custom_duration_value', - 'allowed_transaction_types', - 'high_plan_factor', - 'pre_post_treatment', - 'pre_treatment_days', - 'post_treatment_days', - 'layer_type_1', - 'layer_value_1', - 'layer_type_2', - 'layer_value_2', - 'cashless_percentage', - 'reimbursement_percentage', - 'digital_percentage', - 'co_share_m_percentage', - 'co_share_s_percentage', - 'co_share_c_percentage', - 'cashless_deductible', - 'reimbursement_deductible', - 'digital_deductible', - 'co_share_m_deductible', - 'co_share_s_deductible', - 'co_share_c_deductible', - 'prorate_type', - 'prorate_lookup', - 'max_days_for_disability', - 'max_period_for_disability', - 'currency', - 'show_benefit_item', - 'show_benefit_value', + 'active' ]; - public static $doc_headers_to_field_map = [ - "Service" => 'service_code', - "Plan" => 'plan_code', - "Benefit Code" => 'benefit_code', - "Customer Benefit Code" => 'code', - "Detail Benefit" => 'description', - "ASO/Budget" => 'budget', - "Budget Condition" => 'budget_conditions', - "Budget Code" => 'budget_code', - "Primary benefit" => 'primary_benefit_code', - "Benefit Mode" => 'benefit_mode', - "Room Class" => 'room_class_coverage', - "Max Bed" => 'max_bed_coverage', - "Tolerance Paramater" => 'tolerance_parameter', - "Max. Room Class" => 'max_room_class', - "Limit Value" => 'limit_amount', - "Area" => 'area_limit', - "Shared Benefit With" => 'shared_benefit', - "Shared Benefit Type" => 'shared_benefit_type', - "MSC" => 'msc', - "Gender" => 'genders', - "Min Age" => 'min_age', - "Max Age" => 'max_age', - "Freq. Period" => 'max_frequency_period', - "Daily Frequency" => 'daily_frequency', - "Weekly Frequency" => 'weekly_frequency', - "Monthly Frequency" => 'monthly_frequency', - "Yearly Frequency" => 'yearly_frequency', - "Custom Duration" => 'custom_frequency_days', - "Custom Duration Value" => 'custom_duration_value', - "Cashless, Reimbursement" => 'allowed_transaction_types', - "High Plan Factor" => 'high_plan_factor', - "Pre Post Treatment" => 'pre_post_treatment', - "Pre Treatment" => 'pre_treatment_days', - "Post Treatment" => 'post_treatment_days', - "Layer Type 1" => 'layer_type_1', - "Layer Value 1" => 'layer_value_1', - "Layer Type 2" => 'layer_type_2', - "Layer Value 2" => 'layer_value_2', - "Cashless (%)" => 'cashless_percentage', - "Reimburse (%)" => 'reimbursement_percentage', - "Digital (%)" => 'digital_percentage', - "CoShareM (%)" => 'co_share_m_percentage', - "CoShareS (%)" => 'co_share_s_percentage', - "CoShareC (%)" => 'co_share_c_percentage', - "Cashless Deductible" => 'cashless_deductible', - "Reimbursement Deductible" => 'reimbursement_deductible', - "Digital Deductible" => 'digital_deductible', - "DeductibleM" => 'co_share_m_deductible', - "DeductibleS" => 'co_share_s_deductible', - "DeductibleC" => 'co_share_c_deductible', - "Prorate Type" => 'prorate_type', - "Prorate Lookup" => 'prorate_lookup', - "Max Days for Disability" => 'max_days_for_disability', - "Max Periode of Disability" => 'max_period_for_disability', - "Currency" => 'currency', - "Show Benefit Item" => 'show_benefit_item', - "Show Benefit Value" => 'show_benefit_value', - ]; - - public static $max_frequency_periods = [ - 0 => 'Policy Period', - 1 => 'Daily Visit', - 2 => 'Weekly', - 3 => 'Monthly', - 4 => 'Yearly', - 5 => 'Disability', - 6 => 'Visit', - ]; - - protected $appends = [ - 'max_frequency_period_name', - 'max_frequency' - ]; - - public function setAreaLimitAttribute($value) - { - $this->attributes['area_limit'] = empty($value) ? null : $value; - } - - public function setPrePostTreatmentAttribute($value) - { - $this->attributes['pre_post_treatment'] = empty($value) ? null : ($value == 'Y'); - } - - public function getPrePostTreatmentAttribute($value) - { - return empty($value) ? null : ($value ? 'Y' : 'N'); - } - public function scopeFilter($query, array $filters) { $query->when($filters['search'] ?? false, function ($query, $search) { @@ -174,51 +30,17 @@ class Benefit extends Model }); } - public function benefit() - { - return $this->belongsTo(Benefit::class, 'benefit_code', 'code'); - } + // public function benefit() + // { + // return $this->belongsTo(Benefit::class, 'benefit_code', 'code'); + // } - public function plan() + public function plans() { - return $this->belongsTo(Plan::class, 'plan_code', 'code'); - } - - public function getMaxFrequencyPeriodNameAttribute() - { - return self::$max_frequency_periods[$this->max_frequency_period] ?? null; - } - - public function getMaxFrequencyAttribute() - { - switch ($this->max_frequency_period) { - // case(0) : - // // TODO Fix This - // return null; - // break; - case(1) : - return empty($this->daily_frequency) ? 1 : $this->daily_frequency; - break; - case(2) : - return empty($this->weekly_frequency) ? 1 : $this->weekly_frequency; - break; - case(3) : - return empty($this->monthly_frequency) ? 1 : $this->monthly_frequency; - break; - case(4) : - return empty($this->yearly_frequency) ? 1 : $this->yearly_frequency; - break; - case(5) : - // TODO Fix This - return empty($this->max_period_for_disability) ? 1 : $this->max_period_for_disability; - break; - case(6) : - // TODO Fix This - return 1; - break; - default : - return null; - break; - } + return $this->belongsToMany(Plan::class, 'corporate_benefits', 'benefit_id', 'id') + ->withTimestamps() + ->withPivot([ + // TODO corporate_benefits pivot + ]); } } diff --git a/app/Models/Corporate.php b/app/Models/Corporate.php index afdc0487..fde171b1 100755 --- a/app/Models/Corporate.php +++ b/app/Models/Corporate.php @@ -36,6 +36,11 @@ class Corporate extends Model return $this->morphMany(File::class, 'fileable'); } + public function plans() + { + return $this->hasMany(Plan::class, 'corporate_id', 'id'); + } + public function policies() { return $this->hasMany(CorporatePolicy::class); diff --git a/app/Models/CorporateBenefit.php b/app/Models/CorporateBenefit.php index 64a66c38..e60940c7 100755 --- a/app/Models/CorporateBenefit.php +++ b/app/Models/CorporateBenefit.php @@ -13,17 +13,208 @@ class CorporateBenefit extends Model protected $fillable = [ 'corporate_id', - 'code', - 'name', - 'description', + 'plan_id', + 'benefit_id', + 'corporate_benefit_code', + 'budget', + 'budget_conditions', + 'budget_code', + 'primary_benefit_code', + 'benefit_mode', + 'room_class_coverage', + 'max_bed_coverage', + 'tolerance_parameter', + 'max_room_class', + 'limit_amount', + 'area_limit', + 'shared_benefit', + 'shared_benefit_type', + 'msc', + 'genders', + 'min_age', + 'max_age', + 'max_frequency_period', + 'daily_frequency', + 'weekly_frequency', + 'monthly_frequency', + 'yearly_frequency', + 'custom_frequency_days', + 'custom_duration_value', + 'allowed_transaction_types', + 'high_plan_factor', + 'pre_post_treatment', + 'pre_treatment_days', + 'post_treatment_days', + 'layer_type_1', + 'layer_value_1', + 'layer_type_2', + 'layer_value_2', + 'cashless_percentage', + 'reimbursement_percentage', + 'digital_percentage', + 'co_share_m_percentage', + 'co_share_s_percentage', + 'co_share_c_percentage', + 'cashless_deductible', + 'reimbursement_deductible', + 'digital_deductible', + 'co_share_m_deductible', + 'co_share_s_deductible', + 'co_share_c_deductible', + 'prorate_type', + 'prorate_lookup', + 'max_days_for_disability', + 'max_period_for_disability', + 'currency', + 'show_benefit_item', + 'show_benefit_value', 'active', ]; + public static $doc_headers_to_field_map = [ + "Service" => 'service_code', + "Plan" => 'plan_code', + "Benefit Code" => 'code', + "Customer Benefit Code" => 'corporate_benefit_code', + "Detail Benefit" => 'description', + "ASO/Budget" => 'budget', + "Budget Condition" => 'budget_conditions', + "Budget Code" => 'budget_code', + "Primary benefit" => 'primary_benefit_code', + "Benefit Mode" => 'benefit_mode', + "Room Class" => 'room_class_coverage', + "Max Bed" => 'max_bed_coverage', + "Tolerance Paramater" => 'tolerance_parameter', + "Max. Room Class" => 'max_room_class', + "Limit Value" => 'limit_amount', + "Area" => 'area_limit', + "Shared Benefit With" => 'shared_benefit', + "Shared Benefit Type" => 'shared_benefit_type', + "MSC" => 'msc', + "Gender" => 'genders', + "Min Age" => 'min_age', + "Max Age" => 'max_age', + "Freq. Period" => 'max_frequency_period', + "Daily Frequency" => 'daily_frequency', + "Weekly Frequency" => 'weekly_frequency', + "Monthly Frequency" => 'monthly_frequency', + "Yearly Frequency" => 'yearly_frequency', + "Custom Duration" => 'custom_frequency_days', + "Custom Duration Value" => 'custom_duration_value', + "Cashless, Reimbursement" => 'allowed_transaction_types', + "High Plan Factor" => 'high_plan_factor', + "Pre Post Treatment" => 'pre_post_treatment', + "Pre Treatment" => 'pre_treatment_days', + "Post Treatment" => 'post_treatment_days', + "Layer Type 1" => 'layer_type_1', + "Layer Value 1" => 'layer_value_1', + "Layer Type 2" => 'layer_type_2', + "Layer Value 2" => 'layer_value_2', + "Cashless (%)" => 'cashless_percentage', + "Reimburse (%)" => 'reimbursement_percentage', + "Digital (%)" => 'digital_percentage', + "CoShareM (%)" => 'co_share_m_percentage', + "CoShareS (%)" => 'co_share_s_percentage', + "CoShareC (%)" => 'co_share_c_percentage', + "Cashless Deductible" => 'cashless_deductible', + "Reimbursement Deductible" => 'reimbursement_deductible', + "Digital Deductible" => 'digital_deductible', + "DeductibleM" => 'co_share_m_deductible', + "DeductibleS" => 'co_share_s_deductible', + "DeductibleC" => 'co_share_c_deductible', + "Prorate Type" => 'prorate_type', + "Prorate Lookup" => 'prorate_lookup', + "Max Days for Disability" => 'max_days_for_disability', + "Max Periode of Disability" => 'max_period_for_disability', + "Currency" => 'currency', + "Show Benefit Item" => 'show_benefit_item', + "Show Benefit Value" => 'show_benefit_value', + ]; + + public static $max_frequency_periods = [ + 0 => 'Policy Period', + 1 => 'Daily Visit', + 2 => 'Weekly', + 3 => 'Monthly', + 4 => 'Yearly', + 5 => 'Disability', + 6 => 'Visit', + ]; + + protected $appends = [ + 'max_frequency_period_name', + 'max_frequency' + ]; + + + public function setAreaLimitAttribute($value) + { + $this->attributes['area_limit'] = empty($value) ? null : $value; + } + + public function setPrePostTreatmentAttribute($value) + { + $this->attributes['pre_post_treatment'] = empty($value) ? null : ($value == 'Y'); + } + + public function getPrePostTreatmentAttribute($value) + { + return empty($value) ? null : ($value ? 'Y' : 'N'); + } + + public function getMaxFrequencyPeriodNameAttribute() + { + return self::$max_frequency_periods[$this->max_frequency_period] ?? null; + } + + public function getMaxFrequencyAttribute() + { + switch ($this->max_frequency_period) { + // case(0) : + // // TODO Fix This + // return null; + // break; + case(1) : + return empty($this->daily_frequency) ? 1 : $this->daily_frequency; + break; + case(2) : + return empty($this->weekly_frequency) ? 1 : $this->weekly_frequency; + break; + case(3) : + return empty($this->monthly_frequency) ? 1 : $this->monthly_frequency; + break; + case(4) : + return empty($this->yearly_frequency) ? 1 : $this->yearly_frequency; + break; + case(5) : + // TODO Fix This + return empty($this->max_period_for_disability) ? 1 : $this->max_period_for_disability; + break; + case(6) : + // TODO Fix This + return 1; + break; + default : + return null; + break; + } + } + + public function benefit() + { + return $this->belongsTo(Benefit::class); + } + public function corporate() { return $this->belongsTo(Corporate::class); } + public function plan() + { + return $this->belongsTo(Plan::class); + } + public function scopeFilter($query, array $filters) { $query->when($filters['search'] ?? false, function ($query, $search) { diff --git a/app/Models/Plan.php b/app/Models/Plan.php index b486291b..974d49a9 100755 --- a/app/Models/Plan.php +++ b/app/Models/Plan.php @@ -168,6 +168,15 @@ class Plan extends Model public function benefits() { - return $this->hasMany(Benefit::class, 'plan_code', 'id'); + return $this->belongsToMany(Benefit::class, 'corporate_benefits', 'benefit_id', 'id') + ->withTimestamps() + ->withPivot([ + // TODO corporate_benefits pivot + ]); + } + + public function corporateBeneftis() + { + return $this->hasMany(CorporateBenefit::class, 'benefit_id', 'id'); } } diff --git a/database/migrations/2022_06_23_070847_create_benefits_table.php b/database/migrations/2022_06_23_070847_create_benefits_table.php index 1de1c710..403b2917 100755 --- a/database/migrations/2022_06_23_070847_create_benefits_table.php +++ b/database/migrations/2022_06_23_070847_create_benefits_table.php @@ -15,64 +15,66 @@ return new class extends Migration { Schema::create('benefits', function (Blueprint $table) { $table->id(); - $table->foreignId('corporate_id')->index()->nullable(); + // $table->foreignId('corporate_id')->index()->nullable(); $table->string('service_code')->index()->nullable(); - $table->string('plan_code')->index()->nullable(); - $table->string('benefit_code')->index()->nullable(); - $table->string('code')->index()->nullable(); + // $table->string('plan_code')->index()->nullable(); + // $table->string('benefit_code')->index()->nullable(); + $table->string('code')->index(); $table->text('description')->nullable(); - $table->string('budget')->nullable(); - $table->string('budget_conditions')->nullable(); - $table->string('budget_code')->nullable(); - $table->string('primary_benefit_code')->index()->nullable(); - $table->string('benefit_mode')->nullable(); - $table->string('room_class_coverage')->nullable(); - $table->string('max_bed_coverage')->nullable(); - $table->string('tolerance_parameter')->nullable(); - $table->string('max_room_class')->nullable(); - $table->string('limit_amount', 30)->nullable(); - $table->boolean('area_limit')->default(false)->nullable(); - $table->string('shared_benefit')->nullable(); - $table->string('shared_benefit_type')->nullable(); - $table->string('msc')->nullable(); - $table->string('genders')->nullable(); - $table->string('min_age')->nullable(); - $table->string('max_age')->nullable(); - $table->string('max_frequency_period')->nullable(); - $table->string('daily_frequency')->nullable(); - $table->string('weekly_frequency')->nullable(); - $table->string('monthly_frequency')->nullable(); - $table->string('yearly_frequency')->nullable(); - $table->string('custom_frequency_days')->nullable(); - $table->string('custom_duration_value')->nullable(); - $table->string('allowed_transaction_types')->nullable(); - $table->string('high_plan_factor')->nullable(); - $table->boolean('pre_post_treatment')->nullable(); - $table->string('pre_treatment_days')->nullable(); - $table->string('post_treatment_days')->nullable(); - $table->string('layer_type_1')->nullable(); - $table->string('layer_value_1')->nullable(); - $table->string('layer_type_2')->nullable(); - $table->string('layer_value_2')->nullable(); - $table->string('cashless_percentage')->default(100)->nullable(); - $table->string('reimbursement_percentage')->default(100)->nullable(); - $table->string('digital_percentage')->default(100)->nullable(); - $table->string('co_share_m_percentage')->default(100)->nullable(); - $table->string('co_share_s_percentage')->default(100)->nullable(); - $table->string('co_share_c_percentage')->default(100)->nullable(); - $table->string('cashless_deductible', 30)->nullable(); - $table->string('reimbursement_deductible', 30)->nullable(); - $table->string('digital_deductible', 30)->nullable(); - $table->string('co_share_m_deductible', 30)->nullable(); - $table->string('co_share_s_deductible', 30)->nullable(); - $table->string('co_share_c_deductible', 30)->nullable(); - $table->string('prorate_type')->nullable(); - $table->string('prorate_lookup')->nullable(); - $table->string('max_days_for_disability')->nullable(); - $table->string('max_period_for_disability')->nullable(); - $table->string('currency')->nullable(); - $table->string('show_benefit_item')->nullable(); - $table->string('show_benefit_value')->nullable(); + // $table->string('budget')->nullable(); + // $table->string('budget_conditions')->nullable(); + // $table->string('budget_code')->nullable(); + // $table->string('primary_benefit_code')->index()->nullable(); + // $table->string('benefit_mode')->nullable(); + // $table->string('room_class_coverage')->nullable(); + // $table->string('max_bed_coverage')->nullable(); + // $table->string('tolerance_parameter')->nullable(); + // $table->string('max_room_class')->nullable(); + // $table->string('limit_amount', 30)->nullable(); + // $table->boolean('area_limit')->default(false)->nullable(); + // $table->string('shared_benefit')->nullable(); + // $table->string('shared_benefit_type')->nullable(); + // $table->string('msc')->nullable(); + // $table->string('genders')->nullable(); + // $table->string('min_age')->nullable(); + // $table->string('max_age')->nullable(); + // $table->string('max_frequency_period')->nullable(); + // $table->string('daily_frequency')->nullable(); + // $table->string('weekly_frequency')->nullable(); + // $table->string('monthly_frequency')->nullable(); + // $table->string('yearly_frequency')->nullable(); + // $table->string('custom_frequency_days')->nullable(); + // $table->string('custom_duration_value')->nullable(); + // $table->string('allowed_transaction_types')->nullable(); + // $table->string('high_plan_factor')->nullable(); + // $table->boolean('pre_post_treatment')->nullable(); + // $table->string('pre_treatment_days')->nullable(); + // $table->string('post_treatment_days')->nullable(); + // $table->string('layer_type_1')->nullable(); + // $table->string('layer_value_1')->nullable(); + // $table->string('layer_type_2')->nullable(); + // $table->string('layer_value_2')->nullable(); + // $table->string('cashless_percentage')->default(100)->nullable(); + // $table->string('reimbursement_percentage')->default(100)->nullable(); + // $table->string('digital_percentage')->default(100)->nullable(); + // $table->string('co_share_m_percentage')->default(100)->nullable(); + // $table->string('co_share_s_percentage')->default(100)->nullable(); + // $table->string('co_share_c_percentage')->default(100)->nullable(); + // $table->string('cashless_deductible', 30)->nullable(); + // $table->string('reimbursement_deductible', 30)->nullable(); + // $table->string('digital_deductible', 30)->nullable(); + // $table->string('co_share_m_deductible', 30)->nullable(); + // $table->string('co_share_s_deductible', 30)->nullable(); + // $table->string('co_share_c_deductible', 30)->nullable(); + // $table->string('prorate_type')->nullable(); + // $table->string('prorate_lookup')->nullable(); + // $table->string('max_days_for_disability')->nullable(); + // $table->string('max_period_for_disability')->nullable(); + // $table->string('currency')->nullable(); + // $table->string('show_benefit_item')->nullable(); + // $table->string('show_benefit_value')->nullable(); + + $table->boolean('active')->default(true); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2022_07_12_025440_create_corporate_benefits_table.php b/database/migrations/2022_07_12_025440_create_corporate_benefits_table.php index 80809681..e32873e9 100755 --- a/database/migrations/2022_07_12_025440_create_corporate_benefits_table.php +++ b/database/migrations/2022_07_12_025440_create_corporate_benefits_table.php @@ -16,9 +16,63 @@ return new class extends Migration Schema::create('corporate_benefits', function (Blueprint $table) { $table->id(); $table->foreignId('corporate_id')->index(); - $table->string('code')->index(); - $table->string('name')->nullable(); - $table->text('description')->nullable(); + $table->foreignId('plan_id')->index(); + $table->foreignId('benefit_id')->index(); + + $table->string('corporate_benefit_code')->nullable(); + $table->string('budget')->nullable(); + $table->string('budget_conditions')->nullable(); + $table->string('budget_code')->nullable(); + $table->string('primary_benefit_code')->index()->nullable(); + $table->string('benefit_mode')->nullable(); + $table->string('room_class_coverage')->nullable(); + $table->string('max_bed_coverage')->nullable(); + $table->string('tolerance_parameter')->nullable(); + $table->string('max_room_class')->nullable(); + $table->string('limit_amount', 30)->nullable(); + $table->boolean('area_limit')->default(false)->nullable(); + $table->string('shared_benefit')->nullable(); + $table->string('shared_benefit_type')->nullable(); + $table->string('msc')->nullable(); + $table->string('genders')->nullable(); + $table->string('min_age')->nullable(); + $table->string('max_age')->nullable(); + $table->string('max_frequency_period')->nullable(); + $table->string('daily_frequency')->nullable(); + $table->string('weekly_frequency')->nullable(); + $table->string('monthly_frequency')->nullable(); + $table->string('yearly_frequency')->nullable(); + $table->string('custom_frequency_days')->nullable(); + $table->string('custom_duration_value')->nullable(); + $table->string('allowed_transaction_types')->nullable(); + $table->string('high_plan_factor')->nullable(); + $table->boolean('pre_post_treatment')->nullable(); + $table->string('pre_treatment_days')->nullable(); + $table->string('post_treatment_days')->nullable(); + $table->string('layer_type_1')->nullable(); + $table->string('layer_value_1')->nullable(); + $table->string('layer_type_2')->nullable(); + $table->string('layer_value_2')->nullable(); + $table->string('cashless_percentage')->default(100)->nullable(); + $table->string('reimbursement_percentage')->default(100)->nullable(); + $table->string('digital_percentage')->default(100)->nullable(); + $table->string('co_share_m_percentage')->default(100)->nullable(); + $table->string('co_share_s_percentage')->default(100)->nullable(); + $table->string('co_share_c_percentage')->default(100)->nullable(); + $table->string('cashless_deductible', 30)->nullable(); + $table->string('reimbursement_deductible', 30)->nullable(); + $table->string('digital_deductible', 30)->nullable(); + $table->string('co_share_m_deductible', 30)->nullable(); + $table->string('co_share_s_deductible', 30)->nullable(); + $table->string('co_share_c_deductible', 30)->nullable(); + $table->string('prorate_type')->nullable(); + $table->string('prorate_lookup')->nullable(); + $table->string('max_days_for_disability')->nullable(); + $table->string('max_period_for_disability')->nullable(); + $table->string('currency')->nullable(); + $table->string('show_benefit_item')->nullable(); + $table->string('show_benefit_value')->nullable(); + $table->boolean('active')->default(true); $table->timestamps(); @@ -28,7 +82,7 @@ return new class extends Migration $table->foreignId('updated_by')->nullable()->index(); $table->foreignId('deleted_by')->nullable()->index(); - $table->unique(['corporate_id', 'code']); + $table->unique(['corporate_id', 'plan_id', 'benefit_id']); }); }