You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
494 B

1 year ago
<?php
namespace App\Models;
class Study extends SoftDeletesModel
{
1 year ago
protected $guarded = ['id'];
1 year ago
protected $casts = [
1 year ago
'file' => 'json'
1 year ago
];
1 year ago
protected $appends = ['file_detail'];
1 year ago
1 year ago
public function asks()
1 year ago
{
1 year ago
return $this->hasMany(StudyAsk::class, 'study_id', 'id');
1 year ago
}
1 year ago
public function getFileDetailAttribute()
1 year ago
{
1 year ago
if (empty($this->file)) {
1 year ago
return [];
}
return Upload::whereIn('id', $this->file)->get();
}
}