-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Improvement] Anime Studio
- Loading branch information
Showing
44 changed files
with
728 additions
and
457 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use App\Models\AnimeStudio; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class AnimeStudioResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @param Request $request | ||
* @return array | ||
*/ | ||
public function toArray($request): array | ||
{ | ||
/** @var AnimeStudio $animeStudio */ | ||
$animeStudio = $this->resource; | ||
|
||
$resource = [ | ||
'id' => $animeStudio->id, | ||
'type' => 'studios', | ||
'href' => route('api.anime.studios', $animeStudio->anime, false), | ||
'attributes' => $animeStudio->only(['is_licensor', 'is_producer', 'is_studio']), | ||
]; | ||
|
||
$relationships = []; | ||
|
||
$relationships = array_merge($relationships, $this->getStudioRelationship()); | ||
|
||
$resource = array_merge($resource, ['relationships' => $relationships]); | ||
|
||
return $resource; | ||
} | ||
|
||
/** | ||
* Returns the person relationship for the resource. | ||
* | ||
* @return array | ||
*/ | ||
protected function getStudioRelationship(): array | ||
{ | ||
/** @var AnimeStudio $animeStudio */ | ||
$animeStudio = $this->resource; | ||
|
||
return [ | ||
'studio' => [ | ||
'href' => route('api.studios.details', $animeStudio, false), | ||
'data' => StudioResourceBasic::make($animeStudio->studio), | ||
] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.