PHP code example of abordage / laravel-last-modified

1. Go to this page and download the library: Download abordage/laravel-last-modified 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/ */

    

abordage / laravel-last-modified example snippets


// in app/Http/Kernel.php

protected $middleware = [
    'web' => [
        // other middleware
        
        \Abordage\LastModified\Middleware\LastModifiedHandling::class,
    ],
];


 
namespace App\Http\Controllers;
 
use App\Http\Controllers\Controller;
use LastModified;
 
class PostController extends Controller
{
    public function show($id)
    {
        $post = \App\Models\Post::findOrFail($id);

        LastModified::set($post->updated_at);
        
        return view('posts.show', ['post' => $post]);
    }
}
bash
php artisan vendor:publish --tag="last-modified-config"