helori / laravel-cms by Helori

Work still in progress... Secured admin panel, website components creation, AMP layout, structured data, database management, media manager, image and video processing
138
5
1
Package Data
Maintainer Username: Helori
Maintainer Contact: helori@algoart.fr (Helori Lanos)
Package Create Date: 2017-05-04
Package Last Update: 2017-10-16
Language: Vue
License: MIT
Last Refreshed: 2024-12-23 03:27:31
Package Statistics
Total Downloads: 138
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 5
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

laravel-cms

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