how can i get the id passed with the url and save it in an input ? and the controller is like that :
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use URL;
use DB;
class productController extends Controller
{
//
public function getIndex(){
$in=URL::get('id');
$product=DB::table('products')->get(['id','name','salary','sale','p_salary','n_salary','best','type','image_name','category_id','sub_id','incategory_id','new']);
return view('contents.products')->with('product',$product)
->with('in',$in);
}
}
and the view is like that :
#extends('master')
#section('content')
<form method="POST" action="{{action('productController#getIndex')}}" enctype="multipart/form-code">
{!! csrf_field() !!}
<div class="em-wrapper-main">
<div class="container container-main">
<div class="em-inner-main">
<div class="em-wrapper-area02"></div>
<div class="em-wrapper-area03"></div>
<div class="em-wrapper-area04"></div>
<div class="em-main-container em-col1-layout">
<div class="row">
<div class="em-col-main col-sm-24">
<div class="page-title category-title">
<h1>Shoes</h1>
</div>
<div class="category-products">
<div class="toolbar-top">
<div class="toolbar">
<div class="pager">
<p class="amount"> Items 1 to 12 of 20 total</p>
<div class="pages">
<ol>
<li class="current">1</li>
<li>2
</li>
<li>
<a class="next i-next" href="#" title="Next"> <img src="{{asset('assets/images/pager_arrow_right.gif')}}" alt="Next" class="v-middle" /> </a>
</li>
</ol>
</div>
</div><!-- /.pager -->
<div class="sorter">
<p class="view-mode">
<label>View as:</label> <strong title="Grid" class="grid">Grid</strong> List
</p>
<div class="sort-by toolbar-switch">
<div class="toolbar-title">
<label>Sort By</label>
<select class="sortby" name="sortby">
<option value="position" selected="selected"> Position</option>
<option value="name"> Name</option>
<option value="price"> Price</option>
</select>
</div>
<a href="#" title="Set Descending Direction"><img src="{{asset('assets/images/i_asc_arrow.png')}}" alt="Set Descending Direction" class="v-middle" />
</a>
</div>
<div class="limiter toolbar-switch">
<div class="toolbar-title">
<label>Show</label>
<select class="toolbar-show">
<option value="12" selected="selected"> 12</option>
<option value="24"> 24</option>
<option value="36"> 36</option>
</select>
</div>
</div>
</div><!-- /.sorter -->
</div>
</div><!-- /.toolbar-top -->
<div id="em-grid-mode">
<ul class="emcatalog-grid-mode products-grid emcatalog-disable-hover-below-mobile">
#foreach($product as $p)
#foreach($in as $n)
#if($p->incategory_id == $n->id)
<li class="item first">
<div class="product-item">
<div class="product-shop-top">
<a href="{{action('productdetailController#getProduct' , array('id' => $p->id))}}" title="{{$p->name}}" class="product-image">
<img class="em-img-lazy img-responsive em-alt-hover" src="{{asset('images/')}}/{{$p->image_name}}" width="220" height="220" alt="WIASSI Version 1" />
<img id="product-collection-image-206" class="em-img-lazy img-responsive em-alt-org" src="{{asset('images/')}}/{{$p->image_name}}" width="220" height="220" alt="WIASSI Version 1" />
<span class="bkg-hover"></span> </a>
<div class="bottom">
<div class="em-btn-addto text-center ">
<button type="button" title="Add to Cart" class="button btn-cart" onclick="206"><span><span>Add to Cart</span></span>
</button>
<ul class="add-to-links">
<li><button type="submit" class="link-wishlist" name="submit" title="Add to Wishlist">Add to Wishlist</button>
</li>
<li>Add to Compare
</li>
</ul>
</div>
<div class="quickshop-link-container"> Quickshop
</div>
</div>
</div>
<div class="product-shop">
<div class="f-fix">
<h2 class="product-name text-center "> {{$p->name}} </h2>
<div class=" text-center">
<div class="ratings">
<div class="rating-box">
<div class="rating" style="width:%"></div>
</div> <span class="amount">(0)</span>
</div>
</div>
<div class="text-center ">
<div class="price-box"> <span class="regular-price" id="product-price-206"> <span class="price" content="{{$p->salary}}">${{$p->salary}}</span> </span>
</div>
</div>
<div class="desc std text-center em-element-display-hover">{{$p->name}}</div>
</div>
</div>
</div><!-- /.product-item -->
</li>
#endif
#endforeach
#endforeach
</ul>
</div><!-- /.em-grid-mode -->
<div class="toolbar-bottom em-box-03">
<div class="toolbar">
<div class="pager">
<p class="amount"> Items 1 to 12 of 20 total</p>
<div class="pages">
<ol>
<li class="current">1</li>
<li>2
</li>
<li>
<a class="next i-next" href="#" title="Next">
<img src="{{asset('assets/images/pager_arrow_right.gif')}}" alt="Next" class="v-middle" /> </a>
</li>
</ol>
</div>
</div><!-- /.pager -->
<div class="sorter">
<p class="view-mode">
<label>View as:</label> <strong title="Grid" class="grid">Grid</strong> List
</p>
<div class="sort-by toolbar-switch">
<div class="toolbar-title">
<label>Sort By</label>
<select class="sortby" name="sortby">
<option value="position" selected="selected"> Position</option>
<option value="name"> Name</option>
<option value="price"> Price</option>
</select>
</div>
<a href="#" title="Set Descending Direction"><img src="{{asset('assets/images/i_asc_arrow.png')}}" alt="Set Descending Direction" class="v-middle" />
</a>
</div>
<div class="limiter toolbar-switch">
<div class="toolbar-title">
<label>Show</label>
<select class="toolbar-show">
<option value="12" selected="selected"> 12</option>
<option value="24"> 24</option>
<option value="36"> 36</option>
</select>
</div>
</div>
</div><!-- /.sorter -->
</div>
</div><!-- /.toolbar-bottom -->
</div><!-- /.category-products -->
</div>
</div>
</div><!-- /.em-main-container -->
</div>
</div>
</div><!-- /.em-wrapper-main -->
</form>
#stop
how to get the products that have the incategory_id passed with the url ?
You could use the Request facade to get the id and then, use the where method to get the requested product like this:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Request;
use DB;
class productController extends Controller
{
public function getIndex()
{
$in=Request::get('id');
$product=DB::table('products')->where('incategory_id', $in)->get(['id','name','salary','sale','p_salary','n_salary','best','type','image_name','category_id','sub_id','incategory_id','new']);
return view('contents.products')->with('product',$product);
}
}
Also, you could type-hint the Illuminate\Http\Request:
public function getIndex(Request $request)
{
$in=$request->get('id');
// ...
}
Related
For my website I want to display search result (on a complete new page) using the parameters in the dropdown select input. I have 4 dropdowns and I tried multiple different ways to make it work. But it doesn't seem to work!
Below is my CodeIgniter 4 code
Home Controller
The home controller file which gathers data from 4 dropdown inputs the data is fetched as an array. The array is then executed through the getSearch method located in the home model.
public function search_residential() {
$data['getfooter'] = $this->homeModel->getFooterInfo();
$params = array(
'category' => $this->request->getVar('category'),
'area' => $this->request->getVar('area'),
'bedrooms' => $this->request->getVar('bedrooms'),
'washrooms' =>$this->request->getVar('washrooms'),
);
$data['search'] = $this->homeModel->getSearch($params);
return view('search', $data);
}
Home Model
The home model contains the query of search.
//Searching data
public function getSearch($params) {
$category = $params['category'];
$area = $params['area'];
$bedrooms = $params['bedrooms'];
$washrooms = $params['washrooms'];
$builder= $this->db->table('tblresidential');
$builder->select('*');
$builder->where('1 = 1');
if ($category != '') {
$builder->where('category', $category);
}
if ($area != '') {
$builder->where('area', $area);
}
if ($bedrooms != '') {
$builder->where('bedrooms', $bedrooms);
}
if ($washrooms != '') {
$builder->where('washrooms', $washrooms);
}
$result = $builder->get();
return $result;
}
HTML Code
The HTML code that is used for execution
<div class="search__area-inner">
<?= form_open('/home/search_residential'); ?>
<div class="row">
<div class="col-6 col-lg-3 col-md-3">
<div class="form-group">
<select name="category" class="wide select_option">
<option data-display="Property Type">Property Type</option>
<option value="Property on sale">Property on Sale</option>
<option value="Property on rent">Property on Rent</option>
</select>
</div>
</div>
<div class="col-6 col-lg-3 col-md-3">
<div class="form-group">
<select name="area" class="wide select_option">
<option data-display="Select Area">Select Area</option>
<option value="2000">2000</option>
<option value="1800">1800</option>
<option value="1500">1500</option>
<option value="1200">1200</option>
<option value="900">900</option>
<option value="600">600</option>
<option value="300">300</option>
<option value="100">100</option>
</select>
</div>
</div>
<div class="col-6 col-lg-3 col-md-3">
<div class="form-group">
<select name="bedrooms" class="wide select_option">
<option data-display="Select Bedrooms">Select Bedrooms</option>
<option value="1 bedroom">1</option>
<option value="1.5 bedrooms">1.5</option>
<option value="2 bedrooms">2</option>
<option value="2.5 bedrooms">2.5</option>
<option value="3 bedrooms">3</option>
<option value="4 bedrooms">4</option>
<option value="5 bedrooms">5</option>
</select>
</div>
</div>
<div class="col-6 col-lg-3 col-md-3">
<div class="form-group">
<select name="washrooms" class="wide select_option">
<option data-display="Select Washrooms">Washrooms</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</div>
</div>
<div class="col-12">
<div class="form-group">
<button class="btn btn-primary text-uppercase btn-block"> search
<i class="fa fa-search ml-1"></i>
</button>
</div>
</div>
</div>
<?= form_close(); ?>
</div>
Result View (the page on which result shows)
This is the page where result shows
<?php if(!empty($search)) : ?>
<section class="residential-property-list">
<div class="container">
<div class="row">
<?php foreach($search as $properties) : ?>
<div class="col-lg-12">
<div class="card__image card__box-v1">
<div class="row no-gutters">
<div class="col-md-4 col-lg-3 col-xl-4">
<div class="card__image__header h-250">
<a href="<?= base_url('/home/residential_property'); ?>/<?= $properties->id; ?>">
<img src="<?= $properties->imageone; ?>" alt="featured-image" class="img-fluid w100 img-transition">
<div class="info text-white"> for <?= $properties->category; ?></div>
</a>
</div>
</div>
<div class="col-md-4 col-lg-6 col-xl-5 my-auto">
<div class="card__image-body">
<h6 class="text-capitalize">
<?= $properties->project; ?>
</h6>
<ul class="list-inline card__content">
<li class="list-inline-item">
<span>
Bedrooms <br>
<i class="fa fa-inbox"></i> <?= $properties->bedrooms; ?>
</span>
</li>
<li class="list-inline-item">
<span>
Washrooms <br>
<i class="fa fa-map"></i> <?= $properties->washrooms; ?>
</span>
</li>
<li class="list-inline-item">
<span>
Property Facing <br>
<i class="fa fa-inbox"></i> <?= $properties->facing; ?>
</span>
</li>
<li class="list-inline-item">
<span>
Property area <br>
<i class="fa fa-map"></i> <?= $properties->area; ?>
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</section>
<?php else: ?>
<br>
<br>
<div class="container"><h4 class="text-center">No Result Found Yet</h4></div>
<br>
<br>
<?php endif; ?>
The model's get(...) method returns false|ResultInterface.
To receive the actual result set,
Instead of:
(Home Model)
// ...
$result = $builder->get();
return $result;
// ...
Use this:
Result Arrays
// ...
return $builder->get()->getResult();
// ...
I am building search filtering for my site and I am trying to use livewire to build the search component. The search component has a few filters and one of them is a categories dropdown with a subcategories dropdown below it. When a top-level category is selected it should update the subcategories dropdown with the sub-categories of the top-level category. This should happen dynamically without updating the rest of the component, but the actual search results should only be returned when the apply filter button is pressed.
But the subcategories dropdown is not being updated even though if I dd on $this->subcategories I can see the variable has actually been updated. What am I doing wrong here:
<div class="col-xs-12 col-sm-5 col-md-4 col-lg-3">
<aside id="tg-sidebar" class="tg-sidebar">
<form wire:submit.prevent="submitSearch" class="tg-formtheme tg-formnerrowsearch">
<div class="tg-sidebartitle"><h2>Narrow Your Search:</h2></div>
<fieldset>
<div id="tg-narrowsearchcollapse" class="tg-themecollapse tg-narrowsearchcollapse" wire:ignore>
<div class="tg-collapsetitle">
<i class="fa fa-rotate-left"></i>
<span class="fa fa-angle-down">By Title/Keyword</span>
</div>
<div class="tg-themecollapsecontent">
<div class="form-group tg-inputwithicon">
<i class="icon-magnifier"></i>
<input wire:model.defer="keyword" id="keyword" type="search" name="keyword" class="form-control" placeholder="Search Title/Keyword">
</div>
</div>
<div class="tg-collapsetitle">
<i class="fa fa-rotate-left"></i>
<span class="fa fa-angle-down">By Category</span>
</div>
<div class="tg-themecollapsecontent">
<div class="form-group">
<div class="tg-select">
<select wire:model="category" id="category" name="category">
<option disabled>Select Category</option>
#foreach ($categories as $category)
<option value="{{$category->id}}">{{$category->name}}</option>
#endforeach
</select>
</div>
</div>
<div class="form-group">
<div class="tg-selectgroup">
<select wire:model.defer="subcategory" id="subcategory" name="subcategory">
<option disabled>Select Subcategory</option>
#if(count($subcategories) > 0)
#foreach ($subcategories as $subcategory)
<option value="{{$subcategory->id}}">{{$subcategory->name}}</option>
#endforeach
#endif
</select>
</div>
</div>
</div>
<div class="tg-collapsetitle">
<i class="fa fa-rotate-left"></i>
<span class="fa fa-angle-down">By Location</span>
</div>
<div class="tg-themecollapsecontent">
<div class="form-group tg-inputwithicon">
<i class="fa fa-crosshairs"></i>
<input wire:model.defer="city" id="city" type="text" name="city" class="form-control" placeholder="Town/City">
</div>
<div class="form-group tg-inputwithicon">
<i class="fa fa-map-marker"></i>
<input wire:model.defer="postcode"id="postcode" type="text" name="postcode" class="form-control" placeholder="Postcode">
</div>
<div class="form-group">
<div class="tg-select">
<select wire:model.defer="distance" id="radius" name="radius">
<option>Distance</option>
<option value="1">Within 1 mile</option>
<option value="5">Within 5 miles</option>
<option value="10">Within 10 miles</option>
<option value="15">Within 15 miles</option>
<option value="20">Within 20 miles</option>
<option value="25">Within 25 miles</option>
<option value="30">Within 30 miles</option>
<option value="35">Within 35 miles</option>
<option value="40">Within 40 miles</option>
<option value="45">Within 45 miles</option>
<option value="50">Within 50 miles</option>
<option value="55">Within 55 miles</option>
<option value="60">Within 60 miles</option>
<option value="70">Within 70 miles</option>
<option value="80">Within 80 miles</option>
<option value="90">Within 90 miles</option>
<option value="100">Within 100 miles</option>
<option value="150">Within 150 miles</option>
<option value="200">Within 200 miles</option>
<option value="1200">Nationwide</option>
</select>
</div>
</div>
</div>
<div class="tg-collapsetitle">
<i class="fa fa-rotate-left"></i>
<span class="fa fa-angle-down">By Ads Type</span>
</div>
<div class="tg-themecollapsecontent">
<div class="tg-checkboxgroup">
<span class="tg-checkbox">
<input wire:model.defer="featured" type="checkbox" id="tg-featuredads" name="featured" value="1">
<label for="tg-featuredads">
<span>Featured Ads</span>
<span>987327</span>
</label>
</span>
<span class="tg-checkbox">
<input wire:model.defer="urgent" type="checkbox" id="tg-urgentads" name="urgent" value="1">
<label for="tg-urgentads">
<span>Urgent Ads</span>
<span>48952413</span>
</label>
</span>
<span class="tg-checkbox">
<input wire:model.defer="auction" type="checkbox" id="tg-auctionads" name="auction" value="1">
<label for="tg-auctionads">
<span>Auctions</span>
<span>48952413</span>
</label>
</span>
<span class="tg-checkbox">
<input wire:model.defer="will_post" type="checkbox" id="tg-postageads" name="will_post" value="1">
<label for="tg-postageads">
<span>Willing to Post</span>
<span>48952413</span>
</label>
</span>
</div>
</div>
</div>
<button type="submit" class="tg-btn">apply filter</button>
</fieldset>
</form>
</aside>
</div>
<div class="col-xs-12 col-sm-7 col-md-8 col-lg-9">
<div id="tg-content" class="tg-content">
<div class="tg-contenthead">
<div class="tg-sortandview">
<div class="tg-sortby">
<strong>Sort by:</strong>
<div class="tg-select">
<select>
<option value="Most Recent">Most Recent</option>
<option value="Most Recent">Most Recent</option>
<option value="Most Recent">Most Recent</option>
</select>
</div>
</div>
<div class="tg-views">
<strong>View As Grid</strong>
<ul>
<li class="tg-active"><a href="javascript:void(0);"><i
class="fa fa-th-large"></i></a></li>
<li><i class="fa fa-reorder"></i></li>
</ul>
</div>
</div>
<div class="tg-applyedfilters">
<ul>
<li class="alert alert-dismissable fade in">
×
<span>Manchester</span>
</li>
<li class="alert alert-dismissable fade in">
×
<span>0 - 0</span>
</li>
<li class="alert alert-dismissable fade in">
×
<span>Brand New</span>
</li>
<li class="alert alert-dismissable fade in">
×
<span>Featured Ads</span>
</li>
<li class="alert alert-dismissable fade in">
×
<span>Area Unit: Sq. ft.</span>
</li>
<li class="alert alert-dismissable fade in">
×
<span>Sq. ft. 2500 - Sq. ft.5000</span>
</li>
<li class="alert alert-dismissable fade in">
×
<span>Rooms: 04</span>
</li>
<li class="alert alert-dismissable fade in">
×
<span>2014 - 2016</span>
</li>
<li class="alert alert-dismissable fade in">
×
<span>1500 - 3000</span>
</li>
<li><a class="tg-btncleall" href="javascript:void(0);">Clear All</a></li>
</ul>
</div>
</div>
<div class="tg-ads">
<div class="row">
#if(empty($results))
<div class="alert alert-warning">
<strong>Sorry!</strong> No Adverts Found.
</div>
#else
#foreach($results as $result)
<div class="col-xs-6 col-sm-12 col-md-6 col-lg-4 tg-verticaltop">
<div class="tg-ad tg-verifiedad">
<figure>
<span class="tg-themetag tg-featuretag">featured</span>
<a href="{{route('listing.view', $result)}}">
#if(isset($result->images->where('order', '=', 1)->first()->name))
<img src="{{asset ('storage/ad_images/thumbnails/'.$result->images->where('order', '=', 1)->first()->name)}}" title="{{$result->images->where('order', '=', 1)->first()->title}}" alt="{{$result->images->where('order', '=', 1)->first()->alt}}">
#else
#endif
</a>
<span class="tg-photocount">See {{$result->images->count()}} Photos</span>
</figure>
<div class="tg-adcontent">
<ul class="tg-productcagegories">
<li>{{$result->categories->last()->name}}</li>
</ul>
<div class="tg-adtitle">
<h3>{{$result->title}}</h3>
</div>
<time datetime="2017-06-06">Last Updated: {{\Carbon\Carbon::createFromTimeStamp(strtotime($result->updated_at))->diffForHumans()}}</time>
<div class="tg-adprice"><h4>£{{$result->price}}</h4></div>
<address>
#foreach (json_decode($result->user->addresses->where('id', '=', $result->user_address_id)) as $address)
{{$address->city.' '.$address->post_code}}
#endforeach
</address>
<div class="tg-phonelike">
<a class="tg-btnphone" href="javascript:void(0);">
<i class="icon-phone-handset"></i>
<span data-toggle="tooltip" data-placement="top" title="Show Phone No." data-last="{{$result->user->contacts->where('id', '=', $result->user_contact_id)->first()->mobile}}"><em>Show Phone No.</em></span>
</a>
<span class="tg-like tg-liked"><i class="fa fa-heart"></i></span>
</div>
</div>
</div>
</div>
#endforeach
#endif
</div>
</div>
{{-- <nav class="tg-pagination">
namespace App\Http\Livewire;
use Livewire\Component;
use App\Category;
use App\User;
use App\Advert;
class Listings extends Component
{
public $keyword;
public $categories = [];
public $category;
public $subcategories = [];
public $subcategory;
public $city;
public $postcode;
public $distance;
public $featured;
public $urgent;
public $auction;
public $will_post;
public $results;
public $model;
public function mount($model, $paginate = '10')
{
$this->model = $model;
$this->paginate = $paginate;
$this->categories = Category::whereNull('parent_id')->get();
$this->subcategories = Category::with('children')->where('parent_id', $this->categories->first()->id)->get();
}
public function submitSearch()
{
$advert = new Advert();
if($this->featured){
$advert = $advert->where('mark_ad_featured', '1');
}
if($this->urgent){
$advert = $advert->where('mark_ad_urgent', '1');
}
if($this->auction){
$advert = $advert->where('is_auction', '1');
}
if($this->auction){
$advert = $advert->where('is_auction', '1');
}
if($this->will_post){
$advert = $advert->where('local_pickup', '0');
}
$advert = $advert->where('status', '1');
$advert->orderBy('updated_at', 'asc');
$this->results = $advert->get();
}
public function render()
{
if(!empty($this->category)) {
$this->subcategories = Category::where('parent_id', $this->category)->get();
}
//dd($this->subcategories);
return view('livewire.listings');
}
}
I have tried using the updated lifecycle hook for category property change but it still does not work:
public function updatedCategory($value)
{
if($value) {
$this->category = $value;
$this->subcategories = Category::where('parent_id', $this->category)->get();
}
}
could you change the wire:ignore in this line for wire:ignore.self or not use it if isn't necessary ??? i can't figure it out anything else in that code
<div id="tg-narrowsearchcollapse" class="tg-themecollapse tg-narrowsearchcollapse" wire:ignore.self>
I've created some kind of webshop for my highschool project. After building a filter system that searches through my database and loads them with the help of my self-written class product loader.
To set the filtervariables I've worked with $_GET. Everything is working perfectly fine on my localhost but when uploading to the server posed by my highschool only the header which I'm "requiring" separately works but anything else won't load.
Might it be that the server doesn't allow $_GET methods?
<?php
$current_page = 'Webshop.php';
require 'header.php';
require 'includes\productloader.inc.php';
?>
<body>
<form method="get"action="Webshop.php">
<aside class="EDside">
<div class="Filtersidebar">
<h1>Filter</h1>
<ul class="Filter">
<li><a>Max. Höhe</a></li>
<li><a>Max. Breite</a></li>
<li><a>Max. Tiefe</a></li>
<li><a>Metallart</a></li>
<li><a>Max. Preis</a></li>
<li><input type="text" name="Höhe" value=""></li>
<li><input type="text" name="Breite" value=""></li>
<li><input type="text" name="Tiefe" value=""></li>
<li><select id="Metallart" name="Metallart">
<option value=""></option>
<option value="Bronze">Bronze</option>
<option value="Messing">Messing</option>
<option value="Kupfer">Kupfer</option>
<option value="Edelstahl">Edelstahl</option>
<option value="Aluminium">Aluminium</option>
<option value="Rostig">Rostig</option>
</select></li>
<li><input type="text" name="Preis" value=""></li>
</ul>
</div>
<div>
<a href = Webshop.php><button>Zurücksetzen</button></a>
<button type ="submit" >Anwenden</button>
</div>
</aside>
</form>
<?php
if(isset($_GET['Höhe'])){
$maxhöhe;
if(!$_GET['Höhe']=="")
$maxhöhe = $_GET['Höhe'];
else
$maxhöhe = null;
if(!$_GET['Breite']=="")
$maxbreite = $_GET['Breite'];
else
$maxbreite = null;
if(!$_GET['Tiefe']=="")
$maxtiefe = $_GET['Tiefe'];
else
$maxtiefe = null;
$metallart;
if(!$_GET['Metallart']=="")
$metallart = $_GET['Metallart'];
else
$metallart = null;
$maxpreis;
if(!$_GET['Preis']=="")
$maxpreis = $_GET['Preis'];
else
$maxpreis = null;
if($maxhöhe == null && $maxbreite == null && $maxtiefe == null && $metallart == null && $maxpreis == null)
$loader = productloader::withoutstatement();
else
$loader = productloader::withstatement($maxhöhe,$maxbreite,$maxtiefe,$metallart,$maxpreis);
}
else
$loader = productloader::withoutstatement();
$productcount = count($loader->products);
?>
<?php
if($productcount>0){
echo '
<section class="EDSection">
<ul class="Skulptur">
<li> <div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[0]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[0]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[0]->preis.' EUR</p>
</div>
</div>
</div>
</li>
';
}
if($productcount>1){
echo '
<li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[1]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[1]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[1]->preis.' EUR</p>
</div>
</div>
</div>
</li>
';
}
if($productcount>2){
echo '
<li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[2]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[2]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[2]->preis.' EUR</p>
</div>
</div>
</div>
</li>
';
}
if($productcount>3){
echo '
<li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[3]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[3]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[3]->preis.' EUR</p>
</div>
</div>
</div>
</li>
';
}
if($productcount>4){
echo'
<li> <div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[4]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[4]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[4]->preis.' EUR</p>
</div>
</div>
</div>
</li>
';
}
if($productcount>5){
echo ' <li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[5]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[5]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[5]->preis.' EUR</p>
</div>
</div>
</div>
</li>';
}
if($productcount>6){
echo ' <li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[6]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[6]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[6]->preis.' EUR</p>
</div>
</div>
</div>
</li>';
}
if($productcount>7){
echo ' <li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[7]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[7]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[7]->preis.' EUR</p>
</div>
</div>
</div>
</li>';
}
?>
</section>
<section>
<div style="text-align: center">
<ul class="pagination">
<li>«</li>
<li><a class="active" href="Webshop.php">1</a></li>
<li>2</li>
<li>3</li>
<li>»</li>
</ul>
</div>
</section>
<?php
require 'footer.php';
?>
</body>
</html>
Here is the update of my question:
I am having a filter tab from the database but and doing a loop to show the filters tab.
PROBLEM
But the problem is when we click on tabs it should show a dropdown from where I can choose what we want to filter. but its only showing first filter and other are not working.
EDIT
my view file
<form id="tabForms" action="{{route('o')}}" method="GET">
<div class="col-xs-12 col-sm-8 col-md-6 filter-bootstrap" style="padding:0px;margin-bottom:20px;">
<div class="input-group input-group-lg">
<div class="input-group-btn">
<button type="button" class="btn btn-warning dropdown-toggle"
data-toggle="dropdown" aria-expanded="false"
style="background:#FFF;color:#575962;border:solid 1px #e7ecf1;box-shadow: none;font-weight: 300;
font-size: 15px;text-transform: capitalize;padding: 5px 12px;height: 35px;border-radius:3px 0px 0px 3px;">Add Search Field
</button>
<ul class="dropdown-menu productFilter" id="filters">
<li id="Payment Status" onclick="productFilter(this.id)" >Payment Status</li>
<li id="Shipping Status" onclick="productFilter(this.id)" >Shipping Status</li>
<li id="Order Total" onclick="productFilter(this.id)" >Order Total</li>
<li id="Item Weight" onclick="productFilter(this.id)" >Item Weight</li>
<li id="Shipping class Name" onclick="productFilter(this.id)" >Shipping class Name</li>
<li id="Shipping Country" onclick="productFilter(this.id)" >Shipping Country</li>
<li id="Refund Status" onclick="productFilter(this.id)" >Refund Status</li>
<li id="Shipping class Name" onclick="productFilter(this.id)" >Shipping class Name</li>
<li id="Warehouse Location" onclick="productFilter(this.id)" >Warehouse Location</li>
<li id="Shipment Status Date" onclick="productFilter(this.id)" >Shipment Status Date</li>
<li id="Payment status" onclick="productFilter(this.id)" >Payment status</li>
</ul>
<input type="hidden" class="form-control" name="productFilterType" value="" id="productFilterType"/>
</div>
<!-- /btn-group -->
<!--show text on input -->
<div class="filter-top">
#php
use App\Filter;
$userId = Auth::id();
$filters = Filter::where('user_id',$userId)->get();
foreach($filters as $getfilter)
{
$filter_name = $getfilter->filter_name;
$filter_id = $getfilter->id;
#endphp
<label id="inputTagFilterId" class=filter-id{{$filter_id}} style="color:#666;margin:7px;"> {{$filter_name}} <span class="close-tab"><a style="border-left: dotted 1px #666;color: #666;"> X </a></span></label>
#php }
#endphp
</div>
<div id="filterpop">
<div class='tb-dropdown tb-fieldfilter-popup tb-fieldfilter-selectfieldfiltereditor-popup tb-fieldfilter-selectfieldfiltereditor-popup-large' style='display: block; min-width: 261px; z-index: 1001; opacity: 1; left: 513.609px; top: 195.75px;' data-turbodropdown-popup='' data-positioned='bottomleft'>
<div class='tb-fieldfilter-popup-fields'>
<select class='tb-select tb-fieldfilter-selectfieldfiltereditor-operators' data-turbofieldfilter-selectfieldfiltereditor-operator-field=''>
<option value='equals'>Equals</option>
<option value='notEquals'>Not Equals</option>
<option value='in'>In List</option>
<option value='notIn'>Not In List</option>
</select>
<span class='tb-fieldfilter-popup-errors' data-turbofieldfilter-selectfieldfiltereditor-operator-errors=''></span>
<span class='tb-fieldfilter-selectfieldfiltereditor-values' data-turbofieldfilter-selectfieldfiltereditor-value-fields=''>
<div class='tb-fieldfilter-selectfieldfiltereditor-selector tb-inlineselect tb-inlineselect-multiple' data-turbofieldfilter-selectfieldfiltereditor-selector=''>
<div class='tb-inlineselect-messages' data-turboinlineselect-messages=''>
</div>
<div class='tb-inlineselect-searchbox tb-text-field tb-text-field-with-feedback tb-searchbox' data-turboinlineselect-searchbox=''>
<input type='text' class='tb-input' autocomplete='off' data-turbosearchbox-input='' placeholder='Search...'>
<i class='tb-text-field-feedback' data-turbosearchbox-state-indicator=''></i>
</div>
<div class='tb-inlineselect-selected-items' data-turboinlineselect-selected-items=''>
<div class='tb-inlineselect-selected-items-header' data-turboinlineselect-selected-items-header=''>
<span class='tb-inlineselect-selected-items-title' data-turboinlineselect-selected-items-title=''>Selected:</span>
</div>
<div class='tb-inlineselect-selected-items-viewport' data-turboinlineselect-selected-items-viewport='' style='height: 150px;'>
<div class='tb-inlineselect-selected-items-list' data-turboinlineselect-selected-items-list=''>
<div data-turbolistview-item-key='0' class='tb-listview-item'>
<div class='tb-inlineselect-item'>Unshipped</div>
</div>
</div>
</div>
</div>
<div class='tb-inlineselect-search-results' data-turboinlineselect-search-results='' style=''>
<div class='tb-inlineselect-search-results-header' data-turboinlineselect-search-results-header=''>
<span class='tb-inlineselect-search-results-title' data-turboinlineselect-search-results-title=''>Search Results:</span>
<span class='tb-inlineselect-select-all' data-turboinlineselect-select-all='' data-turboinlineselect-action='selectAll'>Select All</span>
<span class='tb-inlineselect-unselect-all' data-turboinlineselect-unselect-all='' data-turboinlineselect-action='unselectAll'>Clear</span>
</div>
<div class='tb-inlineselect-search-results-viewport' data-turboinlineselect-search-results-viewport='' style='height: 150px;'>
<div class='tb-inlineselect-search-results-list' data-turboinlineselect-search-results-list=''>
<div data-turbolistview-item-key='0' class='tb-listview-item tb-inlineselect-selected-item'>
<div class='tb-inlineselect-item'>Unshipped</div>
</div>
<div data-turbolistview-item-key='1' class='tb-listview-item'>
<div class='tb-inlineselect-item'>Shipped</div>
</div>
<div data-turbolistview-item-key='2' class='tb-listview-item'>
<div class='tb-inlineselect-item'>Partially Shipped</div>
</div>
<div data-turbolistview-item-key='4' class='tb-listview-item'>
<div class='tb-inlineselect-item'>Pending Shipment</div>
</div>
<div data-turbolistview-item-key='8' class='tb-listview-item'>
<div class='tb-inlineselect-item'>Canceled</div>
</div>
<div data-turbolistview-item-key='16' class='tb-listview-item'>
<div class='tb-inlineselect-item'>Third Party Managed</div>
</div>
</div>
<div class='tb-inlineselect-search-results-truncated' data-turboinlineselect-search-results-truncated=''>
</div>
</div>
</div>
</div>
<span class='tb-fieldfilter-popup-errors' data-turbofieldfilter-selectfieldfiltereditor-value-errors=''>
</span>
</span>
</div>
<div class='tb-fieldfilter-popup-buttons'>
<button class='tb-btn' data-turbofieldfilter-selectfieldfiltereditor-update=''>Update</button>
<a href='#' class='tb-btn-link' data-turbofieldfilter-selectfieldfiltereditor-cancel=''>Cancel</a>
</div>
</div>
</div>
</div>
</div>
</div>
Controller file
public function index(request $request)
{
$productFilterType = $request->input('productFilterType');
return view('pages.order',array(
'productFilterType' =>$productFilterType,
));
}
jquery
function productFilter(value) {
alert(value);
jQuery("#productFilterType").val(value);
jQuery("#tabForms").submit();
}
$(document).on('click','#inputTagFilterId',function(){
var label = $('#inputTagFilterId');
var filterid = label.attr('class');
alert(filterid);
$("."+filterid).click(function(){
$("#filterpop").show();
});
});
i'm trying to make a wish list in my project,when i press a button in each product it should add this product to the list and get the user_id and the product_id from there tables but that's not happening can u help me , and this is the controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\User;
use DB;
class listController extends Controller
{
//
public function getIndex(){
$list=DB::table('wishlist')->get();
$product=DB::table('products')->
get(['name','id','salary','image_name']);
$user=DB::table('users')->get(['id']);
return view('contents.wishlist')->with('list',$list)
->with('product',$product)
->with('user',$user);
}
public function postCreate(Request $request){
$id=$request->input('id');
$user_id=User::get(['id']);
$product_id=$request->input('product_id');
DB::table('wishlist')->
insert(['id'=>$id,'id'=>$user_id,'product_id'=>$product_id]);
return redirect('/wishlist');
}
}
and this is the form i'm using :
#extends('master')
#section('content')
<div class="wrapper-breadcrums">
<div class="container">
<div class="row">
<div class="col-sm-24">
<div class="breadcrumbs">
<ul>
<li class="home"> <span >Home</span> <span class="separator">/ </span>
</li>
<li class="cms_page"> <strong>My Account</strong>
</li>
</ul>
</div>
</div>
</div>
</div>
</div><!-- /.wrapper-breadcrums -->
<div class="em-wrapper-main">
<div class="container container-main">
<div class="em-inner-main">
<div class="em-wrapper-area02"></div>
<div class="em-main-container em-col2-left-layout">
<div class="row">
<div class="col-sm-18 col-sm-push-6 em-col-main">
<div class="em-wrapper-area03"></div>
<div class="my-account">
<div class="my-wishlist">
<div class="page-title title-buttons">
<h1>My Wishlist</h1>
</div>
<form id="wishlist-view-form" action="wishlist/create" method="post">
<fieldset>
<input name="form_key" type="hidden" value="inYgLvzSpOOWWVoP" />
<table class="data-table" id="wishlist-table">
<thead>
<tr>
<th></th>
<th>Product Details and Comment</th>
<th>Add to Cart</th>
<th></th>
</tr>
</thead>
<tbody>
#foreach($product as $p)
#foreach($list as $l)
#foreach($user as $u)
#if($l->user_id == $u->id)
<tr id="item_6">
<td>
<a class="product-image" href="product_detail" title=" {{$p->name}} "> <img src="{{asset('images/')}}/{{$p->image_name}}" width="113" height="113" alt=" {{$p->name}} " /> </a>
</td>
<td>
<h3 class="product-name"> {{$p->name}} </h3>
<div class="description std">
<div class="inner">The must-have tee for his third birthday!</div>
</div>
<textarea name="description[6]" rows="3" cols="5" title="Comment" placeholder="Please, enter your comments..."></textarea>
</td>
<td>
<div class="cart-cell">
<div class="price-box" itemscope itemtype="http://schema.org/Product"> <span class="regular-price" id="product-price-258"> <span class="price" content="{{$p->salary}}">${{$p->salary}}</span> </span>
</div>
<div class="add-to-cart-alt">
<input type="text" class="input-text qty validate-not-negative-number" name="qty[6]" value="1" />
<button type="button" title="Add to Cart" onclick="addWItemToCart(6);" class="button btn-cart"><span><span>Add to Cart</span></span>
</button>
</div>
<p><a class="link-edit" href="#">Edit</a>
</p>
</div>
</td>
<td>Remove item
</td>
</tr>
#endif
#endforeach
#endforeach
#endforeach
</tbody>
</table>
<div class="buttons-set buttons-set2">
<button type="submit" name="save_and_share" title="Share Wishlist" class="button btn-share"><span><span>Share Wishlist</span></span>
</button>
<button type="button" title="Add All to Cart" class="button btn-add"><span><span>Add All to Cart</span></span>
</button>
<button type="submit" name="do" title="Update Wishlist" class="button btn-update"><span><span>Update Wishlist</span></span>
</button>
</div>
</fieldset>
</form>
</div>
<div class="buttons-set">
<p class="back-link"><small>« </small>Back
</p>
</div>
</div>
</div><!-- /.em-col-main -->
<div class="col-sm-6 col-sm-pull-18 em-col-left em-sidebar">
<div class="em-wrapper-area02"></div>
<div class="em-line-01 block block-account">
<div class="block-title em-block-title"> <strong><span>My Account</span></strong>
</div>
<div class="block-content">
<ul>
<li>Account Dashboard
</li>
<li>Account Information
</li>
<li>Address Book
</li>
<li>My Orders
</li>
<li>Billing Agreements
</li>
<li>Recurring Profiles
</li>
<li>My Product Reviews
</li>
<li>My Tags
</li>
<li class="current"><strong>My Wishlist</strong>
</li>
<li>My Applications
</li>
<li>Newsletter Subscriptions
</li>
<li class="last">My Downloadable Products
</li>
</ul>
</div>
</div><!-- /.em-line-01 -->
</div><!-- /.em-sidebar -->
</div>
</div>
</div>
</div>
</div><!-- /.em-wrapper-main -->
#stop