Laravel 5 simple search box using GET method

Laravel 5 simple search box using GET method


First of all, I know there are many ways to do this, and this might not be the best way to do it.

So what we are going to do is to add a search box text field in the upper left side of our table. Definitely it will search for any records containing the word to search. The search box can be reuse in other index as well to make tidy codes.

First Step: View

This is the search box (please never mind the add link, you can remove it if you want). Here, we create a form that will direct to officesController@index. The method we use is GET. The role is the variable you will use in your URI to put the search parameter.

You may put this code in a separate blade and reuse it with other view, OR you can just directly add it in the view below which is the index.

Since we will be going to incorporate our search box in the index.blade.php we will going to add it to it.


If you want to reuse our search box to other pages, you can do something like below, and save it as search.blade.php

We converted our text parameters into variables, then in every index.blade.php we include it, and add some variables that should be same name to the variable of the search box. So in your index, include the following code.

This will reuse the search.blade.php by including it to every index.blade.php you have.

Note: This may not exact solution for nested URI segments.

In this stage we will test our search and you should get something like below.

the search box4

here, we searched for an office name BAC. Since we are using GET method, you should have the ?search=BAC params in your URL.

Prev1 / 2

Programmer, Database Designer and Administrator for Web Application. Who loves to read and write interesting topics.


    • just use your route, you don’t have to modify it. GET method will append parameter in your URL will not affect route.

  1. Thanks for your personal marvelous posting! I really enjoyed
    reading it, you could be a great author. I will
    be sure to bookmark your blog and will eventually come back someday.
    I want to encourage you to continue your great work,
    have a nice holiday weekend!

  2. I simply want to mention I am newbie to blogging and really loved your page. Almost certainly I’m going to bookmark your blog post . You amazingly have superb well written articles. Many thanks for sharing your web-site.

  3. My spouse and i also stumbled over here provided by a different website and thought I should check things
    out. I really like what I see so i am just just following you.

    Anticipate looking over your online page yet again.

  4. I simply want to mention I am newbie to blogging and site-building and honestly enjoyed your blog site. Almost certainly I’m planning to bookmark your blog . You definitely have terrific article content. With thanks for revealing your web page.

  5. Hello There. I stumbled upon your weblog the usage of
    msn. Which is an incredibly neatly written article. I’ll ensure to bookmark it and return to learn more of your own useful info.
    Thanks to the post. I am going to definitely comeback.

  6. Hello there, just became alert to your site through Google, and found that it is really informative.
    I am just gonna look out for brussels. I’ll appreciate if you continue
    this from now on. A great deal of individuals will be
    taken advantage of your writing. Cheers!

  7. That is really interesting, You’re an excessively professional blogger.

    I’ve joined your feed and look forward to seeking more of your great
    post. Also, I’ve shared your website in my social networks

  8. Sweet blog! I discovered it while surfing around on Yahoo News.

    Do you have any tips on how to get indexed in Yahoo News?

    I’ve been trying for some time but I never often arrive!
    Appreciate it

  9. Right here is the perfect web site for everyone who would like to understand this topic.
    You understand so much its almost hard to
    argue with you (not that I really would want toHaHa).
    You definitely put a new spin on a subject that has been discussed
    for years. Great stuff, just great!

  10. Hi there! This post couldn’t be written any better!
    Reading this post reminds me of my previous room mate!
    He always kept talking about this. I will forward this
    write-up to him. Pretty sure he will have a good read. Many thanks for sharing!

  11. Hi, i feel that we saw you visited my website so i came to return the favor.I’m wanting to find what you
    should enhance my website!I suppose its ok to work with several of your ideas!!

  12. Excellent goods of your stuff, man. I have take into accout your stuff before and you’re just extremely excellent.
    I actually like what you’ve got below, certainly like what you
    are stating and just how in which you might be saying it.
    You are making it enjoyable and you still take care of to keep it sensible.

    I can’t wait to read considerably more by you.
    This is really a wonderful site.

  13. Normally I don’t read post on blogs, but I would want to say that this write-up very pressured me to try out and do it!
    Your writing style has been surprised me. Thanks a lot,
    very great post.

  14. I blog often and I genuinely appreciate your information. This article has truly peaked my
    interest. I’m going to book mark your website and keep checking for new details about
    once per week. I subscribed to your RSS feed too.

  15. Very nice post. I simply found your blog and wished to state that I actually have really enjoyed browsing your website posts.

    In fact I will be subscribing to the feed and i also hope you write again soon!

  16. Have you thought about including a little more than merely your posts?
    I am talking about, everything you say is fundamental and all.
    But just imagine in the event you added some great photos or videos to provide
    your posts more, “pop”! Your content is extremely good however with pics
    and videos, this site could certainly be among the most beneficial in the
    field. Awesome blog!

  17. What you composed was actually very logical.
    However, what about this? what if you were to write a awesome headline?
    I am not saying your information isn’t good., but what if you
    added something that makes people want more? I mean Laravel 5 simple
    search box using GET method – is kinda vanilla.
    You ought to glance at Yahoo’s front page and watch how
    they create article titles to get viewers to click.
    You might try adding a video or a picture or two
    to grab people interested about what you’ve written. In my opinion, it might bring
    your posts a little bit more interesting.

  18. I’m very happy to uncover this site. I wish to to many thanks for your personal time just for this fantastic read!!
    I definitely really liked every little bit of it and i
    also perhaps you have saved as a favorite to consider new things in your site.

  19. Hi there, just became aware of your site through Google, and found
    that it can be truly informative. I am just gonna be
    cautious about brussels. I’ll be grateful if you continue this in future.
    A lot of individuals will be taken advantage of your writing.

  20. Howdy I am so glad I found your website, I really found you by mistake, while I was searching on Digg for something
    else, Nonetheless I am here now and would just like to say thank you
    for a fantastic post and a all round enjoyable
    blog (I also love the theme/design), I don’t have
    time to browse it all at the minute but I have bookmarked it and also added in your RSS feeds, so when I have time I will be back to read
    a great deal more, Please do keep up the
    great work.

  21. Have you considered about adding a little more than just your posts?
    I am talking about, whatever you say is valuable and everything.
    Nevertheless imagine if you added some very nice graphics or videos to provide your posts more, “pop”!
    Your site content is excellent however with images and movies,
    this site could undeniably be one of several best in its
    field. Great blog!

  22. Excellent article. Keep posting such kind of information on your blog.
    Im really impressed by your site.
    Hey there, You have done an incredible job.
    I’ll definitely digg it and individually suggest to my friends.
    I am sure they’ll be benefited from this web site.

  23. The other day, while I was at work, my cousin stole my apple ipad and tested to see if it can survive
    a thirty foot drop, just so she can be a youtube sensation. My apple ipad is
    now destroyed and she has 83 views. I know this is completely off topic but I had to share
    it with someone!

  24. Simply wish to say your article is as astonishing. The clearness in your
    post is just cool and i can assume you are an expert on this subject.
    Fine with your permission let me to grab your RSS feed to keep updated with forthcoming post.
    Thanks a million and please continue the rewarding work.

  25. Hey there, I think your site might be having browser
    compatibility issues. When I look at your blog site in Opera, it
    looks fine but when opening in Internet Explorer, it has some
    overlapping. I just wanted to give you a quick heads up!

    Other then that, amazing blog!

  26. Howdy! I realize this is certainly somewhat off topic having said that i was wondering if you knew where
    I was able to find a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having problems finding
    one? Thanks a great deal!

  27. Im not too a great deal of online reader to
    tell the truth however your sites really nice, ensure that is stays up!
    I’ll go ahead and bookmark your site to come back down the road.
    Thanks a lot