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.
44 lines
833 B
44 lines
833 B
<?php
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class SupplyDemand extends SoftDeletesModel
|
|
{
|
|
|
|
protected $appends = ['files'];
|
|
protected $casts = ['file_ids' => 'json'];
|
|
|
|
public function getFilesAttribute($value)
|
|
{
|
|
if (empty($this->file_ids)) return [];
|
|
return Upload::whereIn('id', $this->file_ids)->get();
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->hasOne(User::class, 'id', 'user_id');
|
|
}
|
|
|
|
public function keeps()
|
|
{
|
|
return $this->hasMany(SupplyDemandKeep::class, 'supply_demand_id', 'id');
|
|
}
|
|
|
|
|
|
public function messages()
|
|
{
|
|
return $this->hasMany(Message::class, 'supply_demand_id', 'id');
|
|
}
|
|
|
|
public function dialogues()
|
|
{
|
|
return $this->hasMany(Dialogue::class, 'supply_demand_id', 'id');
|
|
}
|
|
|
|
}
|
|
|