【发布时间】:2015-07-07 11:19:55
【问题描述】:
我的新模型:
<?php
class Style extends Eloquent {
protected $table = 'styles';
}
定义路线:
Route::group(array('prefix' => '/templates'), function(){
Route::post('/style-create', array('uses' => 'StyleController@postCreateStyle', 'as' => 'postCreateStyle'));
});
还有模型的控制器:
<?php
class StyleController extends BaseController {
public function postCreateStyle() {
$style = new Style();
$style->save();
return Redirect::route('getStyleHome');
}
}
还有html表单:
<form role="form" method="post" action="{{ URL::route('postCreateStyle') }}">
<!-- FIELDS -->
<input type="submit" value="{{ isset($style) ? 'Save' : 'Create' }} template" class="btn btn-lg btn-primary" />
</form>
如果我点击提交,我会收到此错误:
[2015-04-28 14:11:59] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined method Style::save()' in C:\xampp\htdocs\cspage\app\controllers\StyleController.php:18
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleShutdown()
#1 {main} [] []
我已经重启了xampp,重新导入了整个数据库,我已经清除了自动加载:php artisan dump-autoload,但是错误仍然存在。我做错了什么?
【问题讨论】:
-
您是否有一个名为
style的迁移?另外,我假设这是 L4? -
也试试
php composer dump-autoload。