33 lines
803 B
PHP
33 lines
803 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Survey extends Model
|
|
{
|
|
protected $fillable = [
|
|
'title',
|
|
'date',
|
|
'user_id',
|
|
'uuid',
|
|
'perincian',
|
|
];
|
|
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::creating(function ($model) {
|
|
if (empty($model->uuid)) {
|
|
$model->uuid = (string) \Illuminate\Support\Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function user() { return $this->belongsTo(User::class); }
|
|
public function sections() { return $this->hasMany(Section::class); }
|
|
public function questions() { return $this->hasManyThrough(Question::class, Section::class); }
|
|
public function responses() { return $this->hasMany(Response::class); }
|
|
}
|