1. Go to this page and download the library: Download dragon-code/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/ */
namespace App\Observers;
use Illuminate\Database\Eloquent\Model;
use DragonCode\LastModified\Services\LastModified;
class LastModifiedObserver
{
public function saving(Model $model)
{
LastModified::make()
->models($model)
->update();
}
public function deleting(Model $model)
{
LastModified::make()
->models($model)
->delete();
}
}
namespace App\Providers;
use App\Observers\LastModifiedObserver;
use Illuminate\Foundation\Auth\User;
use Illuminate\Support\ServiceProvider;
class ObserverServiceProvider extends ServiceProvider
{
public function boot()
{
Page::observe(LastModifiedObserver::class);
News::observe(LastModifiedObserver::class);
// ...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.