PHP code example of zschuessler / laravel-route-to-class
1. Go to this page and download the library: Download zschuessler/laravel-route-to-class 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/ */
zschuessler / laravel-route-to-class example snippets
// This is now possible, too:
\Route2Class::addClass('test');
namespace App\Providers\RouteToClass;
use Zschuessler\RouteToClass\Generators\GeneratorAbstract;
class UserTypeGenerator extends GeneratorAbstract
{
public function generateClassName()
{
// Use your own logic here to determine user type
$userType = 'admin';
return 'user-' . $userType;
}
}
Route::get('/', function () {
// Add static class as string
Route2Class::addClass('homepage');
// Add class from anonymous function
Route2Class::addClass(function() {
// Your custom logic goes here
return 'my-anon-class-name';
});
return view('welcome');
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.