我的新模式: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'。 –