jikan-rest/app/GenreAnime.php
pushrbx 0211fc4128 multiple fixes
- 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
2023-05-21 11:18:02 +01:00

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'
];
}
}