我不明白为什么我会得到这个错误。Laravel 5.2 BadMethodCallException在Controller.php行107:方法[保存]不存在
控制器:SectionHeaderController
<?php
namespace SimpleCms\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Carbon\Carbon;
use App\Http\Requests;
use App\SectionHeader;
class SectionHeaderController extends Controller {
public function store(Request $request) {
$header = new SectionHeader();
$this->validate($request, [
'title' => 'required',
'image' => 'required|mimes:jpeg,png|max:1024|dimensions:max_width=300,max_height=100',
'heading' => 'required',
'description' => 'required'
]);
$header->title = $request->title;
$header->heading = $request->description;
$header->description = $request->description;
if($request->hasFile('image')) {
$file = Input::file('image');
$timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
$name = $timestamp. '-' .$file->getClientOriginalName();
$header->filePath = $name;
$file->move(public_path().'/images/', $name);
}
$header->save();
return $this->create()->with('success', 'Done!');
}
}
型号:SectionHeader
<?php
namespace SimpleCms;
use Illuminate\Database\Eloquent\Model;
class SectionHeader extends Model {
protected $table = 'sectionheader';
protected $fillable = [
'title',
'description',
'heading',
'image'
];
}
路线:
Route::post('/home/store', '[email protected]');
我不知道什么是错的,也没有如何解决这个问题。 这个错误出现后,我点击表格提交指向这[email protected]
任何想法?
谢谢。
编辑: 我每建议改变了,我得到新的错误
FatalErrorException在SectionHeaderController.php线34:类 '应用\ SectionHeader' 未找到
我明白你在说什么,我会改变最后一部分不用担心,但我可以找出为什么我得到这个错误 – Morpheus
为什么你改变你的问题????????????????? ?? –
将您的模型名称空间更改为“App \ SectionHeader”...您的名称空间为:SimpleCms ... @Morpheus –