<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
use App\Http\Controllers\HomeController;
use App\Http\Controllers\ItemController;
Route::get('/', function () {
dd('Welcome to simple user route file.');
});
Auth::routes();
Route::get('/home', [HomeController::class, 'index'])->name('home');
Route::get('/test', [ItemController::class, 'index'])->name('test.index');
Route::post('/test', [ItemController::class, 'store'])->name('test.store');
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Item extends Model {
use HasFactory;
protected $fillable = [
'title',
'details'
];
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateItemsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::create('items', function (Blueprint $table) {
$table->id();
$table->string("title");
$table->string("details");
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
Schema::dropIfExists('items');
}
}
Laravel 6 Flash Message Tutorial
In this example, i would like to show you how to create flash message notification in laravel 6. you can create laravel 6 flash message without composer package. i write step by step tutorial for laravel 6 flash message from controller.
we will define various type of flash message notification like alert success, alert danger, alert info, alert warning messages in bootstrap laravel 6 projects. When you have success task on controller method then you can use success flash message, if you have any error task then you can use error flash message.
Flash messages are required in laravel 6 application because that way we can give alter with what progress complete, error, warning etc. In this tutorial, I added several ways to give a flash message like redirect with success message, redirect with an error message, redirect with a warning message and redirect with info message. In this example, we use a bootstrap flash alert layout that way it becomes good layout.
So, you have to just follow the basic three step to integrate flash message in your laravel 6 application. So let's follow below step:
Step 1: Create Global File For Flash Message
In first step we will create new blade file flash-message.blade.php. In this file we will write code of bootstrap alert and check which messages come.
There are following alert will added:
1)success
2)error
3)warning
4)info
5)validation error
So, let's create flash-message.blade.php file and put bellow code on that file.
In this step we have to just include flash-message.blade.php file in your theme default file. You have to just include this flash file in your default theme blade file like as bellow:
@include('flash-message')
You can also see i added flash file on my theme, so you can add that way. Let's see bellow example: