| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- namespace App;
- use App\Constraint\HasTextConstraint;
- $core = Core::getInstance();
- $core->addBreadcrumb("/products", __("Products"));
- $nvp = [];
- $request = Request::fromRequest();
- $product_id = $request->int("product_id");
- if($product_id) {
- $nvp["id"] = $product_id;
- }
- $supplier_id = $request->int("supplier_id");
- if($supplier_id) {
- $nvp["supplier_id"] = $supplier_id;
- }
- $name = $request->string("name");
- if($name) {
- $nvp["name"] = new HasTextConstraint($name);
- }
- $sku = $request->string("sku");
- if($sku) {
- $nvp["sku"] = new HasTextConstraint($sku);
- }
- $type = $request->int("type");
- if($type) {
- $nvp["type"] = $type;
- }
- $count = Product::count($nvp);
- $pagination = new Pagination($count);
- $pagination->setTerms(__("%s product"), __("%s products"));
- $products = Product::query($nvp, [
- "sort" => "id",
- "offset" => $pagination->getOffset(),
- "limit" => $pagination->getPageSize()
- ]);
- View::include("header");
- View::include("products", compact("products", "pagination", "product_id", "supplier_id", "name", "sku", "type"));
- View::include("footer");
|