diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/ContentsController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/ContentsController.php new file mode 100644 index 0000000..0bfae47 --- /dev/null +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/ContentsController.php @@ -0,0 +1,58 @@ +Contents = $Contents; + $this->helpers = $helpers; + } + + public function index(Request $request){ + + $data = $request->all(); + + $validator = Validator::make($data, [ + 'locale' => 'required|in:ru,en,tm', + 'type' => 'required' + ]); + + if($validator->fails()) { + return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validator->errors() ); + } + + $contentType = $request->get('type'); + + $data = response()->json( + ContentResource::collection($this->Contents::where("type", $contentType)->get())); + return $data; + + } + + + + + public static function getAfterFilters() {return [];} + public static function getBeforeFilters() {return [];} + public static function getMiddleware() {return [];} + public function callAction($method, $parameters=false) { + return call_user_func_array(array($this, $method), $parameters); + } + +} diff --git a/plugins/ahmadfatoni/apigenerator/routes.php b/plugins/ahmadfatoni/apigenerator/routes.php index 6025299..b9d3df6 100644 --- a/plugins/ahmadfatoni/apigenerator/routes.php +++ b/plugins/ahmadfatoni/apigenerator/routes.php @@ -9,3 +9,5 @@ Route::get('api/v1/categories/{id}/delete', ['as' => 'api/v1/categories.delete', Route::resource('api/v1/posts', 'AhmadFatoni\ApiGenerator\Controllers\API\PostsController', ['except' => ['destroy', 'create', 'edit']]); Route::get('api/v1/posts/{id}/delete', ['as' => 'api/v1/posts.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\PostsController@destroy']); + +Route::resource('api/v1/content', 'AhmadFatoni\ApiGenerator\Controllers\API\ContentsController', ['except' => ['destroy', 'create', 'edit']]); diff --git a/plugins/tps/hhm/Plugin.php b/plugins/tps/hhm/Plugin.php new file mode 100644 index 0000000..f8c6658 --- /dev/null +++ b/plugins/tps/hhm/Plugin.php @@ -0,0 +1,14 @@ +get('locale'); + + return [ + 'id' => $this->id, + 'content' => $this->getAttributeTranslated('content', $locale), + 'type' => $this->type + ]; + } +} diff --git a/plugins/tps/hhm/controllers/Contents.php b/plugins/tps/hhm/controllers/Contents.php new file mode 100644 index 0000000..a445714 --- /dev/null +++ b/plugins/tps/hhm/controllers/Contents.php @@ -0,0 +1,18 @@ + + = e(trans('backend::lang.form.create')) ?> + + diff --git a/plugins/tps/hhm/controllers/contents/config_form.yaml b/plugins/tps/hhm/controllers/contents/config_form.yaml new file mode 100644 index 0000000..0ae2201 --- /dev/null +++ b/plugins/tps/hhm/controllers/contents/config_form.yaml @@ -0,0 +1,10 @@ +name: Contents +form: $/tps/hhm/models/contents/fields.yaml +modelClass: Tps\Hhm\Models\Contents +defaultRedirect: tps/hhm/contents +create: + redirect: 'tps/hhm/contents/update/:id' + redirectClose: tps/hhm/contents +update: + redirect: tps/hhm/contents + redirectClose: tps/hhm/contents diff --git a/plugins/tps/hhm/controllers/contents/config_list.yaml b/plugins/tps/hhm/controllers/contents/config_list.yaml new file mode 100644 index 0000000..522cda3 --- /dev/null +++ b/plugins/tps/hhm/controllers/contents/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/hhm/models/contents/columns.yaml +modelClass: Tps\Hhm\Models\Contents +title: Contents +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'tps/hhm/contents/update/:id' diff --git a/plugins/tps/hhm/controllers/contents/create.htm b/plugins/tps/hhm/controllers/contents/create.htm new file mode 100644 index 0000000..7bc33b4 --- /dev/null +++ b/plugins/tps/hhm/controllers/contents/create.htm @@ -0,0 +1,46 @@ + +
= e(trans('backend::lang.form.return_to_list')) ?>
+ \ No newline at end of file diff --git a/plugins/tps/hhm/controllers/contents/index.htm b/plugins/tps/hhm/controllers/contents/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/plugins/tps/hhm/controllers/contents/index.htm @@ -0,0 +1 @@ += $this->listRender() ?> diff --git a/plugins/tps/hhm/controllers/contents/preview.htm b/plugins/tps/hhm/controllers/contents/preview.htm new file mode 100644 index 0000000..3ba0dc1 --- /dev/null +++ b/plugins/tps/hhm/controllers/contents/preview.htm @@ -0,0 +1,22 @@ + ++ + = e(trans('backend::lang.form.return_to_list')) ?> + +
\ No newline at end of file diff --git a/plugins/tps/hhm/controllers/contents/update.htm b/plugins/tps/hhm/controllers/contents/update.htm new file mode 100644 index 0000000..839ecfb --- /dev/null +++ b/plugins/tps/hhm/controllers/contents/update.htm @@ -0,0 +1,54 @@ + +