Laravel Snippets


Required Packages:

  • php-mbstring
  • php-dom

With Backpack (

composer create-project --prefer-dist laravel/laravel PROJECTNAME

git init

cp .env.example .env
# EDIT .env ; DB!

php artisan cache:clear
php artisan config:cache

composer require backpack/crud
php artisan backpack:base:install
php artisan backpack:crud:install

To add vendor to git: (optional!)

sed -i 's;/vendor;;' .gitignore

To disable Register for admins and add middleware to admin panel

Add changes from .env.example to .env (Only works with 5.7)

curl -o LaravelBackpack_IsAdmin.patch URL
git apply LaravelBackpack_IsAdmin.patch
rm -f LaravelBackpack_IsAdmin.patch

Create CRUD for User:

# If Other Models:
php artisan make:migration create_users_table 
php artisan migrate

php artisan backpack:crud user
php artisan backpack:base:add-custom-route "CRUD::resource('user', 'UserCrudController');"
php artisan backpack:base:add-sidebar-content "<li><a href='Template:Backpack url('user')'><i class='fa fa-user'></i> <span>Users</span></a></li>"

Retrieved from "$'"1"