Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

luanrodriguesp's avatar

[L5.2] Search form not working on production server

I have a search form(via get), locally it works well but when i deploy for production the form just stop to work.

here is my Controller:

<?php
namespace App\Http\Controllers;

use App\Question;
use Illuminate\Http\Request;
use App\Http\Requests\QuestionRequest;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redirect;
use Laracasts\Flash\Flash;

class QuestionsController extends Controller
{
    protected $requests;

    public function __construct(Request $request)
    {
        $this->requests = $request;
    }


    public function index(){

        if($this->requests['search']) { //on production it comes null
            $q = $this->requests['search'];

            return view('questions.index', array(
                'questions'  => Question::search($q)->paginate(20),
                'searchMsg' => 'Resultado(s) para o termo \'<i>'.$q.'</i>\' ',
            ));
        }

        $questions = Question::orderBy('updated_at', 'DESC')->paginate(20);
        return view('questions.index', array(
            'questions' => $questions
        ));
    }
}

My routes MyRoutes

Here is my form

{!!  Form::open(array('route' => 'questions.index', 'method' => 'GET', 'class' => 'navbar-form navbar-right')) !!}
    <div class="form-group">
        <div class="input-group">
            <input type="text" class="form-control" name="search" value="{{ Request::input('search') }}" autocomplete="off" placeholder="Pesquisar...">
                        <span class="input-group-btn">
                            <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
            </span>
        </div><!-- /input-group -->
    </div><!-- /form-group -->
{!!  Form::close() !!}
0 likes
0 replies

Please or to participate in this conversation.