diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/CategoriesController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/CategoriesController.php index 6cfcf3fef..abb0551f6 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/CategoriesController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/CategoriesController.php @@ -22,7 +22,11 @@ class CategoriesController extends Controller public function index(){ - $data = $this->Category->where('active',1)->get()->toArray(); + $data = $this->Category->select('id','name') + ->with(['translations:model_id,locale,attribute_data']) + ->where('status',1) + ->get() + ->toArray(); return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); } diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/postsController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/postsController.php index 8e77229c0..24f255e83 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/postsController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/postsController.php @@ -34,14 +34,14 @@ class postsController extends Controller return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); } - public function show($id){ + public function show($locale,$id){ $data = $this->Post::with('categories')->find($id); if ($data){ return $this->helpers->apiArrayResponseBuilder(200, 'success', [$data]); } else { - $this->helpers->apiArrayResponseBuilder(404, 'not found', ['error' => 'Resource id=' . $id . ' could not be found']); + return $this->helpers->apiArrayResponseBuilder(404, 'not found', ['error' => 'Resource id=' . $id . ' could not be found']); } } diff --git a/plugins/ahmadfatoni/apigenerator/routes.php b/plugins/ahmadfatoni/apigenerator/routes.php index bdc1b2a41..05e4da3d4 100644 --- a/plugins/ahmadfatoni/apigenerator/routes.php +++ b/plugins/ahmadfatoni/apigenerator/routes.php @@ -4,7 +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::resource('api/v1/categories', 'AhmadFatoni\ApiGenerator\Controllers\API\CategoriesController', ['except' => ['destroy', 'create', 'edit']]); -Route::get('api/v1/categories/{id}/delete', ['as' => 'api/v1/categories.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\CategoriesController@destroy']); -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']); \ No newline at end of file +Route::resource('api/categories', 'AhmadFatoni\ApiGenerator\Controllers\API\CategoriesController', ['except' => ['destroy', 'create', 'edit']]); +Route::resource('{locale}/api/posts', 'AhmadFatoni\ApiGenerator\Controllers\API\postsController', ['except' => ['destroy', 'create', 'edit']]); +Route::get('api/version',function (){ + return '2.0.0'; +}); diff --git a/scripts/category.sql b/scripts/category.sql index 1c9fd37b5..d860e0cfa 100644 --- a/scripts/category.sql +++ b/scripts/category.sql @@ -30,20 +30,54 @@ SELECT rb.id, bt.id FROM orient_wordpress.`iatm_orient_2_term_relationships` rl Inner JOIN orient.rainlab_blog_categories bt on bt.id = rl.term_taxonomy_id INNER JOIN orient.rainlab_blog_posts rb on rl.object_id = rb.id_en + INSERT INTO orient.rainlab_blog_posts_categories (post_id,category_id) +SELECT rb.id, bt.id FROM term_relationships_converted rl + Inner JOIN rainlab_blog_categories bt on bt.id = rl.term_taxonomy_id + INNER JOIN rainlab_blog_posts rb on rl.object_id = rb.id_ru update iatm_orient_term_relationships SET term_taxonomy_id = 9 where term_taxonomy_id = 2; -update iatm_orient_term_relationships SET term_taxonomy_id = 5 where term_taxonomy_id = 3; update iatm_orient_term_relationships SET term_taxonomy_id = 8 where term_taxonomy_id = 5; -update iatm_orient_term_relationships SET term_taxonomy_id = 10 where term_taxonomy_id = 6; -update iatm_orient_term_relationships SET term_taxonomy_id = 11 where term_taxonomy_id = 7; +update iatm_orient_term_relationships SET term_taxonomy_id = 5 where term_taxonomy_id = 3; +update iatm_orient_term_relationships SET term_taxonomy_id = 2508 where term_taxonomy_id = 13; update iatm_orient_term_relationships SET term_taxonomy_id = 13 where term_taxonomy_id = 10; +update iatm_orient_term_relationships SET term_taxonomy_id = 10 where term_taxonomy_id = 6; +update iatm_orient_term_relationships SET term_taxonomy_id = 2509 where term_taxonomy_id = 11; +update iatm_orient_term_relationships SET term_taxonomy_id = 11 where term_taxonomy_id = 7; update iatm_orient_term_relationships SET term_taxonomy_id = 6 where term_taxonomy_id = 23; update iatm_orient_term_relationships SET term_taxonomy_id = 7 where term_taxonomy_id = 26; +update iatm_orient_term_relationships SET term_taxonomy_id = 2510 where term_taxonomy_id = 14; update iatm_orient_term_relationships SET term_taxonomy_id = 14 where term_taxonomy_id = 29; update iatm_orient_term_relationships SET term_taxonomy_id = 12 where term_taxonomy_id = 41; +update iatm_orient_term_relationships SET term_taxonomy_id = 2511 where term_taxonomy_id = 793; update iatm_orient_term_relationships SET term_taxonomy_id = 793 where term_taxonomy_id = 101; +update iatm_orient_term_relationships SET term_taxonomy_id = 2512 where term_taxonomy_id = 621; update iatm_orient_term_relationships SET term_taxonomy_id = 621 where term_taxonomy_id = 696; +update iatm_orient_terms SET term_id = 9 where term_id = 2; +update iatm_orient_terms SET term_id = 8 where term_id = 5; +update iatm_orient_terms SET term_id = 5 where term_id = 3; +update iatm_orient_terms SET term_id = 13 where term_id = 10; +update iatm_orient_terms SET term_id = 10 where term_id = 6; +update iatm_orient_terms SET term_id = 11 where term_id = 7; +update iatm_orient_terms SET term_id = 6 where term_id = 23; +update iatm_orient_terms SET term_id = 7 where term_id = 26; +update iatm_orient_terms SET term_id = 14 where term_id = 29; +update iatm_orient_terms SET term_id = 12 where term_id = 41; +update iatm_orient_terms SET term_id = 793 where term_id = 101; +update iatm_orient_terms SET term_id = 621 where term_id = 696; + +update iatm_orient_term_taxonomy SET term_id = 9 where term_id = 2; +update iatm_orient_term_taxonomy SET term_id = 8 where term_id = 5; +update iatm_orient_term_taxonomy SET term_id = 5 where term_id = 3; +update iatm_orient_term_taxonomy SET term_id = 13 where term_id = 10; +update iatm_orient_term_taxonomy SET term_id = 10 where term_id = 6; +update iatm_orient_term_taxonomy SET term_id = 11 where term_id = 7; +update iatm_orient_term_taxonomy SET term_id = 6 where term_id = 23; +update iatm_orient_term_taxonomy SET term_id = 7 where term_id = 26; +update iatm_orient_term_taxonomy SET term_id = 14 where term_id = 29; +update iatm_orient_term_taxonomy SET term_id = 12 where term_id = 41; +update iatm_orient_term_taxonomy SET term_id = 793 where term_id = 101; +update iatm_orient_term_taxonomy SET term_id = 621 where term_id = 696; INSERT INTO rainlab_blog_posts_categories (post_id,category_id) SELECT rb.id, bt.id FROM `iatm_orient_term_relationships` rl