项目作者: darkterminal

项目描述 :
Laravel 5.5 Multiple-Auth Packages
高级语言: PHP
项目地址: git://github.com/darkterminal/laravel-multiple-auth.git
创建时间: 2017-10-04T18:14:07Z
项目社区:https://github.com/darkterminal/laravel-multiple-auth

开源协议:

下载


Laravel 5.5 Multiple-Auth Packages

From Original Repository trojan302

Requirement*

  • PHP >= 7.0.0
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

Also Need*

  • npm (Node Packages Manager)
  • composer (PHP)

What Are Includes

  • Auth Multiple Level User [ USER and ADMINISTRATOR ]
  • Bootstrap 4 Beta Version
  • jQuery, Popper.js
  • Font Awesome 4 [cdn]

Download Packages

download_via_git

  1. @fcodexxx (htdocs) git clone https://github.com/darkterminal/laravel-multiple-auth.git project-laravel

Install Packages

install_using_composer

  1. @fcodexxx (htdocs) cd project-laravel
  2. @fcodexxx (project-laravel) composer install
  3. @fcodexxx (project-laravel) php artisan package:discover
  4. @fcodexxx (project-laravel) subl .

If Sublime Text Editor or Your favorite text editor is open then duplicate file .env.example to .env

duplicate_env_file

then generate unique key for laravel application using artisan command line

  1. @fcodexxx (project-laravel) php artisan key:generate

Now your .env file look like this

generate_key_for_application

Install Front End using Bootstrap 4 Beta

  • First Remove Frontend scaffolding using artisan command line

    1. @fcodexxx (project-laravel) php artisan preset none
  • Make sure you have jQuery in devDependencies on package.json

install_dev_dependecies

  • If jQuery have been included in packages.json file, then install packages this command line

    1. @fcodexxx (project-laravel) npm install
  • After installing packages have done, then make sure you have this line in file resources/assets/sass/app.scss

    1. /* @import Bootstrap 4 Beta and Custom Partials */
    2. @import "custom";
    3. @import "node_modules/bootstrap/scss/bootstrap";
    4. /* Enjoy using SCSS */

import_stylesheet

  • If you have done with that, the next step is a compile preset Front End scaffolding using this command

    1. @fcodexxx (project-laravel) npm run dev

the result like this

compile_stylesheet

  • Congratulation you have successfully installing Laravel 5.5 and Bootstrap 4 Beta!

Activated Multi-Auth

  • Change databse in .env file

    1. DB_CONNECTION=mysql
    2. DB_HOST=127.0.0.1
    3. DB_PORT=3306
    4. DB_DATABASE=laravel-auth
    5. DB_USERNAME=root
    6. DB_PASSWORD=

Username and Password must be following your database credential, in this case DB_USERNAME is root and DB_PASSWORD is none.

  • Change Mail Driver in .env file to Provide Password Reset

    1. MAIL_DRIVER=log
    2. MAIL_HOST=smtp.mailtrap.io
    3. MAIL_PORT=2525
    4. MAIL_USERNAME=null
    5. MAIL_PASSWORD=null
    6. MAIL_ENCRYPTION=null

By Default mail driver is smtp, replace using log file laravel 5.5 storage

  • Create Database in MySQL Server or Phpmyadmin

    1. CREATE DATABASE laravel-auth
  • The push migration table to server, using this command line

    1. @fcodexxx (project-laravel) php artisan migrate

Database structure look like this

image

  • After successfully migrate database you can add user and admin credentials using tinker

    1. @fcodexxx (project-laravel) php artisan tinker
    2. Psy Shell v0.8.11 (PHP 7.0.23-1+ubuntu17.04.1+deb.sury.org+1 cli) by Justin Hileman
    3. >>> $user = new App\User();
    4. => App\User {#739}
    5. >>> $user->name = 'fscodexxx'
    6. => "fscodexxx"
    7. >>> $user->email = 'fscodexxx@email.com'
    8. => "fscodexxx@email.com"
    9. >>> $user->password = bcrypt('fscodexxx')
    10. => "$2y$10$UbdRJsbQhlHS3gqjLmBTueZIM2ZkzKTiJX9WP3hNxJFdQ6foR11IS"
    11. >>> $user->save()
    12. => true
    13. >>>

Make sure you have been created user, using this command

  1. @fcodexxx (project-laravel) php artisan tinker
  2. Psy Shell v0.8.11 (PHP 7.0.23-1+ubuntu17.04.1+deb.sury.org+1 cli) by Justin Hileman
  3. >>> $user = new App\User();
  4. => App\User {#739}
  5. >>> $user->all();
  6. => Illuminate\Database\Eloquent\Collection {#745
  7. all: [
  8. App\User {#746
  9. id: 1,
  10. name: "fscodexxx",
  11. email: "fscodexxx@email.com",
  12. created_at: "2017-10-04 16:55:26",
  13. updated_at: "2017-10-04 16:55:26",
  14. },
  15. ],
  16. }
  17. >>>

users table look like this

image

  • Create admin creadential

    1. @fcodexxx (project-laravel) php artisan tinker
    2. Psy Shell v0.8.11 (PHP 7.0.23-1+ubuntu17.04.1+deb.sury.org+1 cli) by Justin Hileman
    3. >>> $admin = new App\Admin();
    4. => App\Admin {#739}
    5. >>> $admin->name = 'administrator'
    6. => "administrator"
    7. >>> $admin->email = 'admin@email.com'
    8. => "admin@email.com"
    9. >>> $admin->password = bcrypt('adminpassword')
    10. => "$2y$10$stWyra3Ie.QRRbJO7o6RoOE4sbDTS5kafFw3UBWgP8lD.szZZGzDa"
    11. >>> $admin->save();
    12. => true

Make sure you have been created admin, using this command

  1. @fcodexxx (project-laravel) php artisan tinker
  2. Psy Shell v0.8.11 (PHP 7.0.23-1+ubuntu17.04.1+deb.sury.org+1 cli) by Justin Hileman
  3. >>> $admin->all();
  4. => Illuminate\Database\Eloquent\Collection {#752
  5. all: [
  6. App\Admin {#753
  7. id: 1,
  8. name: "administrator",
  9. email: "admin@email.com",
  10. created_at: "2017-10-04 17:07:09",
  11. updated_at: "2017-10-04 17:07:09",
  12. },
  13. ],
  14. }
  15. >>>

admins table look like this

image

Create vHost in XAMPP or LAMPP (Linux/Ubuntu)

  • Enable virtual hosts by editing httpd.conf, if it is not enabled already. Once you enable it you can skip this step next time.

    1. sudo gedit /opt/lampp/etc/httpd.conf

Find #Include etc/extra/httpd-vhosts.conf and remove the # to un-comment this line

  1. Include etc/extra/httpd-vhosts.conf
  • Add new virtual host by opening the httpd-vhosts.conf file

    1. sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf

Usually, by default there are two virtual hosts in this file. You can edit one or create new one by copy-pasting one of them. The required entries are DocumentRoot and ServerName

  1. <VirtualHost *:80>
  2. ServerAdmin your_email@domain_name.com
  3. DocumentRoot /opt/lampp/htdocs/laravel-project
  4. ServerName laravel-project.dev
  5. ServerAlias www.laravel-project.dev
  6. ErrorLog logs/laravel-project.dev-error_log
  7. CustomLog logs/laravel-project.dev-access_log common
  8. </VirtualHost>
  • Next, you will need to tell Xampp server where to find the address you added above:

    1. sudo gedit /etc/hosts

Add the following line:

  1. 127.0.0.1 laravel-project.dev

Welcome Page Laravel 5.5 with Bootstrap 4 Beta

image

Developing Prosess

If you have successfully installing Laravel 5.5 and Bootstrap 4 Beta. Then you want to developing your project using stylesheet and javascript, you must run this command to watch every changed in your app.scss and app.js file.

  1. @fcodexxx (project-laravel) npm run watch

or

  1. @fcodexxx (project-laravel) npm run watch-poll

Thanks to

Troubleshooting