Your first route example should work fine!!
You only return a view in your route callback. So my only question would be: Did you create the view and fill it with something?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I need routes this
Route::get('/projects/{id}/gantt', function () {
return view('projects.gantt');
});
Route::match(['get', 'post'], '/gantt_data', "GanttController@data");
My routes url is this
http://localhost:8000/projects/1/gantt
and routes link is this
<p><a href="/projects/{{ $project->id }}/gantt">Gantt</a></p>
but when I routes this gantt.php it is not display My gantt page only dispaly empty page. No erros
but when I routes this way
Route::get('/gantt', function () {
return view('projects.gantt');
});
Route::match(['get', 'post'], '/gantt_data', "GanttController@data");
with this link
<p><a href="/gantt">Gantt</a></p>
it is working!!! but I need first routes and link show My gantt relate to project id can you give me a solution My GanttControlle.php
<?php
namespace App\Http\Controllers;
use App\GanttTask;
use App\GanttLink;
use Dhtmlx\Connector\GanttConnector;
class GanttController extends Controller
{
public function data() {
$connector = new GanttConnector(null, "PHPLaravel");
$connector->render_links(new GanttLink(), "id", "source,target,type");
$connector->render_table(new GanttTask(),"id","start_date,duration,text,progress,parent,project_id");
}
}
ProjectController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use App\Task;
use App\Project;
use App\File;
use App\Comment;
use App\Collaboration;
use App\GanttTask;
use App\GanttLink;
use App\Http\Requests;
class ProjectController extends Controller
{
public function index()
{
$projects = Project::personal()->get();
return view('projects.index')->withProject($projects);
}
public function create()
{
return view('projects.new');
}
public function store(Request $request)
{
$this->validate($request, [
'name' => 'required|min:3',
'due-date' => 'required|date|after:today',
'notes' => 'required|min:10',
'status' => 'required'
]);
$project = new Project;
$project->project_name = $request->input('name');
$project->project_status = $request->input('status');
$project->due_date = $request->input('due-date');
$project->project_notes = $request->input('notes');
$project->user_id = Auth::user()->id;
$project->save();
return redirect()->route('projects.index')->with('info','Your Project has been created successfully');
}
public function show($id)
{
$project = Project::find($id);
$tasks = $this->getTasks($id);
$files = $this->getFiles($id);
$comments = $this->getComments($id);
$collaborators = $this->getCollaborators($id);
return view('projects.show')->withProject($project)->withTasks($tasks)->withFiles($files)->withComments($comments)->withCollaborators($collaborators);
}
public function edit($id)
{
$project = Project::find($id);
$tasks = $this->getTasks($id);
return view('projects.edit')->withProject($project)->withTasks($tasks);
}
/*
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$project = Project::findOrFail($id);
$this->validate($request, [
'project_name' => 'required|min:3',
'due-date' => 'required|date|after:today',
'project_notes' => 'required|min:10',
'project_status' => 'required'
]);
$values = $request->all();
$project->fill($values)->save();
return redirect()->back()->with('info','Your Project has been updated successfully');
}
public function destroy($id)
{
$project = Project::findOrFail($id);
$project->delete();
return redirect()->route('projects.index')->with('info', 'Project deleted successfully');
}
/*
* Get all the tasks for a Project
* @param [type] $id [description]
* @return [type] [description]
*/
public function getTasks($id)
{
$tasks = Task::project($id)->get();
return $tasks;
}
public function getFiles($id)
{
$files = File::project($id)->get();
return $files;
}
/*
* Get all the comments that were made on a Project
* @param integer $id
* @return collection
*/
public function getComments($id)
{
$comments = Comment::project($id)->get();
return $comments;
}
/*
* Get all the collaborators on this project
* @param int $id
* @return collection
*/
public function getCollaborators($id)
{
$collaborators = Collaboration::project($id)->get();
return $collaborators;
}
//
}
Please or to participate in this conversation.