我厌倦了这个错误,使用了管理员和用户登录项目并得到了这个错误。
请查看我的文件。
这是错误的屏幕截图: enter image description here
图库上传路线:
Route::get('gallery-upload', 'ImageGalleryController@index');
Route::post('/gallery-upload', 'ImageGalleryController@upload');
Route::delete('/gallery-upload/{id}', 'ImageGalleryController@destroy');
控制器文件:
<?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()
{
$images = ImageGallery::get();
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)
{
$this->validate($request, [
'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);
return back()
->with('success','Image Uploaded successfully.');
}
/**
* Remove Image function
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
ImageGallery::find($id)->delete();
return back()
->with('success','Image removed successfully.');
}
}
答案 0 :(得分:1)
路线档案
Route::get('gallery-upload', 'Admin\ImageGalleryController@index');
Route::post('/gallery-upload', 'Admin\ImageGalleryController@upload');
Route::delete('/gallery-upload/{id}', 'Admin\ImageGalleryController@destroy');
控制器文件:
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\ImageGallery;
class ImageGalleryController extends Controller
{
/**
* Listing Of images gallery
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$images = ImageGallery::get();
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)
{
$this->validate($request, [
'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);
return back()
->with('success','Image Uploaded successfully.');
}
/**
* Remove Image function
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
ImageGallery::find($id)->delete();
return back()
->with('success','Image removed successfully.');
}
}
答案 1 :(得分:0)
您的命名空间看起来错了,我在任何地方都看不到管理员,这就是应用程序正在寻找的。 p>
App\Http\Controllers\ImageGalleryController
不
App\Http\Controllers\Admin\ImageGalleryController