troubleshooting Question

Could you clear why this Controller method isn't called as expected?

Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil asked on
13 Comments1 Solution80 ViewsLast Modified:
Hi Experts

Could you clear why this Controller method isn't called as expected?

Accordingly with a previous question this form have 02 phases

1st: Upload a picture to a defined path - In my tests by using  
use Illuminate\Support\Facades\Storage;
It's perfectly locally uploaded.

2nd  The image url and details must to be saved at the table Vitrines

So, this method is called

Vitrine.prototype.salvar = function(){
  console.log ('JS salvar');  // Pass here
    url: '/admin/vitrine/salvar',
    method: "POST",
    data: {
      _token: $('input[name="_token"]').val(),
      id: $('#id').val(),
      url: $('#url').val(),
      inicio: $('#inicio').val(),
      termino: $('#termino').val(),
      title: $('#title').val(),
      description: $('#description').val(),
      points: $('#points').val()
      hotsite.openModalCustom("Erro", data.responseText, "Entendi", "error");
    success: function(data){
      hotsite.openModalCustom("Sucesso ao salvar", data.retorno, "Entendi", "success");

This method is configured at routes


But it doesn't seen it's called at VitrineController

 public function salvar(Request $request){
       info('Em salvar');

       //----------It must to stop here if it's called. But not.


        $titulo = $request->input('title');
        $descricao = $request->input('description');
        $pontuacao = $request->input('points');
            if($id != '' &&  $id > 0){
              $vitrine = Vitrine::find($id);
              $vitrine = new Vitrine();
              $vitrine->created_at=new \DateTime();
            $vitrine->title = $titulo;
            $vitrine->description = $descricao;
            $vitrine->points = CustomFuncs::brancoParaNulo($pontuacao);
            $vitrine->url = $url;
            $vitrine->validity_start = empty($inicio) ? null : CustomFuncs::formatarDataUS($inicio);
            $vitrine->validity_end = empty($inicio) ? null : CustomFuncs::formatarDataUS($termino);
            $vitrine->updated_at=new \DateTime();
        } catch (\Exception $e) {
            return response()->json(new Resultado(true,'','Erro ao salvar o vídeo'), 400);
        return response()->json(new Resultado(false,'','Vídeo cadastrado com sucesso'));

And a success message is presented by the above JS code:

But nothing is saved at table Vitrines.

Could you check?

Thanks in advance
Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros