mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
- updated api docs - fixed top reviews endpoint - fixed reviews parsing - added "contextual" boolean query string parameters, so params without value can be interpreted as "boolean". E.g. ?sfw or ?kid in the url would add "true" value to their corresponding field in the DTO - fixed typesense issues
76 lines
1.4 KiB
PHP
76 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Jenssegers\Mongodb\Eloquent\Model;
|
|
use Jikan\Request\Genre\AnimeGenresRequest;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
/**
|
|
* Class Magazine
|
|
* @package App
|
|
*/
|
|
class GenreAnime extends JikanApiSearchableModel
|
|
{
|
|
use HasFactory;
|
|
|
|
protected array $filters = [];
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'mal_id', 'name', 'url', 'count'
|
|
];
|
|
|
|
/**
|
|
* The table associated with the model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $table = 'genres_anime';
|
|
|
|
|
|
/**
|
|
* The attributes excluded from the model's JSON form.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'_id', 'expiresAt'
|
|
];
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public static function scrape() : array
|
|
{
|
|
$data = app('JikanParser')->getAnimeGenres(new AnimeGenresRequest());
|
|
|
|
return json_decode(
|
|
app('SerializerV4')
|
|
->serialize($data, 'json'),
|
|
true
|
|
);
|
|
}
|
|
|
|
public function toSearchableArray(): array
|
|
{
|
|
return [
|
|
'id' => (string) $this->mal_id,
|
|
'mal_id' => (int) $this->mal_id,
|
|
'name' => $this->name,
|
|
'count' => $this->count
|
|
];
|
|
}
|
|
|
|
public function typesenseQueryBy(): array
|
|
{
|
|
return [
|
|
'name'
|
|
];
|
|
}
|
|
}
|