我正在使用laravel 5.2,我正在开发项目管理工具。 在我的应用程序中,我有项目,每个项目都有任务,一个任务可能有子任务。 在每个任务中,我都有按钮来创建如下的子任务,
<a href="" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>当我查看与每个项目相关的任务列表时,我的网址如下。
http://localhost:8000/projects/1现在我在视图文件的子任务文件夹中有子任务表单,为每个任务输入子任务
subtasks/subtask.blade.php现在我需要当我点击子任务输入按钮重定向子任务刀片文件为url就是这样。
http://localhost:8000/projects/1/task/1/subtask如何管理子任务添加按钮的href
<a href="" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>和我的路线? 更新这是我的子任务输入表单
<form class="form-vertical" role="form" method="post" action="{{ route('projects/{projectId}/task/{taskId}/subtask')}}"> <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> <input type="text" name="task_name" class="form-control" id="name" value="{{ old('task_name') ?: '' }}"> @if ($errors->has('task_name')) <span class="help-block">{{ $errors->first('task_name') }}</span> @endif </div> <div class="form-group"> <button type="submit" class="btn btn-info">Create Task</button> </div> <input type="hidden" name="_token" value="{{ csrf_token() }}"> </form>我的子任务形式动作是否正确?
I am working with laravel 5.2 and I am developing project management tool. in my application I have projects and each project have tasks and one task may have sub tasks. in each task I have button to create subtasks as following,
<a href="" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>when I view my tasks list witch related to each project my url is as following.
http://localhost:8000/projects/1now i have subtask form in subtasks folder of view file to enter sub tasks to each task
subtasks/subtask.blade.phpnow I need when I click sub task enter button redirect subtask blade file as url is this way.
http://localhost:8000/projects/1/task/1/subtaskhow can I manage href of sub task add button
<a href="" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>and My routes? Updated this is my subtask input form
<form class="form-vertical" role="form" method="post" action="{{ route('projects/{projectId}/task/{taskId}/subtask')}}"> <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> <input type="text" name="task_name" class="form-control" id="name" value="{{ old('task_name') ?: '' }}"> @if ($errors->has('task_name')) <span class="help-block">{{ $errors->first('task_name') }}</span> @endif </div> <div class="form-group"> <button type="submit" class="btn btn-info">Create Task</button> </div> <input type="hidden" name="_token" value="{{ csrf_token() }}"> </form>is my subtask form action correct?
最满意答案
你可以像这样创建路线
http://localhost:8000/projects/1/task/1/subtask Route::get('projects/{projectId}/task/{taskId}/subtask','HomeController@index');用于链接
<a href="{{url('projects/'.$projectId.'/task/'.$taskId.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>`所以在控制器中你可以访问
public function index($projectId,$taskId){ //you can do your query releated task }如果您尚未开发控制器并且希望通过路线传递,则更新
Route::get('projects/{projectId}/task/{taskId}/subtask', function ($projectId, $taskId) { return view('subtasks/subtask',['projectId'=>$projectId,'taskId'=>$taskId]); });You can create route like this
http://localhost:8000/projects/1/task/1/subtask Route::get('projects/{projectId}/task/{taskId}/subtask','HomeController@index');For link
<a href="{{url('projects/'.$projectId.'/task/'.$taskId.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>`so in controller you can access
public function index($projectId,$taskId){ //you can do your query releated task }Update if you have not developed controller and you wish to pass via route then
Route::get('projects/{projectId}/task/{taskId}/subtask', function ($projectId, $taskId) { return view('subtasks/subtask',['projectId'=>$projectId,'taskId'=>$taskId]); });如何在Laravel 5.2中路由子任务URL?(How to route subtasks URL in Laravel 5.2?)我正在使用laravel 5.2,我正在开发项目管理工具。 在我的应用程序中,我有项目,每个项目都有任务,一个任务可能有子任务。 在每个任务中,我都有按钮来创建如下的子任务,
<a href="" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>当我查看与每个项目相关的任务列表时,我的网址如下。
http://localhost:8000/projects/1现在我在视图文件的子任务文件夹中有子任务表单,为每个任务输入子任务
subtasks/subtask.blade.php现在我需要当我点击子任务输入按钮重定向子任务刀片文件为url就是这样。
http://localhost:8000/projects/1/task/1/subtask如何管理子任务添加按钮的href
<a href="" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>和我的路线? 更新这是我的子任务输入表单
<form class="form-vertical" role="form" method="post" action="{{ route('projects/{projectId}/task/{taskId}/subtask')}}"> <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> <input type="text" name="task_name" class="form-control" id="name" value="{{ old('task_name') ?: '' }}"> @if ($errors->has('task_name')) <span class="help-block">{{ $errors->first('task_name') }}</span> @endif </div> <div class="form-group"> <button type="submit" class="btn btn-info">Create Task</button> </div> <input type="hidden" name="_token" value="{{ csrf_token() }}"> </form>我的子任务形式动作是否正确?
I am working with laravel 5.2 and I am developing project management tool. in my application I have projects and each project have tasks and one task may have sub tasks. in each task I have button to create subtasks as following,
<a href="" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>when I view my tasks list witch related to each project my url is as following.
http://localhost:8000/projects/1now i have subtask form in subtasks folder of view file to enter sub tasks to each task
subtasks/subtask.blade.phpnow I need when I click sub task enter button redirect subtask blade file as url is this way.
http://localhost:8000/projects/1/task/1/subtaskhow can I manage href of sub task add button
<a href="" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>and My routes? Updated this is my subtask input form
<form class="form-vertical" role="form" method="post" action="{{ route('projects/{projectId}/task/{taskId}/subtask')}}"> <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> <input type="text" name="task_name" class="form-control" id="name" value="{{ old('task_name') ?: '' }}"> @if ($errors->has('task_name')) <span class="help-block">{{ $errors->first('task_name') }}</span> @endif </div> <div class="form-group"> <button type="submit" class="btn btn-info">Create Task</button> </div> <input type="hidden" name="_token" value="{{ csrf_token() }}"> </form>is my subtask form action correct?
最满意答案
你可以像这样创建路线
http://localhost:8000/projects/1/task/1/subtask Route::get('projects/{projectId}/task/{taskId}/subtask','HomeController@index');用于链接
<a href="{{url('projects/'.$projectId.'/task/'.$taskId.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>`所以在控制器中你可以访问
public function index($projectId,$taskId){ //you can do your query releated task }如果您尚未开发控制器并且希望通过路线传递,则更新
Route::get('projects/{projectId}/task/{taskId}/subtask', function ($projectId, $taskId) { return view('subtasks/subtask',['projectId'=>$projectId,'taskId'=>$taskId]); });You can create route like this
http://localhost:8000/projects/1/task/1/subtask Route::get('projects/{projectId}/task/{taskId}/subtask','HomeController@index');For link
<a href="{{url('projects/'.$projectId.'/task/'.$taskId.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>`so in controller you can access
public function index($projectId,$taskId){ //you can do your query releated task }Update if you have not developed controller and you wish to pass via route then
Route::get('projects/{projectId}/task/{taskId}/subtask', function ($projectId, $taskId) { return view('subtasks/subtask',['projectId'=>$projectId,'taskId'=>$taskId]); });
发布评论