61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Media extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'media';
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'address',
|
|
'link',
|
|
'type',
|
|
'classification',
|
|
'journalism_organization',
|
|
'journalism_organization_doc',
|
|
'press_council_certificate',
|
|
'press_council_certificate_doc',
|
|
'edit_description',
|
|
'edit_status',
|
|
'company_id'
|
|
];
|
|
|
|
public function company(){
|
|
return $this->belongsTo(Company::class, 'company_id', 'id');
|
|
}
|
|
|
|
public function journalists(){
|
|
return $this->hasMany(Journalist::class, 'media_id', 'id');
|
|
}
|
|
|
|
public function announcements()
|
|
{
|
|
return $this->belongsToMany(Announcement::class, 'announcements_media', 'media_id', 'announcement_id')
|
|
->using(AnnouncementMedia::class)
|
|
->withPivot(['status', 'category'])
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function cooperations()
|
|
{
|
|
return $this->belongsToMany(Cooperation::class, 'media_cooperations', 'media_id', 'cooperation_id')
|
|
->using(MediaCooperation::class)
|
|
->withPivot(['status', 'rejection_reason'])
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function orders()
|
|
{
|
|
return $this->belongsToMany(Order::class, 'media_orders', 'media_id', 'order_id')
|
|
->using(MediaOrder::class)
|
|
->withPivot(['status', 'rejection_reason'])
|
|
->withTimestamps();
|
|
}
|
|
}
|