helori/laravel-cms

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Work still in progress... Secured admin panel, website components creation, AMP layout, structured data, database management, media manager, image and video processing

Installs: 136

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 1

Forks: 0

Open Issues: 0

Language:Vue

v1.0.0 2017-09-04 13:11 UTC

This package is auto-updated.

Last update: 2021-10-08 19:31:37 UTC


README

This package provides an admin panel with a built-in media library and the ability to define and administrate everything you need in your website. , a blog manager and a page manager. You can also create custom collections for your content. Each collection is a table in your database : you can define its fields directly from the admin panel, and then create elements for your collection. Typically, a collection can be a gallery, a list of partners, a list of clients...

Installation and setup

On a fresh Laravel (>= v5.4) installation, install the package by running:

composer require helori/laravel-cms

Configure your application (Laravel version < 5.5):

// config/app.php
'providers' => [
    ...
    Helori\LaravelCms\CmsServiceProvider::class,
    Intervention\Image\ImageServiceProvider::class,
    Laravel\Scout\ScoutServiceProvider::class,
];

'aliases' => [
    ...
    'Image' => Intervention\Image\Facades\Image::class,
];

Setup the guard, provider and password reset options to handle administrator authentication :

// config/auth.php
'guards' => [
    ...
    'admin' => [
        'driver' => 'session',
        'provider' => 'admins',
    ],
],
'providers' => [
    ...
    'admins' => [
        'driver' => 'eloquent',
        'model' => Helori\LaravelCms\Models\Admin::class,
    ]
],
'passwords' => [
    ...
    'admins' => [
        'provider' => 'admins',
        'table' => 'admins_resets',
        'expire' => 60,
    ],
],

Configure redirection if an auth exception is raised :

// app/Exceptions/Handler.php
use Illuminate\Auth\AuthenticationException;
...
protected function unauthenticated($request, AuthenticationException $exception)
{
    if ($request->expectsJson()) {
        return response()->json(['error' => 'Unauthenticated.'], 401);
    }

    $guard = array_get($exception->guards(), 0);
    if($guard === 'admin'){
        return redirect()->guest(route('admin-login'));
    }else{
        return redirect()->guest(route('login'));
    }
}

Configure redirection if an administrator is already authenticated :

// app/Middleware/RedirectIfAuthenticated.php
public function handle($request, Closure $next, $guard = null)
{
    if (Auth::guard($guard)->check()) {
        if($guard === 'admin'){
            return redirect()->route('admin-home');
        }else{
            return redirect('/');
        }
    }

    return $next($request);
}

Run the migrations:

php artisan migrate

Create the first administrator to be able to connect the first time:

php artisan tinker
$admin = new \Helori\LaravelCms\Models\Admin
$admin->name = 'John'
$admin->email = 'admin@domain.com'
$admin->password = bcrypt('admin_password')
$admin->save()
exit

Publish the laravel-cms default assets and Vue components:

php artisan vendor:publish --tag=laravel-cms-assets
php artisan vendor:publish --tag=laravel-cms-components

Install the default laravel npm dependencies (to run mix)

npm install

Install the package's font-end dependencies:

npm install axios@0.* bootstrap-sass@3.* jquery@3.* lodash@4.* vue@2.* vuex@2.* vue-router@2.* font-awesome tinymce moment vue-crud --save-dev

Edit your laravel mix config file :

// webpack.mix.js
mix.copy(
    "./node_modules/font-awesome/fonts",
    "./public/fonts"
).sass(
    "./resources/assets/sass/admin.scss",
    "./public/css/admin.css"
).sass(
    "./resources/assets/sass/tinymce.scss",
    "./public/css/tinymce.css"
).js(
    "./resources/assets/js/admin.js",
    "./public/js/admin.js", "."
);

Compile your assets :

npm run dev

Your administrator panel should now available:

http://your-website.dev/admin

Usage