Skip to content

Commit

Permalink
Merge pull request #287 from webreinvent/2.x-feature/update-cms-modul…
Browse files Browse the repository at this point in the history
…e-and-theme-version

2.x feature -> 2.x develop | Added: publish assets api
  • Loading branch information
themodernpk authored Jun 26, 2024
2 parents 7b07b8e + d4c1872 commit b24028a
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
62 changes: 62 additions & 0 deletions Http/Controllers/Api/PublicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use WebReinvent\VaahCms\Libraries\VaahHelper;
use WebReinvent\VaahCms\Models\Module;
use WebReinvent\VaahCms\Models\Setting;
use WebReinvent\VaahCms\Models\Theme;
use WebReinvent\VaahCms\Models\User;


Expand Down Expand Up @@ -60,5 +62,65 @@ public function disableMfa(Request $request,$token)

}
//----------------------------------------------------------
public function publishAssets(Request $request,$slug)
{
try{

$module = Module::slug($slug)->first();

if (!$module) {

$theme = Theme::slug($slug)->first();

if(!$theme){
$response['success'] = false;
$response['errors'][] = "Module/Theme not found.";
return response()->json($response);
}

$message = Theme::copyAssets($theme);

if (!$message) {
$response['success'] = false;
$response['errors'][] = "Something went wrong.";
return response()->json($response);
}

$theme->is_assets_published = 1;
$theme->save();
$response['success'] = true;
$response['messages'][] = "Assets published.";
return response()->json($response);
}

$message = Module::copyAssets($module);

if (!$message) {
$response['success'] = false;
$response['errors'][] = "Something went wrong.";
return response()->json($response);
}

$module->is_assets_published = 1;
$module->save();
$response['success'] = true;
$response['messages'][] = "Assets published.";
} catch (\Exception $e) {
$response = [];
$response['success'] = false;

if(env('APP_DEBUG')){
$response['errors'][] = $e->getMessage();
$response['hint'][] = $e->getTraceAsString();
} else {
$response['errors'][] = trans("vaahcms-general.something_went_wrong");
}
}


return response()->json($response);

}
//----------------------------------------------------------

}
4 changes: 2 additions & 2 deletions Libraries/VaahSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static function createVaahCmsJsonFile($request)
"excerpt"=> "CMS is a framework for creating, managing, and deploying customized content types and fields.",
"author_name"=> "Vaah",
"author_website"=> "https://vaah.dev",
"version"=> "v2.0.1",
"version"=> "v2.0.4",
"is_sample_data_available"=> true,
"import_sample_data"=> false,
],
Expand All @@ -100,7 +100,7 @@ public static function createVaahCmsJsonFile($request)
"github_url"=> "https://github.com/webreinvent/vaahcms-theme-bulma",
"author_name"=> "WebReinvent",
"author_website"=> "https://webreinvent.com",
"version"=> "v0.0.2",
"version"=> "v0.0.6",
"is_sample_data_available"=> true,
"import_sample_data"=> true,
]
Expand Down
6 changes: 4 additions & 2 deletions Routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function () {
//------------------------------------------------
Route::any( '/disable/mfa/{api_token}', 'PublicController@disableMfa' )
->name( 'vh.backend.disable.mfa' );
//------------------------------------------------
Route::any( '/publish/assets/{slug}', 'PublicController@publishAssets' )
->name( 'vh.backend.publish.assets' );

});

Route::group(
Expand Down Expand Up @@ -159,5 +163,3 @@ function () {
Route::any( '/{column}/{value}/delete', 'TaxonomyTypesController@delete' );
});
});


0 comments on commit b24028a

Please sign in to comment.