PHP code example of fomvasss / laravel-url-facet-filter

1. Go to this page and download the library: Download fomvasss/laravel-url-facet-filter 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/ */

    

fomvasss / laravel-url-facet-filter example snippets


 

namespace App\Http\Controllers;

class ProductController extends Controller 
{
        public function index(Request $request)
        {
            $filterAttrs = \FacetFilter::toArray($request->get(\FacetFilter::getFilterUrlKey()));
            
            $products = Product::with('media')
                ->facetFilterable($filterAttrs) // facetFilterable - for example your scope
                ->get();

            return view('article.index', [
                'articles' => $products,
            ]);
        }  
}
bash
php artisan vendor:publish --provider="Fomvasss\UrlFacetFilter\ServiceProvider"
html
array:3 [▼
  "color" => array:2 [▼
    0 => "red"
    1 => "green"
  ]
  "size" => array:1 [▼
    0 => "m"
  ]
  "ergonomic" => array:2 [▼
    0 => "form-1"
    1 => "form-2"
  ]
]