PHP code example of tinigin / laravel-last-modified

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

    

tinigin / laravel-last-modified example snippets


// in bootstrap/app.php

->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Tinigin\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"