This commit is contained in:
2025-09-18 15:31:27 +02:00
commit 2abba0c2b7
406 changed files with 31879 additions and 0 deletions

72
app/Models/Hentai.php Normal file
View File

@@ -0,0 +1,72 @@
<?php
namespace App\Models;
use Spatie\Sitemap\Contracts\Sitemapable;
use Spatie\Sitemap\Tags\Url;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Conner\Tagging\Taggable;
use Laravelista\Comments\Commentable;
class Hentai extends Model implements Sitemapable
{
use Commentable, Taggable;
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'slug',
'description',
];
public function episodes()
{
return $this->hasMany(Episode::class, 'hentai_id');
}
public function torrents()
{
return $this->hasMany(Torrents::class, 'hentai_id');
}
public function title(): String
{
return $this->episodes->first()->title;
}
/**
* Has a Gallery.
*/
public function gallery()
{
return $this->hasMany(Gallery::class);
}
/**
* Check if hentai contains loli / shota tag
*/
public function isLoliOrShota(): bool
{
$problematicTags = ['Loli', 'Shota'];
return Cache::remember(
"episode:{$this->id}:has_problematic_tags",
now()->addMinutes(1440),
fn () => $this->episodes[0]->tags->pluck('name')->intersect($problematicTags)->isNotEmpty()
);
}
public function toSitemapTag(): Url | string | array
{
return Url::create(route('hentai.index', $this->slug))
->setLastModificationDate(Carbon::create($this->created_at));
}
}