backend formularium
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Traits\Blameable;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Altek\Accountant\Contracts\Recordable;
|
||||||
|
|
||||||
class CorporateFormularium extends Model
|
class CorporateFormularium extends Model
|
||||||
{
|
{
|
||||||
@@ -15,7 +16,7 @@ class CorporateFormularium extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'corporate_id',
|
'corporate_id',
|
||||||
'formularium_id',
|
'formularium_template_id',
|
||||||
'active'
|
'active'
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -24,8 +25,8 @@ class CorporateFormularium extends Model
|
|||||||
return $this->belongsTo(Corporate::class);
|
return $this->belongsTo(Corporate::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formularium()
|
public function formularium_template()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Formularium::class);
|
return $this->belongsTo(FormulariumTemplate::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,6 @@ class Formularium extends Model
|
|||||||
$this->attributes['code'] = !empty($value) ? $value : Str::upper(Str::random('6'));
|
$this->attributes['code'] = !empty($value) ? $value : Str::upper(Str::random('6'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function corporateFormulariums()
|
|
||||||
{
|
|
||||||
return $this->hasMany(CorporateFormularium::class, 'formularium_id', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function items()
|
public function items()
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Drug::class, 'formularium_items', 'formularium_id', 'item_id');
|
return $this->belongsToMany(Drug::class, 'formularium_items', 'formularium_id', 'item_id');
|
||||||
|
|||||||
@@ -23,4 +23,9 @@ class FormulariumTemplate extends Model
|
|||||||
'updated_by',
|
'updated_by',
|
||||||
// 'deleted_by',
|
// 'deleted_by',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// public function corporateFormulariums()
|
||||||
|
// {
|
||||||
|
// return $this->hasMany(CorporateFormularium::class, 'formularium_template_id', 'id');
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Schema;
|
|||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use App\Models\Corporate;
|
use App\Models\Corporate;
|
||||||
|
use App\Models\CorporateFormularium;
|
||||||
use App\Models\CorporateService;
|
use App\Models\CorporateService;
|
||||||
use App\Models\CorporatePlan;
|
use App\Models\CorporatePlan;
|
||||||
use App\Models\CorporateBenefit;
|
use App\Models\CorporateBenefit;
|
||||||
@@ -144,6 +145,14 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
$this->logAuditTrail($model, 'deleted');
|
$this->logAuditTrail($model, 'deleted');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Formualrium Template
|
||||||
|
CorporateFormularium::updated(function ($model) {
|
||||||
|
$this->logAuditTrail($model, 'updated');
|
||||||
|
});
|
||||||
|
CorporateFormularium::deleted(function ($model) {
|
||||||
|
$this->logAuditTrail($model, 'deleted');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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_formulariums', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('formularium_id', 'formularium_template_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('corporate_formulariums', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('formularium_template_id', 'formularium_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user