PHP code example of alvarofpp / expand-request

1. Go to this page and download the library: Download alvarofpp/expand-request 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/ */

    

alvarofpp / expand-request example snippets



// ...
$previousUrl = app('request')->create(url()->previous());
if (is_url('courses/create', $previousUrl)) {
    // Do something...
}


namespace App\Http\Requests\Course;

use Alvarofpp\ExpandRequest\Traits\UrlParameters;
use Illuminate\Foundation\Http\FormRequest;

class ShowRequest extends FormRequest
{
    use UrlParameters;
    // ...
}


// ...
public function rules()
{
    return [
        'course' => ['


namespace App\Http\Requests\Course;

use Alvarofpp\ExpandRequest\Traits\UrlParameters;
use Illuminate\Foundation\Http\FormRequest;

class ShowRequest extends FormRequest
{
    use UrlParameters;
    
    protected $renameUrlParameters = [
        'course_id',
        'content_id',
        'video_id',
    ];

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'course_id' => ['


// ...
protected $renameUrlParameters = [
    0 => 'course_id',
    // 1 => 'content_id',
    2 => 'video_id',
];
// ...


namespace App\Http\Requests\Course;

use Alvarofpp\ExpandRequest\Traits\RemoveExtraParameters;
use Illuminate\Foundation\Http\FormRequest;

class ShowRequest extends FormRequest
{
    use RemoveExtraParameters;
    // ...
}


namespace App\Http\Requests\Course;

use Alvarofpp\ExpandRequest\Traits\RemoveExtraParameters;
use Illuminate\Foundation\Http\FormRequest;

class ShowRequest extends FormRequest
{
    use RemoveExtraParameters;
    
    protected $accept = [
        'field_1', 'field_2',
    ];
    // ...
}