[WIP] Import Plans
This commit is contained in:
11
app/Models/Benefit.php
Normal file
11
app/Models/Benefit.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Benefit extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
45
app/Models/Corporate.php
Normal file
45
app/Models/Corporate.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Corporate extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'welcome_message',
|
||||
'help_text',
|
||||
'active'
|
||||
];
|
||||
|
||||
public function imports()
|
||||
{
|
||||
return $this->morphMany(ImportLog::class, 'importable');
|
||||
}
|
||||
|
||||
public function files()
|
||||
{
|
||||
return $this->morphMany(File::class, 'fileable');
|
||||
}
|
||||
|
||||
public function policies()
|
||||
{
|
||||
return $this->hasMany(CorporatePolicy::class);
|
||||
}
|
||||
|
||||
public function currentPolicy()
|
||||
{
|
||||
return $this->hasOne(CorporatePolicy::class)
|
||||
// ->where('start', '<=', now())
|
||||
// ->where('end', '>=', now())
|
||||
->where('active', true)
|
||||
->latestOfMany();
|
||||
}
|
||||
}
|
||||
11
app/Models/CorporateDivision.php
Normal file
11
app/Models/CorporateDivision.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CorporateDivision extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/CorporateEmployees.php
Normal file
11
app/Models/CorporateEmployees.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CorporateEmployees extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
31
app/Models/CorporatePolicy.php
Normal file
31
app/Models/CorporatePolicy.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CorporatePolicy extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_id',
|
||||
'code',
|
||||
'total_premi',
|
||||
'minimal_deposit_percentage',
|
||||
'minimal_deposit_net',
|
||||
'minimal_alert_percentage',
|
||||
'minimal_alert_net',
|
||||
'minimal_stop_service_percentage',
|
||||
'minimal_stop_service_net',
|
||||
'start',
|
||||
'end',
|
||||
'active',
|
||||
];
|
||||
|
||||
public function corporate()
|
||||
{
|
||||
return $this->belongsTo(Corporate::class);
|
||||
}
|
||||
}
|
||||
61
app/Models/File.php
Normal file
61
app/Models/File.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class File extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'fileable_type',
|
||||
'fileable_id',
|
||||
'type',
|
||||
'name',
|
||||
'extension',
|
||||
'path',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'url'
|
||||
];
|
||||
|
||||
public static $file_directories = [
|
||||
'import-temp' => 'import-temp/',
|
||||
];
|
||||
|
||||
public function fileable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return Storage::url($this->path);
|
||||
}
|
||||
|
||||
public function getDirectory($type)
|
||||
{
|
||||
return self::$file_directories[$type] ?? 'any';
|
||||
}
|
||||
|
||||
public static function getFileName($type, $id, $file)
|
||||
{
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
|
||||
return $type . '-' . $id .'-'.Str::random(10).'.'.$extension;
|
||||
}
|
||||
|
||||
public static function storeFile($type, $id, $file)
|
||||
{
|
||||
$fileName = self::getFileName($type, $id, $file);
|
||||
$directory = self::getDirectory($type);
|
||||
$path = $directory . $fileName;
|
||||
$file->storeAs($directory, $fileName);
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
25
app/Models/ImportLog.php
Normal file
25
app/Models/ImportLog.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ImportLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'importable_type',
|
||||
'importable_id',
|
||||
'type',
|
||||
'file_path',
|
||||
'status',
|
||||
'progress',
|
||||
];
|
||||
|
||||
public function files()
|
||||
{
|
||||
return $this->morphMany(File::class, 'fileable');
|
||||
}
|
||||
}
|
||||
66
app/Models/MemberBenefit.php
Normal file
66
app/Models/MemberBenefit.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MemberBenefit extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'service_code',
|
||||
'plan_code',
|
||||
'benefit_code',
|
||||
'description',
|
||||
'budget',
|
||||
'budget_conditions',
|
||||
'budget_code',
|
||||
'primary_benefit_code',
|
||||
'room_class_coverage',
|
||||
'max_bed_coverage',
|
||||
'tolerance_parameter',
|
||||
'max_room_class',
|
||||
'limit_amount',
|
||||
'area_limit',
|
||||
'shared_benefit',
|
||||
'msc',
|
||||
'genders',
|
||||
'min_age',
|
||||
'max_age',
|
||||
'max_frequency_period',
|
||||
'daily_frequency',
|
||||
'weekly_frequency',
|
||||
'monthly_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',
|
||||
'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',
|
||||
];
|
||||
}
|
||||
11
app/Models/Plan.php
Normal file
11
app/Models/Plan.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Plan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/Services.php
Normal file
11
app/Models/Services.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Services extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
Reference in New Issue
Block a user