John John - 3 years ago 191
PHP Question

how to get collaborators with project id in Laravel 5.2 in the localhost

I am developing project management application using Laravel 5.2. in My application side bar menus as sidebar.blade.php witch located in views\layouts\partials\sidebar.blade.php

<li><a href="#">Edit Account</a></li>
<li><a href="{{ route('projects.index') }}">Projects</a></li>
<li><a href="{{ route('collaborators.form')}}">Collaborators</a></li>
<li><a href="#">Todos</a></li>

when I click project link in the sidebar pages view existing pages. and now I need add some collaborators to each project when click collaborators link in the sidebar. my collaborators form in view/collaborators/form

<div class="col-md-4" style="border:1px solid #ccc;margin-left:15px;padding:10px;">
<h4 class="page-header">
<form class="form-vertical" role="form" method="post" action="">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label> Add New </label>
<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>

<div class="form-group">
<button type="submit" class="btn btn-info">Add User</button>
<input type="hidden" name="_token" value="{{ csrf_token() }}">

my problem is this i need consider when I am in project 10 and I click collaborator link and then I need following localhost url


My existing routes is this

Route::get('/collaborators', function(){
return view('collaborators.form');

but it is generated only localhost url as


how can I manages this?

Answer Source

Maybe I am missing something but are you trying to do this:

Route::get('/project/{project}/collaborators', function(){ 
       return view('collaborators.form'); 

And use route('collaborators.form', $project)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download