从刀片模板到存储控制器的Laravel pass id

从刀片模板到存储控制器的Laravel pass id,laravel,laravel-5,Laravel,Laravel 5,我正试图将id传递给存储控制器,因为我需要保存从另一个表检索的业务id。然而,我得到: App\Http\Controllers\EventController::store()缺少参数2 以下是我的看法: @extends('master') @section('title', 'Live Oldham') @section('content') <div class="col-lg-y col-lg-offset-3"> <ul class="list-

我正试图将id传递给存储控制器,因为我需要保存从另一个表检索的业务id。然而,我得到:

App\Http\Controllers\EventController::store()缺少参数2

以下是我的看法:

@extends('master') @section('title', 'Live Oldham')
@section('content')
    <div class="col-lg-y col-lg-offset-3">  
    <ul class="list-group-list">
        @foreach ($business->businesses as $business)
        <li class="list-group-item">
        <a target="_blank" href="{{ url('business/' . $business->id) }}"> {{($business->name) }}</a><a href="{{ url('events/create/' . $business->id) }}" class="fa fa-plus pull-right" aria-hidden="true"></a>
        </li>
        @endforeach       
    </ul>
    </div>
@endsection
表格:

@extends('master')@节('title','liveoldham'))
@节(“内容”)
@if(会话('message'))
@如果(会话('message')=“成功”)
创建的事件
@否则
有一个致命的错误!抱歉,我们正在努力修复它!
@恩迪夫
@恩迪夫
$(函数(){
$(document.tooltip();
} );
创建事件
{{csrf_field()}}
活动名称
@如果($errors->has('title'))
{{$errors->first('title')}
@恩迪夫
频率
选择事件频率。。。
一次性事件
每日的
周报
月刊
每年
@如果($errors->has('frequency'))
{{$errors->first('frequency')}
@恩迪夫
活动开始日期
@如果($errors->has('startdate'))
{{$errors->first('email')}
@恩迪夫
活动结束日期
@如果($errors->has('enddate'))
{{$errors->first('enddate')}
@恩迪夫
事件描述
@如果($errors->has('description'))
{{$errors->first('description')}
@恩迪夫
添加事件
@端部

您可以将id传递给表单操作

<form method="POST" action="{{ action('EventController@store', $business->id) }}" class="form-horizontal" role="form">
...
</form>

...

表单视图代码在哪里?它现在在那里;)将$business_id传递给表单视图,然后将操作表单更改为:action=“{{url('''}}}/events/store/{{{$business_id}}}}”,并将其添加到路由文件:route::post('events/store/{id},'EventController@store');
@extends('master') @section('title', 'Live Oldham')
@section('content')
<div class="container">
<!-- Alert Messages -->
@if (session('message'))
@if (session('message')=="success")
    <div class="alert alert-success">
        Event Created
    </div>
@else
    <div class="alert alert-danger">
       There has been a fatal error! Apologies, we are working to fix it!
    </div>
@endif
@endif
<!-- JQuery UI init -->
<script>
  $( function() {
    $( document ).tooltip();
  } );
</script> 
 <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Create Event</div>
                    <div class="panel-body">
                        <form class="form-horizontal" role="form" method="POST" action="{{ action('EventController@store') }}">
                        {{ csrf_field() }}
                        <div class="form-group{{ $errors->has('title') ? ' has-error' : '' }}">
                        <div style="display:none;" class="title_message form-control alert-warning"></div>
                            <label for="title" class="col-md-4 control-label">Event Title</label>
                        <div class="col-md-6">
                        <input id="title" type="text" class="form-control" placeholder="Event title"
                        title="What is the event title?" name="title" value="{{ old('title') }}">
                            @if ($errors->has('title'))
                                <span class="help-block">
                            <strong>{{ $errors->first('title') }}</strong>
                                </span>
                            @endif
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('frequency') ? ' has-error' : '' }}">
                        <div style="display:none ;" class="frequency_message form-control alert-warning"></div>
                            <label id="frequency2" for="frequency" class="col-md-4 control-label">Frequency</label>
                        <div class="col-md-6">
                        <select class="form-control" name="frequency" id="frequency">
                            <option selected disabled>Choose event frequency...</option>
                            <option value="One">One-time Event</option>
                            <option value="Daily">Daily</option>
                            <option value="Weekly">Weekly</option>
                            <option value="Monthly">Monthly</option>
                            <option value="Yearly">Yearly</option>
                        </select>
                                @if ($errors->has('frequency'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('frequency') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('startdate') ? ' has-error' : '' }}">
                        <div style="display:none ;" class="startdate_message form-control alert-warning"></div>
                            <label id="startdate2" for="startdate" class="col-md-4 control-label">Event Start Date</label>
                        <div class="col-md-6">
                            <input id="startdate" type="date" class="form-control" placeholder="Start Date"
                            title="When does the event start?" name="startdate" value="{{ old('startdate') }}">
                                @if ($errors->has('startdate'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        <div class="form-group{{ $errors->has('enddate') ? ' has-error' : '' }}">
                        <div style="display:none ;" class="enddate_message form-control alert-warning"></div>
                            <label id="address3" for="enddate" class="col-md-4 control-label">Event End Date</label>
                        <div class="col-md-6">
                            <input id="enddate" type="date" class="form-control" placeholder="End Date"
                            title="When does the event end?" name="enddate" value="{{ old('enddate') }}">
                                @if ($errors->has('enddate'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('enddate') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>                        
                        <div class="form-group{{ $errors->has('description') ? ' has-error' : '' }}">
                        <div style="display:none ;" class="description_message form-control alert-warning"></div>
                            <label id="description2" for="description" class="col-md-4 control-label">Event Description</label>
                        <div class="col-md-6">
                            <textarea id="description" type="text" class="form-control" placeholder="Event description"
                            title="Here goes event description" name="description" value="{{ old('description') }}">
                            </textarea>
                                @if ($errors->has('description'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('description') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <button type="submit" id="submit" class="btn btn-success">
                                    Add Event
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

@endsection
<form method="POST" action="{{ action('EventController@store', $business->id) }}" class="form-horizontal" role="form">
...
</form>