Laravel Collectiveでのhiddenの扱い

hiddenはinput type=”hidden”で普通に書く

/resources/views/comments/index.blade.php
/resources/views/comments/replies/index.blade.php

Route

Route::group(['middleware'=>'admin'], function(){
	...//
	Route::resource('admin/comments', 'PostCommentsController');
	Route::resource('admin/comments/replies', 'CommentRepliesController');
});

$ php artisan make:model Comment -m
$ php artisan make:model CommentReply -m

comment migration file

Schema::create('comments', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('post_id')->unsigned()->index();;
            $table->integer('is_active')->default(0);
            $table->string('author');
            $table->string('email');
            $table->text('body');
            $table->timestamps();

            $table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
        });

comment replies migration file

Schema::create('comment_replies', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('comment_id')->unsigned()->index();
            $table->integer('is_active')->default(0);
            $table->string('author');
            $table->string('email');
            $table->text('body');
            $table->timestamps();

            $table->foreign('comment_id')->references('id')->on('comments')->onDelete('cascade');
        });

Model: Post.php

public function comments(){
        return $this->hasMany('App\Post');
    }

Comment.php

protected $fillable = [
		'post_id',
		'author',
		'email',
		'body',
		'is_active'
	];

    public function replies(){
    	return $this->hasMany('App\CommentReply');
    }

CommentReply.php

protected $fillable = [
		'comment_id',
		'author',
		'email',
		'body',
		'is_active'
	];

	public function comment(){
		return $this->belongsTo('App\Comment');
	}

$ php artisan make:controller –resource PostCommentController
$ php artisan make:controller –resource CommentRepliesController

admin.blade.php

<li>
                        <a href="#"><i class="fa fa-wrench fa-fw"></i> Posts<span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li>
                                <a href="{{route('admin.posts.index')}}">All Posts</a>
                            </li>

                            <li>
                                <a href="{{route('admin.posts.create')}}">Create Post</a>
                            </li>

                            <li>
                                <a href="{{route('admin.comments')}}">All Comments</a>
                            </li>

                        </ul>
                        <!-- /.nav-second-level -->
                    </li>

PostCommentsController.php

public function index(){
    	return view('admin.comments.index');
    }

route

Route::get('/post/{id}', ['as'=>'home.post','uses'=>'AdminPostsController@post']);

post.blade.php

<h1>{{$post->title}}</h1>

                <!-- Author -->
                <p class="lead">
                    by <a href="#">{{$post->user->name}}</a>
                </p>
                <hr>
               <!-- Date/Time -->
                <p><span class="glyphicon glyphicon-time"></span> Posted {{$post->created_at->diffForhumans()}}</p>
                <hr>
                <!-- Preview Image -->
                <img class="img-responsive" src="{{$post->photo ? '/' . $post->photo->file : ''}}" alt="">
                <hr>
                <!-- Post Content -->
                <p>{{$post->body}}</p>
                <hr>

 <h4>Leave a Comment:</h4>
                    
                    {!! Form::open(['method'=>'POST', 'action'=>'PostCommentsController@store']) !!}
				        {{ csrf_field()}}
				 
				        <div class="form-group">
				            {!! Form::label('body', 'Body') !!}
				            {!! Form::textarea('body', null, ['class'=>'form-control', 'rows'=>3]) !!}
				        </div>				        
				        <div class="form-group">
				            {!! Form::submit('Submit Comment', ['class'=>'btn btn-primary']) !!}
				        </div>
				    {!! Form::close() !!}                   
                </div>

post.blade.php

 {!! Form::open(['method'=>'POST', 'action'=>'PostCommentsController@store']) !!}
				        {{ csrf_field()}}

				        <input type="hidden" name="post_id" value="{{$post->id}}">
				 
				        <div class="form-group">
				            {!! Form::label('body', 'Body') !!}
				            {!! Form::textarea('body', null, ['class'=>'form-control', 'rows'=>3]) !!}
				        </div>				        
				        <div class="form-group">
				            {!! Form::submit('Submit Comment', ['class'=>'btn btn-primary']) !!}
				        </div>
				    {!! Form::close() !!} 

@if(Sessin::has('comment_message'))
						{{session('comment_message')}}
                @endif

PostCommentsController.php

use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Auth;
use App\User;
use App\Photo;
use App\Comment;

public function store(Request $request){

    	$user = Auth::user();

    	$data = [
    		'post_id' => $request->post_id,
    		'author' => $user->name,
    		'email' => $user->email,
    		'body' => $request->body
    	];
    	Comment::create($data);
    	$request->session()->flash('comment_message','Your message has been submitted and is waiting moderation' );

    	return redirect()->back();
    }

hiddenはinput type=”hidden”で書くという事は、フォームの確認ページがある場合、そこは全てcollectiveは使わずに書く、ということになりますね。