我受夠了這個錯誤,使用管理員和用戶登錄項目,並得到這個錯誤。Laravel 5.4:ReflectionException在Container.php行749:類應用程序 HTTP 控制器管理 ImageGalleryController不存在
請看我的文件。
這是錯誤的截圖: enter image description here
路線的畫廊上傳:
Route::get('gallery-upload', '[email protected]');
Route::post('/gallery-upload', '[email protected]');
Route::delete('/gallery-upload/{id}', '[email protected]');
控制器的文件:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\ImageGallery;
class ImageGalleryController extends Controller
{
/**
* Listing Of images gallery
*
* @return \Illuminate\Http\Response
*/
public function index()
{
\t $images = ImageGallery::get();
\t return view('gallery-upload',compact('images'));
}
public function img()
{
$images = ImageGallery::get();
return view('gallery',compact('images'));
}
// /**
// * Upload image function
// *
// * @return \Illuminate\Http\Response
public function upload(Request $request)
{
\t $this->validate($request, [
\t \t 'title' => 'required',
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$input['image'] = time().'.'.$request->image->getClientOriginalExtension();
$request->image->move(public_path('images'), $input['image']);
$input['title'] = $request->title;
ImageGallery::create($input);
\t return back()
\t \t ->with('success','Image Uploaded successfully.');
}
/**
* Remove Image function
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
\t ImageGallery::find($id)->delete();
\t return back()
\t \t ->with('success','Image removed successfully.'); \t
} \t
}
假如你創建'Admin'目錄'ImageGalleryController'?我確定有命名空間問題! –
有對admin/ImageGalleryController沒有路由,那麼怎麼能來到這個錯誤..類應用程序\ HTTP \控制器\管理\ ImageGalleryController不存在, 這是命名空間的問題.. –
是的,我已經添加了命名空間。 namespace App \ Http \ Controllers \ Admin; –