PHP code example of vagebond / runtype

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

    

vagebond / runtype example snippets


use Illuminate\Http\Resources\Json\JsonResource;

/** @mixin \App\Models\Product */
class ProductResource extends JsonResource
{
    public $showHiddenData = false;

    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'hidden' => $this->when($this->showHiddenData, false),
        ];
    }
}
bash
php artisan vendor:publish --tag="runtype-config"
bash
php artisan runtype:generate