Nachrichten-Plugin 1.0.0: Direktnachrichten, Gruppen, Anhänge, GIFs, Emojis
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
2844452002
55 changed files with 5448 additions and 0 deletions
27
src/Models/Gif.php
Normal file
27
src/Models/Gif.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Chat\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Inhaus\Plugins\Chat\Gifs;
|
||||
|
||||
#[Fillable(['path', 'title', 'tags', 'width', 'height'])]
|
||||
class Gif extends Model
|
||||
{
|
||||
protected $table = 'chat_gifs';
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
// Maße für die Vorschau im Chat merken; Datei beim Löschen mit entfernen
|
||||
static::saving(function (Gif $gif): void {
|
||||
if ($gif->isDirty('path') && $gif->path && Storage::disk(Gifs::DISK)->exists($gif->path)) {
|
||||
$size = @getimagesize(Storage::disk(Gifs::DISK)->path($gif->path));
|
||||
$gif->width = $size[0] ?? null;
|
||||
$gif->height = $size[1] ?? null;
|
||||
}
|
||||
});
|
||||
static::deleted(fn (Gif $gif) => Storage::disk(Gifs::DISK)->delete($gif->path));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue