Skip to content

Instantly share code, notes, and snippets.

@farshidrezaei
Last active May 17, 2019 20:11
Show Gist options
  • Save farshidrezaei/f12ec21bd65f1180115c30afb2010f7f to your computer and use it in GitHub Desktop.
Save farshidrezaei/f12ec21bd65f1180115c30afb2010f7f to your computer and use it in GitHub Desktop.
Simple Signed URL
<?php
//define a route that in action validate signature
Route::get('signed', function (Request $request) {
if ( ! $request->hasValidSignature() ) {
abort( 404 );
}else{
//do something
}
})->name('signed');
//alternative
//App/Http/Kernel.php
protected $routeMiddleware = [
//...
'signed' => ValidateSignature::class,
];
Route::get('signed', function (Request $request) {
//do something
})->name('signed')->middleware('signed');
//generate signed link for 'signed' route
$signed_route = URL::temporarySignedRoute( 'signed', now()->addSeconds(10), ['user' => 1] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment