PHP code example of bilfeldt / laravel-flash-message
1. Go to this page and download the library: Download bilfeldt/laravel-flash-message library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Http\Controllers;
use Bilfeldt\LaravelFlashMessage\Message;
use Illuminate\Http\Request;
class PostController extends Controller
{
/**
* Display a listing of the resource.
*
* @param Request $request
*/
public function index(Request $request)
{
$message = Message::warning('This is a simple message intended for you') // message/success/info/warning/error
->title('This is important')
->addMessage('account', 'There is 10 days left of your free trial')
->addLink('Read more', 'https://example.com/signup');
return view('posts')->withMessage($message);
}
}
namespace App\Http\Controllers;
use Bilfeldt\LaravelFlashMessage\Message;
use Illuminate\Http\Request;
class PostController extends Controller
{
/**
* Display a listing of the resource.
*
* @param Request $request
*/
public function index(Request $request)
{
$message = Message::warning('This is a simple message intended for you') // message/success/info/warning/error
->title('This is important')
->addMessage('account', 'There is 10 days left of your free trial')
->addLink('Read more', 'https://example.com/signup');
return redirect('/posts')->withMessage($message); // This will flash the message to the Laravel session
}
}