【发布时间】:2017-04-16 12:05:14
【问题描述】:
我是 laravel 的新手。我的应用版本 5.2.45 有问题
当我尝试传递变量以查看来自数据库的信息时,App\Http\Controllers\PhotoController::create() 缺少参数 1:
路线:
Route::get('photo/create/{id}', 'PhotoController@create');
控制器:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use DB;
use Session;
class PhotoController extends Controller { private $table = 'photos';
// Show Create Form
public function create($gallery_id) {
// render view
return view('photo.create', compact('gallery_id'));
}
查看:
@section('content')
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h1>Upload photo</h1>
{!! Form::open(array('action' => 'PhotoController@store', 'enctype' => 'multipart/form-data')) !!}
{{ Form::label('title', 'Title:') }}
{{ Form::text('title', null, array('class' => 'form-control', 'required' => '', 'maxlength' => '255')) }}
{{ Form::label('description', 'Description:') }}
{{ Form::text('description', null, array('class' => 'form-control', 'required' => '', 'minlength' => '5', 'maxlength' => '255') ) }}
{{ Form::label('image', 'Photo:') }}
{{ Form::file('cover') }}
<input type="hidden" name="gallery_id" value="{{ $gallery_id }}">
{{ Form::submit('Upload photo', array('class' => 'btn btn-success btn-lg btn-block', 'style' => 'margin-top: 20px;')) }}
{!! Form::close() !!}
</div>
</div>
@endsection
【问题讨论】: