work in progress
This commit is contained in:
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Chat;
|
||||
|
||||
class Dynamic extends Model
|
||||
{
|
||||
@@ -64,4 +65,13 @@ class Dynamic extends Model
|
||||
public function getUrlAttribute(): string {
|
||||
return route('dynamics.show', $this);
|
||||
}
|
||||
|
||||
public function getOrCreateChat(): Chat
|
||||
{
|
||||
if ($this->chat) {
|
||||
return $this->chat;
|
||||
}
|
||||
|
||||
return $this->chat()->create([]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user