fomvasss/laravel-url-facet-filter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fomvasss/laravel-url-facet-filter

最新稳定版本:1.7.0

Composer 安装命令:

composer require fomvasss/laravel-url-facet-filter

包简介

Building and displaying facet filter parameters and managing them

README 文档

README

License Build Status Latest Stable Version Total Downloads Quality Score

Building and displaying facet filter parameters and managing them

Installation

Run from the command line:

composer require fomvasss/laravel-url-facet-filter

Publishing

php artisan vendor:publish --provider="Fomvasss\UrlFacetFilter\ServiceProvider"

Usage

Build url`s

<a href="{{ \FacetFilter::build('color', 'red') }}">Red</a>	
<a href="{{ \FacetFilter::build('color', 'green') }}">Green</a>	
<a href="{{ \FacetFilter::build('size', 'm') }}">M</a>	
<a href="{{ \FacetFilter::build('size', 'xl') }}">XL</a>	

Usage in controller

app/Http/Controllers/ProductControllr.php

<?php 

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,
            ]);
        }  
}

Example, in url string:

https://my-site.com/products?⛃=color☛red⚬green♦size☛m♦ergonomic☛form-1⚬form-2

In php controller (after prepare FacetFilter::toArray()):

array:3 [▼
  "color" => array:2 [▼
    0 => "red"
    1 => "green"
  ]
  "size" => array:1 [▼
    0 => "m"
  ]
  "ergonomic" => array:2 [▼
    0 => "form-1"
    1 => "form-2"
  ]
]

Links

统计信息

  • 总下载量: 237
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-25