我有一个应用程序表,我试图用一个按钮删除一个应用程序。但是当我单击按钮时,什么也没有发生或没有改变。
我的刀片文件
Exception has occurred: ModuleNotFoundError
No module named 'ev3dev2'
File "C:\Users\User\Documents\implanted\tester.py", line 2, in <module>
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B,
SpeedPercent, MoveTank
from ev3dev2.sensor import INPUT_1
from ev3dev2.sensor.lego import TouchSensor
from ev3dev2.led import Leds
ts = TouchSensor()
leds = Leds()
print("Press the touch sensor to change the LED color!")
while True:
if ts.is_pressed:
leds.set_color("LEFT", "GREEN")
leds.set_color("RIGHT", "GREEN")
else:
leds.set_color("LEFT", "RED")
leds.set_color("RIGHT", "RED")
我的控制器
{!!Form::open(['action' => ['AbstractsController@deleteapplications' , $application->A_ID , $application->S_ID], 'method' => 'POST', 'class' =>'pull-right'])!!}
{{Form::hidden('_method','DELETE')}}
<td> {{Form::submit('Withdraw', ['class' => 'btn btn-danger'])}}</td>
{!!Form::close()!!}
我的路线
public function deleteapplications($A_ID, $S_ID)
{
$applications = Application::where(['S_ID' => $S_ID , 'A_ID' => $A_ID ])->get();
$application->delete();
return view('Application.show')->with('success', 'Application deleted');
}
我的HTML源代码
Route::POST('/MyApplications/{A_ID}{S_ID}', 'AbstractsController@deleteapplications');
新更新 在论坛中进行长期研究之后,我发现laravel如果不在表单中,则会忽略该表单
<form method="POST" action="http://localhost/RssPortal45/RssPortal/public/MyApplications/220145862" accept-charset="UTF-8" class="pull-right"><input name="_method" type="hidden" value="DELETE"><input name="_token" type="hidden" value="XSj0KvnNfjkjnEB0c8ZEl5xYtdF7s889OWuNvdHq">
<td> <input class="btn btn-danger" type="submit" value="Withdraw"></td>
</form>
</tr>
答案 0 :(得分:1)
尝试一下
刀片:
{!!Form::open(['route' => ['delete.applications' , $application->A_ID , $application->S_ID], 'method' => 'DELETE', 'class' =>'pull-right'])!!}
<td> {{Form::submit('Withdraw', ['class' => 'btn btn-danger'])}}</td>
{!!Form::close()!!}
路线:
Route::delete('/MyApplications/{A_ID}{S_ID}', ['uses' => 'AbstractsController@deleteapplications',
'as' => 'delete.applications']);
希望这会有所帮助:)
答案 1 :(得分:0)
尝试更改您的路线
Route::delete('/MyApplications/{A_ID}{S_ID}', 'AbstractsController@deleteapplications');
答案 2 :(得分:0)
尝试一下
public function deleteapplications($A_ID, $S_ID){
$applications = Application::where(['S_ID','=', $S_ID ],
['A_ID','=', $A_ID])->firstOrFail();
$application->delete();
return view('Application.show')->with('success', 'Application deleted');
}
答案 3 :(得分:0)
要完成一整天的调试
问题出在标签上
我从
更改了视图{!!Form::open(['action' => ['AbstractsController@deleteapplications' , $application-
>A_ID , $application->S_ID], 'method' => 'POST', 'class' =>'pull-right'])!!}
{{Form::hidden('_method','DELETE')}}
<td> {{Form::submit('Withdraw', ['class' => 'btn btn-danger'])}}</td>
{!!Form::close()!!}
到
<td>
{!!Form::open(['action' => ['AbstractsController@deleteapplications' ,
$application->A_ID , $application->S_ID], 'method' => 'POST', 'class' =>'pull-right'])!!}
{{Form::hidden('_method','DELETE')}}
{{Form::submit('Withdraw', ['class' => 'btn btn-danger'])}}
{!!Form::close()!!}
</td>
在我的路线中将POST方法更改为DELETE
还将/{A_ID}{S_ID}
更改为/{A_ID}/{S_ID}
最后一次更改是在我的控制器而不是return view
中,我使用了return redirect
,因为由于变量为空,返回视图将仅返回到带有错误的删除页面