added media, mutation events, agent instructions
This commit is contained in:
@@ -21,7 +21,7 @@ class Dynamic extends Model
|
||||
|
||||
public function participants(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'participants');
|
||||
return $this->belongsToMany(User::class, 'participants')->withPivot('role');
|
||||
}
|
||||
|
||||
public function ledgers(): HasMany
|
||||
|
||||
@@ -29,4 +29,9 @@ class Ledger extends Model
|
||||
{
|
||||
return $this->hasMany(Mutation::class);
|
||||
}
|
||||
|
||||
public function media(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
{
|
||||
return $this->morphMany(Media::class, 'mediable');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class Media extends Model {
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'file_path',
|
||||
'file_name',
|
||||
'mime_type',
|
||||
];
|
||||
|
||||
protected $appends = ['url'];
|
||||
|
||||
public function mediable(): MorphTo {
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function getUrlAttribute(): string {
|
||||
return asset('storage/' . $this->file_path);
|
||||
}
|
||||
}
|
||||
@@ -27,4 +27,9 @@ class Message extends Model
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function media(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
{
|
||||
return $this->morphMany(Media::class, 'mediable');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,11 @@ class Mutation extends Model
|
||||
return $this->morphOne(Chat::class, 'chatable');
|
||||
}
|
||||
|
||||
public function media(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
{
|
||||
return $this->morphMany(Media::class, 'mediable');
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::created(function (Mutation $mutation) {
|
||||
|
||||
Reference in New Issue
Block a user