34 lines
692 B
PHP
34 lines
692 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Rule extends Model
|
|
{
|
|
protected $table = 'rules';
|
|
public $timestamps = false;
|
|
|
|
protected $guarded = [];
|
|
|
|
public function penyakit()
|
|
{
|
|
return $this->belongsTo(Penyakit::class, 'kode_penyakit', 'kode_penyakit');
|
|
}
|
|
public function gejala()
|
|
{
|
|
return $this->belongsTo(Gejala::class, 'kode_gejala', 'kode_gejala');
|
|
}
|
|
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::creating(function ($rules) {
|
|
$count = self::count() + 1;
|
|
$rules->kode_basis = 'R' . str_pad($count, 2, '0', STR_PAD_LEFT);
|
|
});
|
|
}
|
|
}
|
|
|