2017-06-24 18 views
0

私はPostController、create_postページを持っているので、CRUD操作を実行したいと思い、web.phpでルートを設定しました。laravelの空白ページのトラブル5.4

PostController.php

<?php 

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 

class PostController extends Controller 
{ 

    public function index() 
    { 
     // 
    } 

    public function create() 
    { 
     return view('/posts/create_post'); //link to the create_post page inside posts forlder 
    } 


    public function store(Request $request) 
    { 
     $this->validate($request, array(
      'title'=>'required|max:255', 
      'body'=>'required' 
     )); 
     $post= new Post; 
     $post->title=$request->title; 
     $post->body=$request->body; 
     $post->save(); 
    } 

    public function show($id) 
    { 
     // 
    } 

    public function edit($id) 
    { 
     // 
    } 

    public function update(Request $request, $id) 
    { 
     // 
    } 

    public function destroy($id) 
    { 
     // 
    } 
} 

リソース>ビュー>ポスト> create_post.blade.php ポストはcreate_postビューが保存されているフォルダです。 インクルードまたはパーシャルエラーがないため、フォームパートのみをインクルードしました。 ルートweb.php

   <h1>Create New Post</h1> 
       <div class="form-area"> 
     {{ Form::open(array('route' => 'posts/store')) }} 
    <br style="clear:both"> 
        <div class="form-group"> 
            {{Form::label('title', 'Title:')}} 
            {{Form::text('title', null, array('class'=>'form-control', 'name'=>'title'))}} 
        </div> 
        <div class="form-group"> 
         {{Form::label('body', 'Body:')}} 
         {{Form::textarea('body', null, array('class'=>'form-control', 'name'=>'body'))}} 
        </div> 
      {{Form::submit('Post', array('class'=>'btn btn-primary pull-right', 'name'=>'submit'))}} 
{{ Form::close() }} 
    </div> 

ルート> ::リソース( '/ポスト/ create_post'、 'のPostController')。私はhttp://127.0.0.1:8000/posts/create_postリンクを実行しているこれまでのページが白紙であるが、私は歓迎のために同じテンプレートを使用している、についてと連絡先ページと完全に取り組んでいるが、これらのページが別のフォルダに保存され、別々のコントローラを持っている

答えて

1

使用してみてください:

return view('posts.create_post'); 
関連する問題