PHP code example of f9webltd / laravel-redirect-response-macros

1. Go to this page and download the library: Download f9webltd/laravel-redirect-response-macros 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/ */

    

f9webltd / laravel-redirect-response-macros example snippets

 php
public function store(FormRequest $request)
{
    // create record ...
    return redirect()->route('posts.index')->created();
}
 php
public function store(FormRequest $request)
{
    // create record ...
    return redirect()->route('posts.index')->with('success', 'The record was successfully created');
}
 php
public function update(FormRequest $request, $id)
{
    return back()->success('Everything is great!');
}
 php
public function update(FormRequest $request, $id)
{
    return back()->info('Some information ...');
}
 php
public function update(FormRequest $request, $id)
{
    return back()->danger('That action just is impossible!');
}
 php
public function update(FormRequest $request, $id)
{
    return back()->warning('This could be risky ...');
}
 php
public function store(FormRequest $request)
{
    // create record ...
    return redirect()->route('posts.index')->created();
}
 php
public function store(FormRequest $request)
{
    // create record ...
    return redirect()->route('posts.index')->created(
      route('posts.edit', $post)
    );
}
 php
public function update(FormRequest $requestm int $id)
{
    // update record ...
    return back()->updated();
}
 php
public function update(Post $post)
{
    $posts->delete();

    return redirect()->route('posts.index')->deleted();
}
 php
public function index()
{
    // code ...
    return redirect()->route('dashboard')->error('You cannot do this thing!');
}