Answer the question
In order to leave comments, you need to log in
How not to follow a route but complete it?
Good afternoon gentlemen :)
There are 4 buttons
<div class="ramka">
<h2>Управление виртуальной жизнью</h2>
</br>
<div class="ramkaleft">
</br>
<form action="/startvirtuallive" method="get">
<button type="submit" class="btn btn-success">Запустить рождаемость</button>
</form>
</br>
<form action="/startvirtuallivekiller" method="get">
<button type="submit" class="btn btn-success">Запустить смертность</button>
</form>
</div>
<div class="ramkaright">
</br>
<form action="/stopvirtuallive" method="get">
<button type="submit" class="btn btn-danger">Остановить рождаемость</button>
</form>
</br>
<form action="/stopvirtuallivekiller" method="get">
<button type="submit" class="btn btn-danger">Остановить смертность</button>
</form>
</div>
Route::get('/startvirtuallive', '[email protected]');
Route::get('/startvirtuallivekiller', '[email protected]');
Route::get('/stopvirtuallive', '[email protected]');
Route::get('/stopvirtuallivekiller', '[email protected]');
class MainController extends Controller
{
public function startvirtuallive()
{
$this->virtuallive(true);
}
public function startvirtuallivekiller()
{
$this->virtuallivekiller(true);
}
public function stopvirtuallive()
{
$this->virtuallive(false);
}
public function stopvirtuallivekiller()
{
$this->virtuallivekiller(false);
}
public function virtuallivekiller($virtual_livekiller = true)
{
if ($virtual_livekiller != false)
{
DB::table('virtuallive')
->where('id', 1)
->update(['livekiller' => 1]);
}
if ($virtual_livekiller != true)
{
DB::table('virtuallive')
->where('id', 1)
->update(['livekiller' => 0]);
}
while ($virtual_livekiller == true)
{
$live = DB::table('virtuallive')->get();
foreach($live as $animal)
{
$now = $animal->livekiller;
}
if($now == 1)
{
DB::select('CALL fixid();');
if(DB::table('zagon_all')->where('id', '=', 1)->delete() == true)
{
DB::table('zagon_dead')->insert(
['idanimal' => 1]
);
DB::select('CALL fixid();');
}
sleep(1);
}
else
{
break;
}
}
}
public function virtuallive($virtual_live = true)
{
if ($virtual_live != false)
{
DB::table('virtuallive')
->where('id', 1)
->update(['live' => 1]);
}
if ($virtual_live != true)
{
DB::table('virtuallive')
->where('id', 1)
->update(['live' => 0]);
}
while ($virtual_live == true) {
$live = DB::table('virtuallive')->get();
foreach($live as $animal)
{
$now = $animal->live;
}
if($now == 1){
DB::table('zagon_all')-> insertGetId(
[]
);
DB::select('CALL fixid();');
sleep(10);
}
else
{
break;
}
}
}
}
Answer the question
In order to leave comments, you need to log in
The fact that nothing is shown on the page is correct, you have it written that nothing should be shown. To show it, you need to do return view(...) , and in your controllers you only have a method call and that's it.
The first two methods also do not return anything, it's just that in them your code loops on while ($virtual_live == true), no new content comes to the page, and it seems that the page has been redrawn. In fact, it's just that the http request is not over yet - pay attention to the chrome twist in the tab.
You need to do return reditect(...) on the page that draws the original image.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question