wip multiple image sizes

This commit is contained in:
Irfan 2020-11-24 18:39:59 +05:00
parent 2e119957f2
commit d0777c2074
8 changed files with 10 additions and 37 deletions

View File

@ -20,7 +20,7 @@ class Character extends Model
* @var array
*/
protected $fillable = [
'mal_id', 'url', 'name', 'name_kanji', 'nicknames', 'about', 'member_favorites', 'image_url', 'animeography', 'mangaography', 'voice_actors'
'mal_id', 'url', 'name', 'name_kanji', 'nicknames', 'about', 'member_favorites', 'images', 'animeography', 'mangaography', 'voice_actors'
];
/**
@ -46,22 +46,6 @@ class Character extends Model
'_id', 'trailer_url', 'premiered', 'opening_themes', 'ending_themes', 'images', 'member_favorites'
];
public function getImageAttribute()
{
$imageUrl = $this->attributes['image_url'];
return [
'jpg' => [
'image_url' => $imageUrl,
'small_image_url' => str_replace('.jpg', 't.jpg', $imageUrl),
],
'webp' => [
'image_url' => str_replace('.jpg', '.webp', $imageUrl),
'small_image_url' => str_replace('.jpg', 't.webp', $imageUrl),
]
];
}
public function getFavoritesAttribute()
{
return $this->attributes['member_favorites'];

View File

@ -16,7 +16,7 @@ class Club extends Model
* @var array
*/
protected $fillable = [
'mal_id', 'url', 'image_url', 'title', 'members_count', 'pictures_count', 'category', 'created', 'type', 'staff', 'anime_relations', 'manga_relations', 'character_relations'
'mal_id', 'url', 'images', 'title', 'members_count', 'pictures_count', 'category', 'created', 'type', 'staff', 'anime_relations', 'manga_relations', 'character_relations'
];
/**
@ -39,20 +39,9 @@ class Club extends Model
* @var array
*/
protected $hidden = [
'_id', 'request_hash', 'expiresAt', 'image_url'
'_id', 'request_hash', 'expiresAt', 'images'
];
public function getImageAttribute()
{
$imageUrl = $this->attributes['image_url'];
return [
'jpg' => [
'image_url' => $imageUrl,
],
];
}
public static function scrape(int $id)
{
$data = app('JikanParser')->getClub(new ClubRequest($id));

View File

@ -26,7 +26,7 @@ class PersonVoiceResource extends JsonResource
'character' => [
'mal_id' => $this['character']['mal_id'],
'url' => $this['character']['url'],
'image_url' => $this['character']['image_url'],
'images' => $this['character']['images'],
'name' => $this['character']['name']
]
];

View File

@ -18,7 +18,7 @@ class CreateAnimeTable extends Migration
$table->unique(['request_hash' => 1], 'request_hash');
$table->unique(['mal_id' => 1], 'mal_id');
$table->string('url');
$table->string('image_url');
$table->string('images');
$table->string('trailer_url');
$table->index('title');
$table->index('title_english');

View File

@ -17,7 +17,7 @@ class CreateMangaTable extends Migration
$table->unique(['request_hash' => 1], 'request_hash');
$table->unique(['mal_id' => 1], 'mal_id');
$table->string('url');
$table->string('image_url');
$table->string('images');
$table->index('title');
$table->index('title_english');
$table->index('title_japanese');

View File

@ -17,7 +17,7 @@ class CreatePeopleTable extends Migration
$table->unique(['request_hash' => 1], 'request_hash');
$table->unique(['mal_id' => 1], 'mal_id');
$table->string('url');
$table->string('image_url');
$table->string('images');
$table->string('website_url');
$table->index('name');
$table->string('given_name')->index()->nullable();

View File

@ -17,7 +17,7 @@ class CreateCharactersTable extends Migration
$table->unique(['request_hash' => 1], 'request_hash');
$table->unique(['mal_id' => 1], 'mal_id');
$table->string('url');
$table->string('image_url');
$table->string('images');
$table->index('name');
$table->index('name_kanji');
$table->index('nicknames');

View File

@ -19,7 +19,7 @@ class GenreControllerTest extends TestCase
'mal_id',
'url',
'title',
'image_url',
'images',
'synopsis',
'type',
'airing_start',
@ -68,7 +68,7 @@ class GenreControllerTest extends TestCase
'mal_id',
'url',
'title',
'image_url',
'images',
'synopsis',
'type',
'publishing_start',