PHP code example of danpalmieri / jetstream-team-url

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

    

danpalmieri / jetstream-team-url example snippets


return [
    'url' => [
        'prefix' => 'teams', // the prefix for the team routes
        'team_attribute' => 'id', // the attribute to use for the team route
    ],

    'middleware' => \DanPalmieri\JetstreamTeamUrl\Middleware\VerifyOrSetCurrentTeamInRoute::class,
    
    'livewire_support' => true, // Add a persistent middleware to Livewire to support the team in the URL

    'on_denied' => [
        'strategy' => 'redirect', // abort|redirect
        'redirect' => [
            'to' => '/',
            'with' => [
                'key' => 'error',
                'value' => 'You are not allowed to access this team.',
            ],
        ],
        'abort' => [403, 'You are not allowed to access this team.'],
    ],

    'on_different_team' => [
        'strategy' => 'switch', // abort|switch
        'abort' => [403, 'You are not working on the right team.'],
    ],
];

Route::useTeamInUrl(function () {
    Route::get('/dashboard', fn () => view('dashboard')); // example.test/teams/2352/dashboard
});

Route::currentTeamRedirect('_'); // example.test/_/posts/34 -> example.test/teams/2352/posts/34
bash
php artisan vendor:publish --tag="jetstream-team-url-config"