diff --git a/app/Http/Controllers/Admin/ContactCrudController.php b/app/Http/Controllers/Admin/ContactCrudController.php index 5fa183c..2c8f422 100644 --- a/app/Http/Controllers/Admin/ContactCrudController.php +++ b/app/Http/Controllers/Admin/ContactCrudController.php @@ -60,22 +60,12 @@ class ContactCrudController extends CrudController CRUD::setValidation(ContactRequest::class); CRUD::field('name'); - CRUD::field('contacts')->type('repeatable')->fields([ - [ // Table - 'name' => 'contact', - 'label' => 'Contact', - 'type' => 'table', - 'entity_singular' => 'contact', - 'columns' => [ - 'title' => 'Title', - 'phone' => 'Phone', - 'mail' => 'Mail', - 'fax' => 'Fax' - ], - 'max' => 2, // maximum rows allowed in the table - 'min' => 1, // minimum rows allowed in the table - ], - ])->new_item_label("Add contact"); + CRUD::field('contacts')->type('table')->columns([ + 'title' => 'Title', + 'phone' => 'Phone', + 'mail' => 'Mail', + 'fax' => 'Fax' + ])->entity_singular('contact')->max(2)->min(1)->new_item_label("Add contact"); /** * Fields can be defined using the fluent syntax or array syntax: diff --git a/app/Http/Controllers/Api/ContactController.php b/app/Http/Controllers/Api/ContactController.php new file mode 100644 index 0000000..5dcf943 --- /dev/null +++ b/app/Http/Controllers/Api/ContactController.php @@ -0,0 +1,15 @@ +get(); + return $this->respondWithCollection($contacts, new ContactTransformer($this->locale)); + } +} diff --git a/app/Http/Controllers/Api/DocumentController.php b/app/Http/Controllers/Api/DocumentController.php index 8d35987..b186fff 100644 --- a/app/Http/Controllers/Api/DocumentController.php +++ b/app/Http/Controllers/Api/DocumentController.php @@ -12,5 +12,4 @@ class DocumentController extends ApiController $documents = Document::orderBy('lft', 'desc')->get(); return $this->respondWithCollection($documents, new DocumentTransformer($this->locale)); } - } diff --git a/app/Http/Controllers/Api/MultimediaCategoryController.php b/app/Http/Controllers/Api/MultimediaCategoryController.php index affcc37..a3ccfbd 100644 --- a/app/Http/Controllers/Api/MultimediaCategoryController.php +++ b/app/Http/Controllers/Api/MultimediaCategoryController.php @@ -8,11 +8,9 @@ use App\Transformers\CategoryTransformer; class MultimediaCategoryController extends ApiController { - public function index() { $categories = MultimediaCategory::orderBy('lft', 'desc')->get(); return $this->respondWithCollection($categories, new CategoryTransformer($this->locale, 'media')); } - } diff --git a/app/Http/Controllers/Api/MultimediaController.php b/app/Http/Controllers/Api/MultimediaController.php index b2e7dae..98584ea 100644 --- a/app/Http/Controllers/Api/MultimediaController.php +++ b/app/Http/Controllers/Api/MultimediaController.php @@ -12,5 +12,4 @@ class MultimediaController extends ApiController $medias = MultimediaCategory::where('id', $category)->with('medias')->get()->first()->medias; return $this->respondWithCollection($medias, new MediaTransformer()); } - } diff --git a/app/Http/Controllers/Api/TarifController.php b/app/Http/Controllers/Api/TarifController.php index 5b02a36..1d79a9e 100644 --- a/app/Http/Controllers/Api/TarifController.php +++ b/app/Http/Controllers/Api/TarifController.php @@ -18,5 +18,4 @@ class TarifController extends ApiController } return $this->respondWithCollection($tarifs, new TarifTransformer($this->locale)); } - } diff --git a/app/Http/Controllers/Api/TradingsController.php b/app/Http/Controllers/Api/TradingsController.php index 23ecd4d..baeac4d 100644 --- a/app/Http/Controllers/Api/TradingsController.php +++ b/app/Http/Controllers/Api/TradingsController.php @@ -78,8 +78,6 @@ class TradingsController extends ApiController return $this->errorNotFound(); } return $this->errorWrongArgs(); - - } function getPercentageDifference($new, $old){ return (($new - $old) / abs($old)) * 100; diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php deleted file mode 100644 index 6e127c4..0000000 --- a/app/Http/Controllers/ContactController.php +++ /dev/null @@ -1,86 +0,0 @@ -type == 'trading' ? [ 'id' => $category->id, - 'title' => $category->getTranslations('title', [$this->locale])[$this->locale], + 'title' => $category->getTranslations('title', [$this->locale])[$this->locale] ?? '-', ] : [ 'id' => $category->id, - 'title' => $category->getTranslations('title', [$this->locale])[$this->locale], + 'title' => $category->getTranslations('title', [$this->locale])[$this->locale] ?? '-', 'type' => $category->type, ]; } diff --git a/app/Transformers/ContactTransformer.php b/app/Transformers/ContactTransformer.php new file mode 100644 index 0000000..233d42e --- /dev/null +++ b/app/Transformers/ContactTransformer.php @@ -0,0 +1,27 @@ +locale = $locale; + } + + public function transform(Contact $contact) + { + $translatedContact = $contact->getTranslations('contacts',[$this->locale]); + $contacts = $translatedContact ? json_decode($translatedContact[$this->locale], true) : []; + return [ + 'id' => $contact->id, + 'name' => $contact->getTranslations('name',[$this->locale])[$this->locale] ?? '-', + 'contacts' => $contacts, + ]; + } +} \ No newline at end of file diff --git a/app/Transformers/DocumentTransformer.php b/app/Transformers/DocumentTransformer.php index 4e24ce4..47b1cba 100644 --- a/app/Transformers/DocumentTransformer.php +++ b/app/Transformers/DocumentTransformer.php @@ -17,11 +17,12 @@ class DocumentTransformer extends TransformerAbstract public function transform(Document $document) { - $file = Str::replaceFirst('public/', '', $document->getTranslations('file',[$this->locale])[$this->locale]); + $translatedFile = $document->getTranslations('file',[$this->locale]); + $file = $translatedFile ? url(Str::replaceFirst('public/', '', $translatedFile[$this->locale])) : '-'; return [ 'id' => $document->id, - 'title' => $document->getTranslations('title',[$this->locale]), - 'file' => url($file), + 'title' => $document->getTranslations('title',[$this->locale])[$this->locale] ?? '-', + 'file' => $file, ]; } } \ No newline at end of file diff --git a/app/Transformers/NewsTransformer.php b/app/Transformers/NewsTransformer.php index 079a410..223f6be 100644 --- a/app/Transformers/NewsTransformer.php +++ b/app/Transformers/NewsTransformer.php @@ -18,9 +18,9 @@ class NewsTransformer extends TransformerAbstract { return [ 'id' => $news->id, - 'title' => $news->getTranslations('title', [$this->locale]), - 'short_description' => $news->getTranslations('short_description', [$this->locale]), - 'description' => $news->getTranslations('description', [$this->locale]), + 'title' => $news->getTranslations('title', [$this->locale])[$this->locale] ?? '-', + 'short_description' => $news->getTranslations('short_description', [$this->locale])[$this->locale] ?? '-', + 'description' => $news->getTranslations('description', [$this->locale])[$this->locale] ?? '-', 'date' => $news->date, 'image' => url($news->image), ]; diff --git a/app/Transformers/TarifTransformer.php b/app/Transformers/TarifTransformer.php index c6a25df..4eda85d 100644 --- a/app/Transformers/TarifTransformer.php +++ b/app/Transformers/TarifTransformer.php @@ -19,8 +19,8 @@ class TarifTransformer extends TransformerAbstract return [ 'id' => $tarif->id, 'type' => $tarif->type, - 'title' => $tarif->getTranslations('title', [$this->locale]), - 'prices' => $tarif->getTranslations('prices', [$this->locale]), + 'title' => $tarif->getTranslations('title', [$this->locale])[$this->locale] ?? '-', + 'prices' => $tarif->getTranslations('prices', [$this->locale])[$this->locale] ?? [], ]; } } \ No newline at end of file diff --git a/app/Transformers/TradingTransformer.php b/app/Transformers/TradingTransformer.php index 8587b5e..73aea7e 100644 --- a/app/Transformers/TradingTransformer.php +++ b/app/Transformers/TradingTransformer.php @@ -9,7 +9,7 @@ class TradingTransformer extends TransformerAbstract { private $type; - public function __construct($type='') + public function __construct($type = '') { $this->type = $type; } diff --git a/bootstrap/cache/packages.php b/bootstrap/cache/packages.php old mode 100755 new mode 100644 diff --git a/bootstrap/cache/services.php b/bootstrap/cache/services.php old mode 100755 new mode 100644 diff --git a/config/app.php b/config/app.php index 66365e4..48ea3a0 100644 --- a/config/app.php +++ b/config/app.php @@ -82,7 +82,7 @@ return [ | */ - 'locale' => 'tm', + 'locale' => 'ru', 'locales' => ['en','ru','tm'], /* diff --git a/database/migrations/2022_12_05_113105_create_contacts_table.php b/database/migrations/2022_12_05_113105_create_contacts_table.php index 035c9d5..56b15a0 100644 --- a/database/migrations/2022_12_05_113105_create_contacts_table.php +++ b/database/migrations/2022_12_05_113105_create_contacts_table.php @@ -17,6 +17,10 @@ class CreateContactsTable extends Migration $table->id(); $table->text('name'); $table->longText('contacts'); + $table->integer('parent_id')->default(0)->nullable(); + $table->integer('lft')->default(0); + $table->integer('rgt')->default(0); + $table->integer('depth')->default(0); $table->timestamps(); }); } diff --git a/routes/api.php b/routes/api.php index c54068f..a90e184 100644 --- a/routes/api.php +++ b/routes/api.php @@ -8,6 +8,7 @@ use App\Http\Controllers\Api\ImportController; use App\Http\Controllers\Api\TradingsController; use App\Http\Controllers\Api\NewsController; use App\Http\Controllers\Api\CategoryController; +use App\Http\Controllers\Api\ContactController; use App\Http\Controllers\Api\DocumentController; use App\Http\Controllers\Api\TarifController; use App\Http\Controllers\Api\MultimediaCategoryController; @@ -34,9 +35,12 @@ Route::get('other-filters', [FiltersController::class, 'otherFilters']); Route::get('categories', [CategoryController::class, 'index']); Route::get('tradings', [TradingsController::class, 'index']); Route::get('categories/{id}/tradings', [TradingsController::class, 'selectedTradings']); -Route::get('news', [NewsController::class, 'index']); -Route::get('documents', [DocumentController::class, 'index']); -Route::get('tariffs', [TarifController::class, 'index']); Route::get('media/categories', [MultimediaCategoryController::class, 'index']); Route::get('medias/{category}', [MultimediaController::class, 'index']); + +Route::get('news', [NewsController::class, 'index']); +Route::get('documents', [DocumentController::class, 'index']); +Route::get('tariffs', [TarifController::class, 'index']); +Route::get('contacts', [ContactController::class, 'index']); + diff --git a/storage/app/settings.json b/storage/app/settings.json old mode 100755 new mode 100644 diff --git a/storage/app/setup.json b/storage/app/setup.json old mode 100755 new mode 100644