PHP code example of whitecube / laravel-links

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

    

whitecube / laravel-links example snippets


use App\Models\Product;
use Whitecube\Links\Facades\Links;

public function boot()
{
    // Simple routes:
    Links::route('home');
    Links::route('about')->title('About us');
    Links::route(name: 'catalog', parameters: ['list' => 'bestselling'])->title('Popular products');

    // Group resources as an "archive":
    Links::archive('products')
        ->index(fn($link) => $link->route('products')->title('All products'))
        ->items(fn($link) => $link->route('product')
            ->model(Product::class)
            ->title(fn($product) => $product->name)
        );
}

use Illuminate\Database\Eloquent\Model;
use Whitecube\Links\Casts\ResolvedInlineLinkTagsString;

class Post extends Model
{
    protected $casts = [
        'content' => ResolvedInlineLinkTagsString::class,
    ];
}