我的新模式:Laravel:创建新的雄辩模式,但laravel不承认它
<?php
class Style extends Eloquent {
protected $table = 'styles';
}
定义路线:
Route::group(array('prefix' => '/templates'), function(){
Route::post('/style-create', array('uses' => '[email protected]', '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? – ceejayoz
版本:L4或L5? –
尝试'php composer dump-autoload'。 –