Package Data | |
---|---|
Maintainer Username: | afrittella |
Maintainer Contact: | a.frittella@sintab.it (Andrea Frittella) |
Package Create Date: | 2017-03-13 |
Package Last Update: | 2020-11-03 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-21 03:01:09 |
Package Statistics | |
---|---|
Total Downloads: | 171 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 5 |
Total Forks: | 1 |
Total Open Issues: | 1 |
Back Project is an admin panel for Laravel 5.4+ based on AdminLTE and other amazing packages. See Credits for details.
See CHANGELOG.md for detailed updates.
composer require afrittella/back-project
Add the Service Provider to your config.app service providers list:
Afrittella\BackProject\BackProjectServiceProvider::class,
Publishing configuration, assets, view, migrations
Configuration
php artisan vendor:publish --provider="Afrittella\BackProject\BackProjectServiceProvider" --tag="config"
php artisan vendor:publish --provider="Prologue\Alerts\AlertsServiceProvider"
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="config"
php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"
In config/laravel-permission.php change model classes to:
'permission' => Afrittella\BackProject\Models\Permission::class,
'role' => Afrittella\BackProject\Models\Role::class,
Social login is disabled by default. To use it you must follow these steps:
Change the following lines in config/back-project.php
'social_login_enabled' => [
'facebook' => true, // enable facebook login
'twitter' => true, // enable twitter login
'linkedin' => true // enable linkedin login
],
Once obtained app keys, add them to .env and to config/services.php as shown below.
.env
FACEBOOK_ID = XXXXXXXX
FACEBOOK_SECRET = XXXXX
FACEBOOK_REDIRECT = http://example.com/auth/facebook/callback
TWITTER_ID = XXXXXXXX
TWITTER_SECRET = XXXXX
TWITTER_REDIRECT = http://example.com/auth/twitter/callback
LINKEDIN_ID = XXXXXXXX
LINKEDIN_SECRET = XXXXX
LINKEDIN_REDIRECT = http://example.com/auth/linkedin/callback
config/service.php
...
'facebook' => [
'client_id' => env('FACEBOOK_ID'),
'client_secret' => env('FACEBOOK_SECRET'),
'redirect' => env('FACEBOOK_REDIRECT'),
],
'twitter' => [
'client_id' => env('TWITTER_ID'),
'client_secret' => env('TWITTER_SECRET'),
'redirect' => env('TWITTER_REDIRECT'),
],
'linkedin' => [
'client_id' => env('LINKEDIN_ID'),
'client_secret' => env('LINKEDIN_SECRET'),
'redirect' => env('LINKEDIN_REDIRECT'),
]
Language
At this time only italian and english language are supported.
Run
php artisan vendor:publish --provider="Afrittella\BackProject\BackProjectServiceProvider" --tag="lang"
Please note: You don't need to publish translation files if you don't want to change default strings.
Default Laravel languages are provided by caousecs/laravel-lang package. You had to manually copy translation files based on the language you will use on your project.
Copy the content of vendor/caouecs/laravel-lang/src/[language-folder] to resources/lang/[language-folder]
BackProject, AdminLTE, Avatar assets and views
php artisan vendor:publish --provider="Afrittella\BackProject\BackProjectServiceProvider" --tag="adminlte"
php artisan vendor:publish --provider="Laravolt\Avatar\ServiceProvider"
php artisan vendor:publish --provider="Afrittella\BackProject\BackProjectServiceProvider" --tag="public"
php artisan vendor:publish --provider="Afrittella\BackProject\BackProjectServiceProvider" --tag="errors"
You can publish Back Project default views if you want to edit them:
php artisan vendor:publish --provider="Afrittella\BackProject\BackProjectServiceProvider" --tag="views"
Migrations
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations"
Run
php artisan migrate
php artisan back-project:seed-permissions
php artisan back-project:seed-menus
Queue
Queues can be used to send registration email.
To set up queues:
QUEUE_DRIVER=database
"use_queue" => true,
php artisan queue:table
to create the jobs table php artisan queue:failed-table
By default Back Project use classic notification system.
Authorization
BackProject is provided with 3 custom middleware, one of this replaces “RedirectIfAuthenticated”. If you want to use this middleware (it redirects to admin/dashboard if authenticated), you should replace the ”guest” alias in your app/Http/Middleware/Kernel.php with back project custom one and add the other two as follows:
'guest' => \Afrittella\BackProject\Http\Middleware\RedirectIfAuthenticated::class,
'admin' => \Afrittella\BackProject\Http\Middleware\Admin::class,
'role' => \Afrittella\BackProject\Http\Middleware\Role::class,
User model
A default User model is provided with the package. It has all the features to make Back Project works well. If you would like to use your custom model, simply extend:
Afrittella\BackProject\Models\Auth\User;
If you are using package model, or if your User model is not present in the default folder, you must change config/auth.php:
...
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => Afrittella\BackProject\Models\Auth\User::class,
],
...
Remember to change user_model key in config/back-project.php if you want to use your custom User model.
Back Project simple auth method
Back Project has a simple authorization method, located in Afrittella/BackProject/Http/Controllers/Controller.php
public function bCAuthorize($ability, $record = [])
{
if ($record->user_id !== Auth::user()->id) {
abort(403);
}
}
You can use it if you want to simply check if a user is authorized to manage a record. Just use this controller instead of Laravel default controller and call “bCAuthorize” before doing any database action
Exceptions
Back Project has a default exception handler who renders custom error views. To use this handler add the following lines to Exceptions/Handler.php
...
use Afrittella\BackProject\Exceptions\BackProjectHandler;
use Afrittella\BackProject\Exceptions\BaseException;
class Handler extends ExceptionHandler
{
...
public function render($request, Exception $exception)
{
...
if ($exception instanceof BaseException) {
if ($response = BackProjectHandler::getResponse($exception)) {
return $response;
}
}
...
return parent::render($request, $exception);
}
}
Once completed the Installation and Configuration sections, go to your project's url (www.example.com/register), register and activate the first user who will be the site administrator.
Back Project use intervention/image and intervention/imagecache to manage image upload, resizing and display. Once uploaded, an image can be displayed using imagecache package and default or custom filters. Feel free to create custom filters for your images.
Change config/imagecache.php following this example:
return array(
/*
|--------------------------------------------------------------------------
| Name of route
|--------------------------------------------------------------------------
|
| Enter the routes name to enable dynamic imagecache manipulation.
| This handle will define the first part of the URI:
|
| {route}/{template}/{filename}
|
| Examples: "images", "img/cache"
|
*/
'route' => [FIRST PART OF THE URI YOU WANT FOR DISPLAYING IMAGES],
/*
|--------------------------------------------------------------------------
| Storage paths
|--------------------------------------------------------------------------
|
| The following paths will be searched for the image filename, submited
| by URI.
|
| Define as many directories as you like.
|
*/
'paths' => array(
// Insert here your uploads directory
public_path('upload'),
public_path('images')
),
/*
|--------------------------------------------------------------------------
| Manipulation templates
|--------------------------------------------------------------------------
|
| Here you may specify your own manipulation filter templates.
| The keys of this array will define which templates
| are available in the URI:
|
| {route}/{template}/{filename}
|
| The values of this array will define which filter class
| will be applied, by its fully qualified name.
|
*/
'templates' => array(
'small' => 'Intervention\Image\Templates\Small',
'medium' => 'Intervention\Image\Templates\Medium',
'large' => 'Intervention\Image\Templates\Large',
),
/*
|--------------------------------------------------------------------------
| Image Cache Lifetime
|--------------------------------------------------------------------------
|
| Lifetime in minutes of the images handled by the imagecache route.
|
*/
'lifetime' => 43200,
);
Read the Intervention/Image documentation to know how to use it.
You can use HasOneAttachment or HasManyAttachment trait on a model to associate it to attachments table.
Example:
...
use Afrittella\BackProject\Traits\HasOneAttachment;
...
class Model
{
use HasOneAttachment;
...
}
You can change the folder where files are uploaded in config/filesystems.php
I was inspired by Backpack for Laravel project, but i tried to make a simple one with only the features I need for my projects. Feel free to open a PR or send a feedback if you would like to collaborate and improve it.
Back Project depends on the following packages:
This package is licensed under the MIT license.