44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Order extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'orders';
|
|
|
|
protected $fillable = [
|
|
'start_date',
|
|
'end_date',
|
|
'image',
|
|
'task_description',
|
|
'required_reports',
|
|
'cooperation_id',
|
|
'enhancer_id',
|
|
];
|
|
|
|
public function media()
|
|
{
|
|
return $this->belongsToMany(Media::class, 'media_orders', 'order_id', 'media_id')
|
|
->using(MediaOrder::class)
|
|
->withPivot(['status', 'rejection_reason'])
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function cooperation(){
|
|
return $this->belongsTo(Cooperation::class, 'cooperation_id', 'id')->withTrashed();
|
|
}
|
|
|
|
public function reports(){
|
|
return $this->hasMany(Report::class, 'order_id', 'id');
|
|
}
|
|
|
|
public function completions(){
|
|
return $this->hasMany(CooperationCompletion::class, 'order_id', 'id');
|
|
}
|
|
}
|