【发布时间】:2018-10-18 12:05:51
【问题描述】:
我有一个包含 2 个组件 id 和 body 的数据库表,body 是一个文本,正如我在 laravel 数据库迁移中指定的那样:
$table->increments('id');
$table->text('body');
我用我的终端 php artisan make:controller todoController --resource 创建了一个文件控制器 todocontroller --resource 并使用以下命令,我有很多功能:它们之间有 3 个与 id 有关系:
public function show($id)
{
return $id ;
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
DB::table('todos')->where('id', '=', $id)->delete();
return view('pages.home');;
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
我想从我在 Home.blade.php 中创建的简单单击按钮中删除我喜欢的行:
<ul class="list-group">
@foreach($todos as $todo)
<li class="list-group-item d-flex justify-content-between align-items-center">
<form action="" method="">
<button type="button" class="btn btn-success" >{{$todo->id}}</button>
</form>
</li>
@endforeach
</ul>
我多次尝试使用php artisan route:list 从终端获取root,但它不起作用。
【问题讨论】:
-
查看下面的链接,如果你没有得到任何东西告诉我,我会帮助你stackoverflow.com/questions/44113969/…