first commit
This commit is contained in:
32
app/Models/Survey.php
Normal file
32
app/Models/Survey.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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); }
|
||||
}
|
||||
Reference in New Issue
Block a user