updated api Cartoons

This commit is contained in:
mrNikto9 2024-07-18 12:16:13 +05:00
parent 8870aa93f6
commit ed1f5f5846
6 changed files with 94 additions and 18 deletions

View File

@ -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){

View File

@ -27,5 +27,9 @@ class Cartoons extends Model
'list_posters' => 'array'
];
public $attachOne = [
'trailer' => 'System\Models\File'
];
}

View File

@ -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

View File

@ -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:

View File

@ -0,0 +1,23 @@
<?php namespace Tps\Tps\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableUpdateTpsTpsCartoons3 extends Migration
{
public function up()
{
Schema::table('tps_tps_cartoons', function($table)
{
$table->string('trailer')->nullable();
});
}
public function down()
{
Schema::table('tps_tps_cartoons', function($table)
{
$table->dropColumn('trailer');
});
}
}

View File

@ -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