- crud with custom page - create model and migration for database schema - custom view - company relation from User model
34 lines
831 B
PHP
34 lines
831 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Spatie\MediaLibrary\HasMedia;
|
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
|
|
|
class Company extends Model implements HasMedia
|
|
{
|
|
use InteractsWithMedia, SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function parternMedia(): HasOne
|
|
{
|
|
return $this->hasOne(PartnerMedia::class);
|
|
}
|
|
|
|
public function journalists(): HasManyThrough
|
|
{
|
|
return $this->hasManyThrough(Journalist::class, PartnerMedia::class);
|
|
}
|
|
}
|