gpt4 book ai didi

php - 无法在 Laravel 中显示表格数据

转载 作者:行者123 更新时间:2023-11-30 21:56:12 26 4
gpt4 key购买 nike

我需要在 View 中显示任务表,show.blade.file @tasks 文件夹中的列值“task_name”这是 TaskController

 public function store(Request $request)//, $id, Task $task)
{
$task = new Task;
$task->task_name= $request->input('name');
$task->body = $request->input('body');
$task->assign = $request->input('status');
$task->priority = $request->input('status');
$task->duedate = date("Y-m-d", strtotime($request->input("date")));// $request->input('date');
// $task->project_id = $id;
$task->save();
}

public function show($id)
{
$task = Task::find($id);
return view('tasks.show')->withTasks($task);
}
public function getTasks($id)
{
$tasks = Task::find($id)->get();
return $tasks;
}

show.blade.php

 @if(isset($tasks))
@foreach($tasks as $ta)
<h1>{{ $ta->task_name }}</h1>
@endforeach
@endif

路由.php

Route::resource('tasks','TasksController');

没有,任何错误,但任务表中不显示task_name

最佳答案

这样做

public function show($id)
{
$task = Task::find($id)->get();;
return view('tasks.show',['tasks' => $task]);
}

关于php - 无法在 Laravel 中显示表格数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45115516/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com