I have a controller named RankController.php
. I rename in UsersController.php
manually when I want to separate some methods. Then I choose to rename it back in to RankController.php
. Note: I only change the name of the file, I don't change the name of the class. Here is the code of controller.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Schema;
use App\User;
use App\Rank;
use App\Ban;
class RankController extends Controller
{
// Constructor function
public function __construct()
{
// Check if user is logged in
$this->middleware('auth');
}
public function search(Request $request)
{
$this->validate($request, ['search' => 'required', ]);
$users = User::select('id', 'name')->where([
['name', '!=', Auth()->user()->name],
['name', 'like', "%" . $request->input('search') . "%"],
])->paginate(10);
return view('rank.search')
->with('users', $users);
}
}
And here is where I call the controller:
{!! Form::open(['action' => ['RankController@search'], 'method' => 'POST']) !!}
{{Form::text('search', '', ['placeholder' => 'Search a user'])}}
{{Form::submit('Search', ['class' => 'btn btn-primary'])}}
{!! Form::close() !!}
Note: This is the single file where I get the error. This is the error: Action App\Http\Controllers\RankController@search not defined. (View: /var/www/htdocs/Proiect/resources/views/layouts/app.blade.php) (View: /var/www/htdocs/Proiect/resources/views/layouts/app.blade.php)
I try the code on other PC and it generate the same error.