Im пытается сделать систему управления контентом. Но когда я нажал кнопку, чтобы активировать/деактивировать, это дает мне ошибку NotFoundHttpException в строке RouteCollection.php 161 .. Каковы причины этой ошибки?Причины NotFoundHttpException в строке RouteCollection.php 161?
Мой взгляд
<div class="col-md-12 col-sm-6 col-xs-12">
<div class="x_panel">
<div class="x_content">
<table class="table table-hover">
<tr>
<th>
Original File Name
</th>
<th>
Change File Name
</th>
<th>
File Extension
</th>
<th>
Image
</th>
<th>
Category
</th>
<th>
Status
</th>
</tr>
@foreach($data as $file)
<tr>
<th>{{ $file->original_filename}}</th>
<th>{{ $file->rs_filename}}</th>
<th>{{ $file->file_extension}}</th>
<th><img src="/files/images/{{ $file->rs_filename }} " width ="50px" height ="50px"></th>
<th>@if($file->category=="1"){{ "Laravel" }}@endif</th>
<th>@if($file->status=="0")<a href ="/activateImage/{{$file->id}}"><button class ="btn btn-primary" >{{"Activate"}} </button></a>@else <a href ="/deactivateImage/{{$file->id}}"><button class ="btn btn-primary" > {{ "Deactivate"}}@endif</button></a></th>
</tr>
@endforeach
</table>
</div>
</div>
</div>
Мои маршруты
Route::post('/activateImage{id}', '[email protected]');
Route::post('/deactivateImage{id}', '[email protected]');
Контроллер
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Input;
use Validator;
use Redirect;
use Illuminate\Http\Request;
use Session;
use File;
use App\FileModel;
class LiveSearchLaravelController extends Controller
{
public function index()
{
$data = FileModel::all();
return view('live_search_laravel.index',compact('data'));
}
public function activateImage($id)
{
$data = FileModel::find($id)->update('status', 1);
return back();
}
public function deactivateImage($id)
{
$data = FileModel::find($id)->update('status', 1);
return back();
}
}
В вашей каждой форме добавить {{csrf_field()}} –
Я пытался поставить <типа = "скрытое" имя входного = "_ фишки "value =" {{{csrf_token()}}} "/> и теперь его работа .. Я столкнулся с ошибкой в моем контроллере. Правильно ли мой контроллер? – Angel
В вашем activImage используйте 'where' insyead of 'where'. И у вас нет метода деактивацииImage в вашем conter. –