I am trying to access a route in Laravel web route from Vue, but it return Error:
Request failed with status code 500 response "message": "Class 'App\Http\Controllers\Admin\Customer' not found",
This is my controller routes in web.php
Route::group(['prefix' => 'admin'], function () {
Route::group(['prefix' => 'customers'], function() {
Route::get('/', 'Admin\CustomerController@index');
Route::post('/store', 'Admin\CustomerController@store');
Route::post('/{id}/edit', 'Admin\CustomerController@update');
Route::get('/{id}', 'Admin\CustomerController@delete');
Route::get('/api/search', 'Admin\CustomerController@search');
});
});
This is my search query in my customercontroller class
public function search()
{
$results = Customer::orderBy('firstname')
->when(request('q'), function($query) {
$query->where('firstname', 'like', '%'.request('q').'%')
->orWhere('lastname', 'like', '%'.request('q').'%')
->orWhere('shop_name', 'like', '%'.request('q').'%')
->orWhere('shop_address', 'like', '%'.request('q').'%')
;
})
->limit(6)
->get();
return response()
->json(['results' => $results]);
}
vue template where i tried to access customerUrl
data(){
return{
form: {},
errors: {},
customerUrl:'/admin/customers/api/search',
productUrl:'/admin/products/api/search'
}
},
use App\Customer
at top of your controller class – porloscerros Ψ