diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/CartoonsController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/CartoonsController.php index 33c993d..88ef6a3 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/CartoonsController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/CartoonsController.php @@ -43,19 +43,46 @@ class CartoonsController extends Controller return $this->helpers->apiArrayResponseBuilder(200, 'success', $filteredData); } - - - public function show($id){ - + public function show($id) + { $data = $this->Cartoons::find($id); + $baseUrl = url('/storage/app/media'); - if (!is_null($data)){ - return $this->helpers->apiArrayResponseBuilder(200, 'success', [$data]); + if (!is_null($data)) { + $dataArray = $data->toArray(); + + // Update the image URLs + $dataArray['list_image'] = $baseUrl . $dataArray['list_image']; + $dataArray['banner_image'] = $baseUrl . $dataArray['banner_image']; + $dataArray['logo'] = $baseUrl . $dataArray['logo']; + $dataArray['main_characters_image'] = $baseUrl . $dataArray['main_characters_image']; + $dataArray['shots_image'] = $baseUrl . $dataArray['shots_image']; + $dataArray['posters_image'] = $baseUrl . $dataArray['posters_image']; + + if (!is_null($dataArray['list_characters'])) { + foreach ($dataArray['list_characters'] as &$character) { + foreach ($character['character_images'] as &$character_image) { + $character_image['image'] = $baseUrl . $character_image['image']; + } + } + } + + if (!is_null($dataArray['list_shots'])) { + foreach ($dataArray['list_shots'] as &$shot) { + $shot['shot_image'] = $baseUrl . $shot['shot_image']; + } + } + + if (!is_null($dataArray['list_posters'])) { + foreach ($dataArray['list_posters'] as &$poster) { + $poster['image'] = $baseUrl . $poster['image']; + } + } + + return $this->helpers->apiArrayResponseBuilder(200, 'success', [$dataArray]); } else { - return $this->helpers->apiArrayResponseBuilder(404, 'error', [$data]); - + return $this->helpers->apiArrayResponseBuilder(404, 'error', null); } - } public function store(Request $request){ diff --git a/plugins/tps/tps/models/Cartoons.php b/plugins/tps/tps/models/Cartoons.php index 34bce3f..c0b3c6b 100644 --- a/plugins/tps/tps/models/Cartoons.php +++ b/plugins/tps/tps/models/Cartoons.php @@ -27,5 +27,9 @@ class Cartoons extends Model 'list_posters' => 'array' ]; + public $attachOne = [ + 'trailer' => 'System\Models\File' + ]; + } diff --git a/plugins/tps/tps/models/cartoons/fields.yaml b/plugins/tps/tps/models/cartoons/fields.yaml index b722381..5b8d091 100644 --- a/plugins/tps/tps/models/cartoons/fields.yaml +++ b/plugins/tps/tps/models/cartoons/fields.yaml @@ -76,14 +76,23 @@ fields: type: repeater form: fields: - characters_image: - label: 'Characters image' - mode: image - thumbOptions: - mode: crop - extension: auto + character_images: + label: 'Character images' + prompt: 'Add new item' + maxItems: '3' + displayMode: accordion span: auto - type: mediafinder + type: repeater + form: + fields: + image: + label: Image + mode: image + thumbOptions: + mode: crop + extension: auto + span: auto + type: mediafinder character_header: label: 'Character header' span: auto @@ -136,6 +145,7 @@ fields: list_posters: label: 'List posters' prompt: 'Add new item' + maxItems: '3' displayMode: accordion span: full type: repeater @@ -143,7 +153,7 @@ fields: fields: image: label: poster_image - mode: file + mode: image thumbOptions: mode: crop extension: auto @@ -157,3 +167,12 @@ fields: span: auto default: horizontal type: balloon-selector + trailer: + label: Trailer + mode: file + useCaption: true + thumbOptions: + mode: crop + extension: auto + span: auto + type: fileupload diff --git a/plugins/tps/tps/plugin.yaml b/plugins/tps/tps/plugin.yaml index ecb66d5..2b4ef1f 100644 --- a/plugins/tps/tps/plugin.yaml +++ b/plugins/tps/tps/plugin.yaml @@ -27,7 +27,7 @@ navigation: url: tps/tps/partnerscontroller icon: icon-bank side-menu-item5: - label: Cartoons + label: 'Main Projects' url: tps/tps/cartoonscontroller icon: icon-image side-menu-item6: diff --git a/plugins/tps/tps/updates/builder_table_update_tps_tps_cartoons_3.php b/plugins/tps/tps/updates/builder_table_update_tps_tps_cartoons_3.php new file mode 100644 index 0000000..140bf78 --- /dev/null +++ b/plugins/tps/tps/updates/builder_table_update_tps_tps_cartoons_3.php @@ -0,0 +1,23 @@ +string('trailer')->nullable(); + }); + } + + public function down() + { + Schema::table('tps_tps_cartoons', function($table) + { + $table->dropColumn('trailer'); + }); + } +} diff --git a/plugins/tps/tps/updates/version.yaml b/plugins/tps/tps/updates/version.yaml index f7ebdac..9a20c56 100644 --- a/plugins/tps/tps/updates/version.yaml +++ b/plugins/tps/tps/updates/version.yaml @@ -45,3 +45,6 @@ v1.0.15: v1.0.16: - 'Updated table tps_tps_cartoons' - builder_table_update_tps_tps_cartoons_2.php +v1.0.17: + - 'Updated table tps_tps_cartoons' + - builder_table_update_tps_tps_cartoons_3.php