diff --git a/composer.json b/composer.json index d1c4bc5..98e408d 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,10 @@ ] }, "config": { - "preferred-install": "dist" + "preferred-install": "dist", + "allow-plugins": { + "composer/installers": true + } }, "minimum-stability": "dev", "prefer-stable": true diff --git a/config/database.php b/config/database.php index f967969..4565885 100644 --- a/config/database.php +++ b/config/database.php @@ -58,7 +58,7 @@ return [ 'host' => 'localhost', 'port' => 3306, 'database' => 'airport2023', - 'username' => 'root', + 'username' => 'shohrat', 'password' => 'bt110226', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/postController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/postController.php new file mode 100644 index 0000000..53ac852 --- /dev/null +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/postController.php @@ -0,0 +1,116 @@ +Content = $Content; + $this->helpers = $helpers; + } + + protected function validateForm($data, $rules) + { + return Validator::make($data, $rules); + } + + public function index(Request $request) + { + $dataVal = $request->all(); + + + $data = Post::with(['categories:id,name', 'featured_images']) + ->where('published', 1) + ->select('id', 'title', 'published_at', 'slug', 'excerpt') + ->orderBy('published_at', 'desc') + ->with('views') + ->paginate($dataVal["per_page"] ?? 6); + + + //$data->translateContext($dataVal["locale"]); + if($data){ + $data->each(function ($item, $key) use($dataVal) { + $item->translateContext($dataVal["locale"] ?? 'ru'); + }); + } + + if (count($data) != 0) { + // return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); + return response()->json($data, 200); + } else { + return $this->helpers->apiArrayResponseBuilder(404, 'not found data', []); + } + } + + + public function getPost(Request $request, $id) + { + $dataVal = $request->all(); + + $data = Post::with(['categories:id,name', 'featured_images']) + ->select('id', 'title', 'published_at', 'slug', 'excerpt', 'content_html') + ->with('views') + ->find($id); + + + if($data){ + $obj = Db::table('vdomah_blogviews_views') + ->where('post_id', $id); + + if ($obj->count() > 0) { + $row = $obj->first(); + + // $views = $row->views + rand(1,10);; + + $views = $row->views + 1;; + + $obj->update(['views' => $views]); + // $data['views'] = $row->views; + } + else { + + Db::table('vdomah_blogviews_views')->insert([ + 'post_id' => $data->getKey(), + 'views' => 1 + ]); + + //$data['views'] = 0; + } + + + + $data->translateContext($dataVal["locale"] ?? 'ru'); + + return response()->json($data, 200); + //return $this->helpers->apiArrayResponseBuilder(200, 'success', [$data]); + }else{ + + return $this->helpers->apiArrayResponseBuilder(404, 'not found data', []); + } + + } + + + +} diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/sectionController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/sectionController.php index e4b9587..34ef62d 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/sectionController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/sectionController.php @@ -9,6 +9,7 @@ use Illuminate\Http\Request; use AhmadFatoni\ApiGenerator\Helpers\Helpers; use Illuminate\Support\Facades\Validator; use tps\Airport\Models\Content; +use tps\Airport\Models\Menu; use Config; @@ -32,15 +33,16 @@ class sectionController extends Controller public function index(Request $request) { - $path = 'http://localhost:8000' . Config::get('cms.storage.media.path'); + $path = 'http://216.250.8.104:8081' . Config::get('cms.storage.media.path'); - $data = $request->all(); + $dataVal = $request->all(); $rules = [ 'page' => 'required', + //'locale' => 'required' ]; - $validator = $this->validateForm($data, $rules); + $validator = $this->validateForm($dataVal, $rules); if ($validator->fails()) { return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validator->errors()); } @@ -54,15 +56,43 @@ class sectionController extends Controller $dataq = json_decode($data); for ($i = 0; $i < count($data[0]->data); $i++) { - if ($dataq[0]->data[$i]->section_id != null) { - $modified = $dataq[0]->data[$i]->section::where('id', $dataq[0]->data[$i]->section_id)->with('translations:locale,model_id,attribute_data')->first(); + if ($dataq[0]->data[$i]->section_id != null && $dataq[0]->data[$i]->flight_type == 0) { + $modified = $dataq[0]->data[$i]->section::where('id', $dataq[0]->data[$i]->section_id)->first(); + + $modified->translateContext($dataVal["locale"] ?? 'ru'); + $modified->makeHidden(['created_at', 'updated_at', 'deleted_at']); $contents = array_merge($contents, array($modified)); // dump($testq); - } else { - $modified = $dataq[0]->data[$i]->section::select('id', 'title', 'slug', 'excerpt', 'published_at', 'type')->orderBy('published_at', 'desc')->limit($dataq[0]->data[$i]->limit)->with('translations:locale,model_id,attribute_data')->get(); + } + else if($dataq[0]->data[$i]->flight_type == 1 && $dataq[0]->data[$i]->section_id == null){ + $modified = $dataq[0]->data[$i]->section::where('type_flight', input("flight_type"))->first(); + + $modified->translateContext($dataVal["locale"] ?? 'ru'); $contents = array_merge($contents, array($modified)); } + else{ + + $modified = $dataq[0]->data[$i]->section::select('id', 'title', 'slug', 'excerpt', 'published_at', 'type') + ->orderBy('published_at', 'desc') + ->limit($dataq[0]->data[$i]->limit) + ->with(['featured_images']) + ->with('views') + ->get(); + + + if($modified){ + $modified->each(function ($item, $key) use($dataVal) { + $item->translateContext($dataVal["locale"] ?? 'ru'); + }); + } + + $post_section = array( + "type"=> "post", + "posts"=> $modified + ); + $contents = array_merge($contents, array($post_section)); + } } $data[0]->section_contents = $contents; @@ -74,4 +104,29 @@ class sectionController extends Controller return $this->helpers->apiArrayResponseBuilder(404, 'not found data', []); } } + + + + public function getMenu(Request $request) + { + $dataVal = $request->all(); + + $data = Menu::select('id', 'name', 'sub_menu', 'order', 'menu_slug', 'status') + ->orderBy('order', 'asc') + ->get(); + + if (count($data) != 0) { + + + $data->each(function ($item, $key) use($dataVal) { + $item->translateContext($dataVal["locale"] ?? 'ru'); + }); + + + return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); + + } else { + return $this->helpers->apiArrayResponseBuilder(404, 'not found data', []); + } + } } diff --git a/plugins/ahmadfatoni/apigenerator/routes.php b/plugins/ahmadfatoni/apigenerator/routes.php index 878b56b..8dac1f4 100644 --- a/plugins/ahmadfatoni/apigenerator/routes.php +++ b/plugins/ahmadfatoni/apigenerator/routes.php @@ -4,4 +4,8 @@ Route::post('fatoni/generate/api', array('as' => 'fatoni.generate.api', 'uses' = Route::post('fatoni/update/api/{id}', array('as' => 'fatoni.update.api', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\ApiGeneratorController@updateApi')); Route::get('fatoni/delete/api/{id}', array('as' => 'fatoni.delete.api', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\ApiGeneratorController@deleteApi')); +Route::get('api/posts', 'AhmadFatoni\ApiGenerator\Controllers\API\postController@index'); +Route::get('api/posts/{id}', 'AhmadFatoni\ApiGenerator\Controllers\API\postController@getPost'); + Route::get('api/sections', 'AhmadFatoni\ApiGenerator\Controllers\API\sectionController@index'); +Route::get('api/menu', 'AhmadFatoni\ApiGenerator\Controllers\API\sectionController@getMenu'); diff --git a/plugins/rainlab/blog/models/Post.php b/plugins/rainlab/blog/models/Post.php index bf8db6d..2aab7e5 100644 --- a/plugins/rainlab/blog/models/Post.php +++ b/plugins/rainlab/blog/models/Post.php @@ -15,6 +15,7 @@ use Cms\Classes\Controller; use October\Rain\Database\NestedTreeScope; use RainLab\Blog\Classes\TagProcessor; use ValidationException; +use Vdomah\BlogViews\Models\BlogView; /** * Class Post @@ -81,7 +82,14 @@ class Post extends Model public $belongsTo = [ 'user' => BackendUser::class ]; - + + public $hasMany = [ + 'views' => [ + BlogView::class, + 'table' => 'vdomah_blogviews_views', + 'key'=> 'post_id' + ] + ]; public $belongsToMany = [ 'categories' => [ Category::class, diff --git a/plugins/tps/airport/controllers/Accardion.php b/plugins/tps/airport/controllers/Accardion.php new file mode 100644 index 0000000..ce37602 --- /dev/null +++ b/plugins/tps/airport/controllers/Accardion.php @@ -0,0 +1,18 @@ + + = e(trans('backend::lang.form.create')) ?> + + diff --git a/plugins/tps/airport/controllers/accardion/config_form.yaml b/plugins/tps/airport/controllers/accardion/config_form.yaml new file mode 100644 index 0000000..3f0e461 --- /dev/null +++ b/plugins/tps/airport/controllers/accardion/config_form.yaml @@ -0,0 +1,10 @@ +name: Accardion +form: $/tps/airport/models/accardion/fields.yaml +modelClass: tps\Airport\Models\Accardion +defaultRedirect: tps/airport/accardion +create: + redirect: 'tps/airport/accardion/update/:id' + redirectClose: tps/airport/accardion +update: + redirect: tps/airport/accardion + redirectClose: tps/airport/accardion diff --git a/plugins/tps/airport/controllers/accardion/config_list.yaml b/plugins/tps/airport/controllers/accardion/config_list.yaml new file mode 100644 index 0000000..f77c699 --- /dev/null +++ b/plugins/tps/airport/controllers/accardion/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/airport/models/accardion/columns.yaml +modelClass: tps\Airport\Models\Accardion +title: Accardion +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/airport/accardion/update/:id' diff --git a/plugins/tps/airport/controllers/accardion/create.htm b/plugins/tps/airport/controllers/accardion/create.htm new file mode 100644 index 0000000..58f2e7e --- /dev/null +++ b/plugins/tps/airport/controllers/accardion/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/airport/controllers/accardion/index.htm b/plugins/tps/airport/controllers/accardion/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/plugins/tps/airport/controllers/accardion/index.htm @@ -0,0 +1 @@ += $this->listRender() ?> diff --git a/plugins/tps/airport/controllers/accardion/preview.htm b/plugins/tps/airport/controllers/accardion/preview.htm new file mode 100644 index 0000000..b0431a5 --- /dev/null +++ b/plugins/tps/airport/controllers/accardion/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/airport/controllers/accardion/update.htm b/plugins/tps/airport/controllers/accardion/update.htm new file mode 100644 index 0000000..71760d6 --- /dev/null +++ b/plugins/tps/airport/controllers/accardion/update.htm @@ -0,0 +1,54 @@ + += e(trans('backend::lang.form.return_to_list')) ?>
+ \ No newline at end of file diff --git a/plugins/tps/airport/controllers/flights/_list_toolbar.htm b/plugins/tps/airport/controllers/flights/_list_toolbar.htm new file mode 100644 index 0000000..1d8ba21 --- /dev/null +++ b/plugins/tps/airport/controllers/flights/_list_toolbar.htm @@ -0,0 +1,18 @@ + diff --git a/plugins/tps/airport/controllers/flights/config_form.yaml b/plugins/tps/airport/controllers/flights/config_form.yaml new file mode 100644 index 0000000..7991040 --- /dev/null +++ b/plugins/tps/airport/controllers/flights/config_form.yaml @@ -0,0 +1,10 @@ +name: Flights +form: $/tps/airport/models/flights/fields.yaml +modelClass: tps\Airport\Models\Flights +defaultRedirect: tps/airport/flights +create: + redirect: 'tps/airport/flights/update/:id' + redirectClose: tps/airport/flights +update: + redirect: tps/airport/flights + redirectClose: tps/airport/flights diff --git a/plugins/tps/airport/controllers/flights/config_list.yaml b/plugins/tps/airport/controllers/flights/config_list.yaml new file mode 100644 index 0000000..839f44c --- /dev/null +++ b/plugins/tps/airport/controllers/flights/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/airport/models/flights/columns.yaml +modelClass: tps\Airport\Models\Flights +title: Flights +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/airport/flights/update/:id' diff --git a/plugins/tps/airport/controllers/flights/create.htm b/plugins/tps/airport/controllers/flights/create.htm new file mode 100644 index 0000000..b5ff6d9 --- /dev/null +++ b/plugins/tps/airport/controllers/flights/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/airport/controllers/flights/index.htm b/plugins/tps/airport/controllers/flights/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/plugins/tps/airport/controllers/flights/index.htm @@ -0,0 +1 @@ += $this->listRender() ?> diff --git a/plugins/tps/airport/controllers/flights/preview.htm b/plugins/tps/airport/controllers/flights/preview.htm new file mode 100644 index 0000000..56d294b --- /dev/null +++ b/plugins/tps/airport/controllers/flights/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/airport/controllers/flights/update.htm b/plugins/tps/airport/controllers/flights/update.htm new file mode 100644 index 0000000..4076181 --- /dev/null +++ b/plugins/tps/airport/controllers/flights/update.htm @@ -0,0 +1,54 @@ + += e(trans('backend::lang.form.return_to_list')) ?>
+ \ No newline at end of file diff --git a/plugins/tps/airport/controllers/pagecontent/_list_toolbar.htm b/plugins/tps/airport/controllers/pagecontent/_list_toolbar.htm new file mode 100644 index 0000000..b1508fb --- /dev/null +++ b/plugins/tps/airport/controllers/pagecontent/_list_toolbar.htm @@ -0,0 +1,18 @@ + diff --git a/plugins/tps/airport/controllers/pagecontent/config_form.yaml b/plugins/tps/airport/controllers/pagecontent/config_form.yaml new file mode 100644 index 0000000..4c66dd9 --- /dev/null +++ b/plugins/tps/airport/controllers/pagecontent/config_form.yaml @@ -0,0 +1,10 @@ +name: PageContent +form: $/tps/airport/models/pagecontent/fields.yaml +modelClass: tps\Airport\Models\PageContent +defaultRedirect: tps/airport/pagecontent +create: + redirect: 'tps/airport/pagecontent/update/:id' + redirectClose: tps/airport/pagecontent +update: + redirect: tps/airport/pagecontent + redirectClose: tps/airport/pagecontent diff --git a/plugins/tps/airport/controllers/pagecontent/config_list.yaml b/plugins/tps/airport/controllers/pagecontent/config_list.yaml new file mode 100644 index 0000000..d6fa110 --- /dev/null +++ b/plugins/tps/airport/controllers/pagecontent/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/airport/models/pagecontent/columns.yaml +modelClass: tps\Airport\Models\PageContent +title: PageContent +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/airport/pagecontent/update/:id' diff --git a/plugins/tps/airport/controllers/pagecontent/create.htm b/plugins/tps/airport/controllers/pagecontent/create.htm new file mode 100644 index 0000000..9c017a4 --- /dev/null +++ b/plugins/tps/airport/controllers/pagecontent/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/airport/controllers/pagecontent/index.htm b/plugins/tps/airport/controllers/pagecontent/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/plugins/tps/airport/controllers/pagecontent/index.htm @@ -0,0 +1 @@ += $this->listRender() ?> diff --git a/plugins/tps/airport/controllers/pagecontent/preview.htm b/plugins/tps/airport/controllers/pagecontent/preview.htm new file mode 100644 index 0000000..cab445c --- /dev/null +++ b/plugins/tps/airport/controllers/pagecontent/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/airport/controllers/pagecontent/update.htm b/plugins/tps/airport/controllers/pagecontent/update.htm new file mode 100644 index 0000000..e1052c7 --- /dev/null +++ b/plugins/tps/airport/controllers/pagecontent/update.htm @@ -0,0 +1,54 @@ + +