{"id":18622,"date":"2020-09-10T13:53:39","date_gmt":"2020-09-10T13:53:39","guid":{"rendered":"http:\/\/www.devopsschool.com\/blog\/?p=18622"},"modified":"2021-10-29T06:31:43","modified_gmt":"2021-10-29T06:31:43","slug":"how-to-use-dropdown-search-functionality-with-pagination-in-laravel-php-framework","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-use-dropdown-search-functionality-with-pagination-in-laravel-php-framework\/","title":{"rendered":"How to Use  Dropdown  Search Functionality with Pagination in Laravel PHP Framework?"},"content":{"rendered":"\n\n\n<p><\/p>\n\n\n\n<p><strong>Step 1<\/strong>. Firstly, add dropdown in blade file according to below code,here mention name=&#8221;city_filter&#8221; and id id=&#8221;city_filter&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"717\" height=\"285\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/1-1.png\" alt=\"\" class=\"wp-image-18623\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/1-1.png 717w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/1-1-300x119.png 300w\" sizes=\"auto, (max-width: 717px) 100vw, 717px\" \/><\/figure>\n\n\n\n<p><strong>step 2<\/strong>:pass id in table tag in<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"268\" height=\"279\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/8-3.png\" alt=\"\" class=\"wp-image-18624\"\/><\/figure>\n\n\n\n<p><strong>step 3<\/strong>: write jquery code that is mention below. certain  code  observe carefully.<br>(i) pass id dropdown city_filter in jquery code $(&#8220;#city_filter&#8221;),<br>(ii) welcome_country is named routing mentioned in routes url:&#8221;{{ url(&#8216;welcome_country&#8217;) }}?filter_city=&#8221;+city_filter,<br>(iii)step 2 table id pass in jquery $(&#8216;#myTable tbody&#8217;).html(&#8221;);<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"648\" height=\"325\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/2-3.png\" alt=\"\" class=\"wp-image-18625\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/2-3.png 648w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/2-3-300x150.png 300w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/figure>\n\n\n\n<p><strong>step 4: Routing <\/strong><\/p>\n\n\n\n<p>step 3 second point url name should match in routing<br>Route::get(&#8216;welcome_country&#8217;,&#8217;GuestController@welcome_country&#8217;)-&gt;name(&#8216;welcome_country&#8217;);<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"743\" height=\"37\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/4-6.png\" alt=\"\" class=\"wp-image-18626\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/4-6.png 743w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/4-6-300x15.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/4-6-740x37.png 740w\" sizes=\"auto, (max-width: 743px) 100vw, 743px\" \/><\/figure>\n\n\n\n<p>step 5:Controller<br>(i) $filter_city mention in jquery is requested particular city in $filter_city = $request-&gt;get(&#8216;filter_city&#8217;);<br>(ii) if filter city is selected in dropdown then selected city id should match with table<br>(iii) return page blade file mention in step 2 and compact variable should match with page blade file<br>return view(&#8216;page&#8217;, compact(&#8216;gallery&#8217;))-&gt;render(); match with in blade file @foreach ($gallery as $gall) will be mention in next step<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"588\" height=\"412\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/5-6.png\" alt=\"\" class=\"wp-image-18627\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/5-6.png 588w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/5-6-300x210.png 300w\" sizes=\"auto, (max-width: 588px) 100vw, 588px\" \/><\/figure>\n\n\n\n<p><strong>step 6<\/strong>: <strong>blade file code<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"660\" height=\"654\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/6-3.png\" alt=\"\" class=\"wp-image-18628\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/6-3.png 660w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/6-3-300x297.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/6-3-150x150.png 150w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/6-3-80x80.png 80w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/figure>\n\n\n\n<p><strong>NOTE: CSS and script bootstrap link should not missed<\/strong><\/p>\n\n\n\n<p><strong>Result<\/strong>: select dropdown city<\/p>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_58284\"><iframe loading=\"lazy\"  id=\"_ytid_80866\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_58284\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"553\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/7-3-1024x553.png\" alt=\"\" class=\"wp-image-18629\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/7-3-1024x553.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/7-3-300x162.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/7-3-768x415.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/09\/7-3.png 1030w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Step 1. Firstly, add dropdown in blade file according to below code,here mention name=&#8221;city_filter&#8221; and id id=&#8221;city_filter&#8221; step 2:pass id in table tag in step 3: write jquery code that&#8230; <\/p>\n","protected":false},"author":31,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5201],"tags":[5651,6415,6035],"class_list":["post-18622","post","type-post","status-publish","format-standard","hentry","category-laravel","tag-controller","tag-dropdown","tag-jquery"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/18622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/31"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=18622"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/18622\/revisions"}],"predecessor-version":[{"id":24539,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/18622\/revisions\/24539"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=18622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=18622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=18622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}