diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/CartoonsController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/CartoonsController.php index 715dc23..bebc732 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/CartoonsController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/CartoonsController.php @@ -23,16 +23,34 @@ class CartoonsController extends Controller public function index() { $data = $this->Cartoons->all()->toArray(); - + $baseUrl = url('/storage/app/media'); - + foreach ($data as &$project) { - $project['image'] = $baseUrl . $project['image']; + $project['list_image'] = $baseUrl . $project['list_image']; + $project['banner_image'] = $baseUrl . $project['banner_image']; + $project['logo'] = $baseUrl . $project['logo']; + $project['main_characters_image'] = $baseUrl . $project['main_characters_image']; + $project['shots_image'] = $baseUrl . $project['shots_image']; + $project['posters_image'] = $baseUrl . $project['posters_image']; + + if(!is_null($project['list_characters'])) + foreach ($project['list_characters'] as &$character) + $character['characters_image'] = $baseUrl . $character['characters_image']; + + if(!is_null($project['list_shots'])) + foreach ($project['list_shots'] as &$shot) + $shot['shot_image'] = $baseUrl . $shot['shot_image']; + + if(!is_null($project['list_shots'])) + foreach ($project['list_posters'] as &$poster) + $poster['image'] = $baseUrl . $poster['image']; } - + return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); } + public function show($id){ $data = $this->Cartoons::find($id); diff --git a/plugins/tps/tps/models/Cartoons.php b/plugins/tps/tps/models/Cartoons.php index 372cdd4..34bce3f 100644 --- a/plugins/tps/tps/models/Cartoons.php +++ b/plugins/tps/tps/models/Cartoons.php @@ -21,4 +21,11 @@ class Cartoons extends Model public $rules = [ ]; + protected $casts = [ + 'list_characters' => 'array', + 'list_shots' => 'array', + 'list_posters' => 'array' + ]; + + } diff --git a/plugins/tps/tps/models/cartoons/fields.yaml b/plugins/tps/tps/models/cartoons/fields.yaml index 2c102d5..b722381 100644 --- a/plugins/tps/tps/models/cartoons/fields.yaml +++ b/plugins/tps/tps/models/cartoons/fields.yaml @@ -3,11 +3,157 @@ fields: label: Name span: auto type: text - image: - label: Image + list_image: + label: 'List image' mode: image thumbOptions: mode: crop extension: auto span: auto type: mediafinder + banner_image: + label: 'Banner image' + mode: image + thumbOptions: + mode: crop + extension: auto + span: auto + type: mediafinder + logo: + label: Logo + mode: image + thumbOptions: + mode: crop + extension: auto + span: auto + type: mediafinder + information_number_1: + label: 'Information number 1' + span: auto + type: text + information_text_1: + label: 'Information text 1' + span: auto + type: text + information_number_2: + label: 'Information number 2' + span: auto + type: text + information_text_2: + label: 'Information text 2' + span: auto + type: text + information_number_3: + label: 'Information number 3' + span: auto + type: text + information_text_3: + label: 'Information text 3' + span: auto + type: text + information: + label: Information + size: small + span: full + type: textarea + main_characters_text: + label: 'Main characters text' + span: auto + type: text + main_characters_image: + label: 'Main characters image' + mode: image + thumbOptions: + mode: crop + extension: auto + span: auto + type: mediafinder + list_characters: + label: 'List characters' + prompt: 'Add new item' + displayMode: accordion + span: full + type: repeater + form: + fields: + characters_image: + label: 'Characters image' + mode: image + thumbOptions: + mode: crop + extension: auto + span: auto + type: mediafinder + character_header: + label: 'Character header' + span: auto + type: text + character_text: + label: 'Character text' + size: '' + span: full + type: textarea + shots_text: + label: 'Shots text' + span: auto + type: text + shots_image: + label: 'Shots image' + mode: image + thumbOptions: + mode: crop + extension: auto + span: auto + type: mediafinder + list_shots: + label: 'List shots' + prompt: 'Add new item' + displayMode: accordion + span: full + type: repeater + form: + fields: + shot_image: + label: 'Shot image' + mode: image + thumbOptions: + mode: crop + extension: auto + span: auto + type: mediafinder + posters_text: + label: 'Posters text' + span: auto + type: text + posters_image: + label: 'Posters image' + mode: file + thumbOptions: + mode: crop + extension: auto + span: auto + type: mediafinder + list_posters: + label: 'List posters' + prompt: 'Add new item' + displayMode: accordion + span: full + type: repeater + form: + fields: + image: + label: poster_image + mode: file + thumbOptions: + mode: crop + extension: auto + span: auto + type: mediafinder + image_type: + label: 'Image type' + options: + horizontal: horizontal + vertical: vertical + span: auto + default: horizontal + type: balloon-selector diff --git a/plugins/tps/tps/updates/builder_table_update_tps_tps_cartoons.php b/plugins/tps/tps/updates/builder_table_update_tps_tps_cartoons.php new file mode 100644 index 0000000..7ca95f6 --- /dev/null +++ b/plugins/tps/tps/updates/builder_table_update_tps_tps_cartoons.php @@ -0,0 +1,23 @@ +renameColumn('image', 'list_image'); + }); + } + + public function down() + { + Schema::table('tps_tps_cartoons', function($table) + { + $table->renameColumn('list_image', 'image'); + }); + } +} diff --git a/plugins/tps/tps/updates/builder_table_update_tps_tps_cartoons_2.php b/plugins/tps/tps/updates/builder_table_update_tps_tps_cartoons_2.php new file mode 100644 index 0000000..cd5b93a --- /dev/null +++ b/plugins/tps/tps/updates/builder_table_update_tps_tps_cartoons_2.php @@ -0,0 +1,57 @@ +string('banner_image')->nullable(); + $table->string('logo')->nullable(); + $table->string('information_number_1')->nullable(); + $table->string('information_number_2')->nullable(); + $table->string('information_number_3')->nullable(); + $table->string('information_text_1')->nullable(); + $table->string('information_text_2')->nullable(); + $table->string('information_text_3')->nullable(); + $table->text('information')->nullable(); + $table->string('main_characters_text')->nullable(); + $table->string('main_characters_image')->nullable(); + $table->text('list_characters')->nullable(); + $table->string('shots_text')->nullable(); + $table->string('shots_image')->nullable(); + $table->string('list_shots')->nullable(); + $table->string('posters_text')->nullable(); + $table->string('posters_image')->nullable(); + $table->text('list_posters')->nullable(); + }); + } + + public function down() + { + Schema::table('tps_tps_cartoons', function($table) + { + $table->dropColumn('banner_image'); + $table->dropColumn('logo'); + $table->dropColumn('information_number_1'); + $table->dropColumn('information_number_2'); + $table->dropColumn('information_number_3'); + $table->dropColumn('information_text_1'); + $table->dropColumn('information_text_2'); + $table->dropColumn('information_text_3'); + $table->dropColumn('information'); + $table->dropColumn('main_characters_text'); + $table->dropColumn('main_characters_image'); + $table->dropColumn('list_characters'); + $table->dropColumn('shots_text'); + $table->dropColumn('shots_image'); + $table->dropColumn('list_shots'); + $table->dropColumn('posters_text'); + $table->dropColumn('posters_image'); + $table->dropColumn('list_posters'); + }); + } +} diff --git a/plugins/tps/tps/updates/version.yaml b/plugins/tps/tps/updates/version.yaml index 1432c54..f7ebdac 100644 --- a/plugins/tps/tps/updates/version.yaml +++ b/plugins/tps/tps/updates/version.yaml @@ -39,3 +39,9 @@ v1.0.13: v1.0.14: - 'Created table tps_tps_contacts' - builder_table_create_tps_tps_contacts_2.php +v1.0.15: + - 'Updated table tps_tps_cartoons' + - builder_table_update_tps_tps_cartoons.php +v1.0.16: + - 'Updated table tps_tps_cartoons' + - builder_table_update_tps_tps_cartoons_2.php