starsoft / laravel-editor
A package for use Grapes.js in Larave
1.1.8
2022-05-26 11:50 UTC
Requires
- php: ^7.3|^8.0
- illuminate/support: ~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0
- spatie/laravel-medialibrary: ^9.6
README
install via composer.
composer require starsoft/laravel-editor
To Get Start with LaraEditor Follow steps below
-
Add 'gjs_data' Column to model you are going to use with Editor.
-
Implement Editable Interface to Model class
-
add Editable trait to model class
-
Implement Required methods in model and create 2 routes to load and store editor content
-
create a EditorContentController controller and add following methods
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(Page $page)
{
return $page->getEditor();
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request, Page $page)
{
return $page->saveEditorData($request);
}
public function templates(Page $page)
{
return array_merge(
$page->getTemplatesFromPath(config('cms.templatesPath')),
$page->getBlocksFromPath(config('cms.blocksPath')),
);
}
- create following routes
Route::get('page-customize/{page}', [PageEditorController::class, 'index'])->name('page-customize.index');
Route::post('page-customize/{page}', [PageEditorController::class, 'store'])->name('page-customize.store');
Route::get('page-customize/{page}/templates', [PageEditorController::class, 'templates'])->name('page-customize.templates');
- publish & run migration files
php artisan vendor:publish --provider="LaraEditor\LaraEditorServiceProvider" --tag="migrations"
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations"
php artisan migrate