36 lines
701 B
PHP
36 lines
701 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Penyakit extends Model
|
|
{
|
|
protected $table = 'penyakit';
|
|
public $timestamps = false;
|
|
|
|
protected $fillable = [
|
|
'kode_penyakit',
|
|
'nama_penyakit',
|
|
'penjelasan',
|
|
'penanganan',
|
|
'gambar'
|
|
];
|
|
|
|
|
|
public function rules()
|
|
{
|
|
return $this->hasMany(Rule::class, 'kode_penyakit', 'kode_penyakit');
|
|
}
|
|
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::creating(function ($penyakit) {
|
|
$count = self::count() + 1;
|
|
$penyakit->kode_penyakit = 'P' . str_pad($count, 2, '0', STR_PAD_LEFT);
|
|
});
|
|
}
|
|
}
|