Init Laravel project

Debug Bar

  • Open the vs code or whatever you use as code editor and in the termenal add this line of code and press enter"
  • composer require barryvdh/laravel-debugbar --dev
  • Add this line to config/app file in the providers
  • Barryvdh\Debugbar\ServiceProvider::class,
  • Add this line to config/app file in the aliases
  • 'Debugbar' => Barryvdh\Debugbar\Facades\Debugbar::class,
  • Add this line route folder inside web.php in the home route"
  • Debugbar::info('info');
  • Publish the debug bar package in the project"
  • php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
  • Connect project to mySql Database"
  • "Start mySql and server using Xaamp or any similer app provide same services"
  • "Press on the GO to app folder button"
  • php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
Create data base and set the env file to connect to it

UI Setup

  • run this command:
  • composer require laravel/ui
  • run this command
  • php artisan ui bootstrap --auth
  • Create main.scss inside resources
  • Create main.css inside public css folder
  • go to resources/view/layouts/app.php and add this line of code in the head
  • link href="" rel="stylesheet"
  • run this command
  • npm install && npm run dev
  • run this command to install mix:
  • npm install laravel-mix@latest
  • run this command
  • npm run watch
  • helper commands if needed
  • npm clean-install npm run build
    "watch": "webpack --watch --progress"

Set admin and users roles

  • run this commands:
  • composer require santigarcor/laratrust
    php artisan vendor:publish --tag="laratrust"
    php artisan laratrust:setup
    php artisan laratrust:seeder
    php artisan vendor:publish --tag="laratrust-seeder"
    composer dump-autoload
  • Past this line in databases/seeders/DatabaseSeeder.php inside the function
  • $this->call(LaratrustSeeder::class);
  • run this commands:
  • php artisan migrate
    php artisan db:seed
  • Go to app/http/controllers/auth/RegisterController.php and add this code to the create function
  • ->attachRole('user');

Setup Multi Languages

    Step 1
  • Go to app/config/app.php and set the defualt local by set local key to whatever you want :
  • 'locale'=>'en'
    Step 2
  • run this command to create a language middleware and after that replace the code inside the class with:
  • use Illuminate\Support\Facades\App; public function handle(Request $request, Closure $next) { if (Session()->has('applocale') and array_key_exists(Session()->get('applocale'), config('languages'))) { App::setlocale(Session()->get('applocale')); } else { App::setlocale(config('app.fallback_locale')); } return $next($request); }
    Step 3
  • add the created middleware to "WEB" key in the kernel file to run it from all app Go to app/http/kernel.php
  • \App\Http\Middleware\Language::class,
    Step 4
  • Create file named languages inside the config folder contain this code:
  • php return [ 'en' => [ 'display' => 'English', 'flag-icon' => 'us', ], 'ar' => [ 'display' => 'Arabic', 'flag-icon' => 'sa', ], ];
    Step 5
  • Create controller named LanguagesController:
  • php artisan make:controller LanguagesController
  • replace the code inside the controller with:
  • php namespace App\Http\Controllers; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Redirect; class LanguagesController extends Controller { public function switchLang($lang) { if (array_key_exists($lang, Config::get('languages'))) { Session::put('applocale', $lang); } return Redirect::back(); } }
    Step 6
  • Create a new route inside routes/wep.php file
  • Route::get('lang/{lang}', ['as' => 'lang.switch', 'uses' => '\App\Http\Controllers\LanguagesController@switchLang']);
    Step 7
  • Add the flags to projects using this code
  • npm install flag-icons
  • inside resources/ sass / app.sass add this code to link flags
  • @import '~flag-icons/css/flag-icons.css';
  • run this code
  • npm run watch
    Step 8
  • add this dropdwon items to layouts folder inside app.blade.php
  • See the code
    Step 9
  • Create the languages folders and files to the lang folder
  • ?php return [ 'whoAreWe' => 'Who Are We ?', ];
    Step 10
  • Simply use it like this from blade
  • about.whoAreWe
  • and like this from controllers
  • trans('about.whoAreWe');