PHP code example of ac-developers / eloquent-url-presenter

1. Go to this page and download the library: Download ac-developers/eloquent-url-presenter 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/ */

    

ac-developers / eloquent-url-presenter example snippets


'providers' => [
    AcDevelopers\EloquentUrlPresenter\EloquentUrlPresenterServiceProvider::class,
    ];

$app->register(AcDevelopers\EloquentUrlPresenter\EloquentUrlPresenterServiceProvider::class);

php artisan vendor:publish --provider="AcDevelopers\EloquentUrlPresenter\EloquentUrlPresenterServiceProvider"

/**
 * UserUrlPresenter constructor.
 *
 * @param \App\User $user
 */
public function __construct(User $user)
{
    parent::__construct($user);

    //
}


/**
 * Get the show url for this user
 *
 * @return string
 */
public function show()
{
    return url('show/{user}', ['slug' => $this->entity])
}

php artisan generate:urlPresenter UserUrlPresenter --model=User

php artisan generate:urlPresenter UserUrlPresenter --model=User --resource