我創建了一個允許用戶創建主題/帖子的視圖。該視圖的鏈接位於我的導航欄中。但問題是,當我嘗試點擊鏈接(顯示視圖)時,我無任何錯誤地重定向到主頁。Laravel 5.2簡單地嘗試顯示視圖時出錯
在導航欄的鏈接中,我放了<li><a href="{{ route('createtheme') }}">
,它簡單地激活名爲「createtheme」的路線。該路線如下: Route::get('/theme/create', '[email protected]')->name('createtheme');
。 因此,這激活了ThemesController.php中的創建方法。這是:
public function create()
{
return view('themes.create');
}
所以,如果我正確讀這個,這應該給我正確的看法,對不對?它不會給我任何錯誤,所以我不知道在哪裏尋找。
這是我想要顯示的觀點:
@extends('layouts.default')
@section('content')
<div class="container main-content">
<div class="row first-row">
<div class="col s12">
<div class="card">
<div class="card-content clearfix">
<span class="card-title">New theme</span>
</div>
</div>
<div class="card">
<div class="card-content">
<form method="POST" action="">
{{ csrf_field() }}
<input type="hidden" name="user_id" value="{{ Auth::user()->id }}">
<div class="row">
<div class="input-field col s6 has-error form-group">
<input id="title" class="form-control" type="text" name="title" placeholder="Title of topic">
<label for="title" class="active">Title of theme</label><span>Titel is mandatory!</span>
</div>
<div class="file-field input-field col s6 form-group">
<div class="btn cyan darken-1 disabled"><span>Attachment</span>
<input id="attachement" type="file" name="attachment" class="disabled">
</div>
<div class="file-path-wrapper form-group">
<input type="text" placeholder="geen" class="file-path validate form-control">
</div>
</div>
</div>
<div class="row">
<div class="col s12 form-group">
<textarea id="message-body" class="form-control" name="body"></textarea>
</div>
</div>
<div class="row">
<div class="col s6">
Hier komen opties om het onderwerp te sluiten of
aan te geven dat het opgelost is, alleen bij bewerken
</div>
<div class="col s6">
<a href="" class="btn right cyan darken-1" type="submit">Save</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
<script type="text/javascript" src="{{ asset('js/ckeditor/ckeditor.js') }}">
</script>
<script type="text/javascript" src="{{ asset('js/editor.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/blog.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/materialize.js') }}">
</script>
@endsection
這裏是與此相關的問題的途徑。
Route::get('/theme/create', '[email protected]')->name('createtheme');
Route::post('/theme/create', '[email protected]');
當然Store方法:
public function store(Request $request)
{
Theme::create($request->input()); //Dit doet hetzelfde als bovenstaande
return redirect('/');
}
中間件
我將取代'返回查看(「themes.create」);用''DD在控制器(「來到這裏」)',以確保它實際上使得人們控制器方法和問題不在您的中間件或視圖中。 –
我把它取代@DavidAllen但它仍然做同樣的事情,它只是帶我回到主頁 –
你在得到什麼?白頁? –