lundi 1 juillet 2019

Can i use Helper @can in controller?

i have this code in my controller

public function index()
   {
       if(request()->ajax())
       {
           return datatables()->of(User::latest()->get())
               ->addColumn('action', function($data){
                   $button = '<a href="#" name="show" id="'.$data->id.'" class="show-modal"><i title="Visualizar" style="color: #00897b;" class="material-icons">visibility</i></a>';
                   $button .= '&nbsp;&nbsp;';
                   $button .= '<a href="#" name="edit" id="'.$data->id.'" class="edit-modal"><i title="Editar" style="color: black;" class="material-icons">edit</i></a>';
                   $button .= '&nbsp;&nbsp;';
                   $button .= '<a href="#" name="delete" id="'.$data->id.'" class="delete-modal"><i title="Excluir" style="color: red;" class="material-icons">delete</i></a>';
                   return $button;
               })
               ->rawColumns(['action'])
               ->make(true);
       }
       return view('admin.usuarios.index');
   }

Can i use helper @can in button? Like this:

$button = '@can ('isAdmin') <a href="#" name="show" id="'.$data->id.'" class="show-modal"><i title="Visualizar" style="color: #00897b;" class="material-icons">visibility</i></a> @endCan';



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire