i have a problem access the functions of my controller , only the Controller.index works and all the others not working not working . this is my route in web.php
Route::get('Publications/datatables', 'publicationController@datatables')->name('Publications-datatables'); Route::resource('publications', 'publicationController');
and here is my controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Publication;
use DataTables;
class publicationController extends Controller {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$publications = Publication::get();
return view('Publications.index',compact('publications'));
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create(Request $request)
{
return view('Publications.create');
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$publication = Publication::create($request->all());
return redirect()->route('Publications.show', $publication->id)->with('success', trans('og.alert.success'));
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show(Publication $publication)
{
return view('Publications.show', compact('publication'));
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit(Publication $publication)
{
return view('Publications.edit', compact('publication'));
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$data = $request->all();
$publication = Publication::find($id);
$publication->update($data);
return redirect()->route('Publications.show', $publication->id)->with('success', trans('og.alert.success'));
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id, Request $request)
{
if ($publication = Publication::find($id)) {
$wasDeleted = $publication->delete();
}
return redirect()->route('Publications.index')->with('success', trans('og.alert.success'));
}
public function datatables()
{
// $this->authorize(__FUNCTION__, new Publication); // App\Policies\PublicationPolicy
$Publications = Publication::all();
return Datatables::of($Publications)
->editColumn('id', '<a href=""></a>')
->addColumn('actions',
'<a class="btn btn-primary btn-xs" href="" data-placement="top" data-toggle="tooltip" title="'.trans('og.button.tooltip.edit').'" data-title="'.trans('og.button.tooltip.edit').'" ><span class="glyphicon glyphicon-pencil"></span></a>
<form style="display:inline" action="" method="POST"><input type="hidden" name="_token" value=""><input type="hidden" name="_method" value="DELETE" ><span data-placement="top" data-toggle="tooltip" title="'.trans('og.button.tooltip.delete').'"><button class="btn btn-danger btn-xs" type="submit" onclick="return confirm(\''.trans('og.alert.confirm_deletion').'\')" ><span class="glyphicon glyphicon-trash"></button></span></a></form>')
->rawColumns(['id', 'actions'])
->make(true);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire