For every input exists only one hash. Before saving smth important it is necessary to hash the sensible information.
It is not possible to uncrypt the password. It is not reversible!
- Create a new file laravel
laravel new name-of-project --git
-
Connect the database by modifying the .env file
-
Install Laravel Breeze
composer require laravel/breeze --dev
- Install Laravel Breeze
php artisan breeze:install
- Select these things in order
blade
no
1
- Install the package for vite ecc.
composer require pacificdev/laravel_9_preset
- Install bootstrap with --auth
php artisan preset:ui bootstrap --auth
- Install vite depencencies after modifying vite.config.js in vite.config.cjs or by deleting 'type' = 'modules' in package.json with:
npm i && npm run dev
- Then open the file online with
php artisan serve
-
Delete edit.blade.php and guest.blade.php because not necessary
-
Open MAMP and make a migration
php artisan migrate
then type or select yes
- Refactor
php artisan make:controller Admin/DashboardController
- in web.php
/*Admin route*/
Route::middleware('auth', 'verified')->prefix('admin')->name('admin.')->group(function () {
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
});
- in DashboardController add function
public function index()
{
return view('admin.dashboard');
}
-
copy and paste in layouts the app.blade.php and rename it in admin.blade.php and create a new layout
-
in admin.blade.php add this template and remember to add the dropdown after logout
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fontawesome 6 cdn -->
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css' integrity='sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==' crossorigin='anonymous' referrerpolicy='no-referrer' />
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<!-- Usando Vite -->
@vite(['resources/js/app.js'])
</head>
<body>
<div id="app">
<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-2 shadow">
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3" href="/">BoolPress</a>
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">
<div class="navbar-nav">
<div class="nav-item text-nowrap ms-2">
<a class="nav-link" href="{{ route('logout') }}" onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
@csrf
</form>
</div>
<!-- <ul>
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ url('dashboard') }}">{{__('Dashboard')}}</a>
<a class="dropdown-item" href="{{ url('profile') }}">{{__('Profile')}}</a>
<a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
@csrf
</form>
</div>
</li>
</ul> -->
</div>
</header>
<div class="container-fluid vh-100">
<div class="row h-100">
<!-- Definire solo parte del menu di navigazione inizialmente per poi
aggiungere i link necessari giorno per giorno
-->
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-dark navbar-dark sidebar collapse">
<div class="position-sticky pt-3">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link text-white {{ Route::currentRouteName() == 'admin.dashboard' ? 'bg-secondary' : '' }}" href="{{route('admin.dashboard')}}">
<i class="fa-solid fa-tachometer-alt fa-lg fa-fw"></i> Dashboard
</a>
</li>
</ul>
</div>
</nav>
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
@yield('content')
</main>
</div>
</div>
</div>
</body>
</html>
- In terminal write the command to add storage for future imgs
php artisan storage:link
-
In RouteServiceProvider modify dashboard in 'admin'
-
create model and controller and everything else by using -a
php artisan make:model Post -a
- Add in PostController this:
👉 namespace App\Http\Controllers\Admin;
use App\Models\Post;
use App\Http\Requests\StorePostRequest;
use App\Http\Requests\UpdatePostRequest;
👉use App\Http\Controllers\Controller;
-
Delete policies in Http
-
write columns of our migrations table
-
Fill seeder and add model post and str helper remember to add it at the beginnig of the file
-
use $this->class in database seeder
-
migrate the database
-
seed the table
-
In web.php in amdin section
Route::resource('posts', PostController::class);
-
in postcontroller complete all the fields
-
Create a new folder named posts in the views that will contain all the blade files connected to the PostController (index.blade.php, edit.blade.php, show.blade.php, store.blade.php ecc.). The files' content is similar to what is done in the laravel-dc-comics project.
-
How to pass a param in a ressource to have a precise slug in URL. It takes the URI and converts it into a slug by overwriting it.
Route::resource('posts', PostController::class)->parameters([
'posts' => 'post:slug'
]);
-
Fill everything as the previuos exercise!
-
Remember to validate the data inserted in the forms
Follow the guide in the documentation --> 👉 https://laravel.com/docs/10.x/pagination or go to this site --> https://www.itsolutionstuff.com/post/laravel-10-pagination-example-tutorialexample.html
php artisan vendor:publish
laravel-pagination