Create a link to a single password-free user in the database

Asked

Viewed 42 times

0

Currently I have a BD of budgets, customers and workshops. When I demand a customer I have to quote in the workshops the value and then choose the best cost x benefit and pass on to the customer.

What I want to do is generate a link to the workshop type www.meusite.com.br/orcamentos/$$$@#@@#$2352525234. This hash would be the budget ID and when entering the link it will have to type the CNPJ (this I have in the BD). So it will enter the values and conditions and record. I will receive a notification and step to the customer.

I am developing in Laravel and Vuejs. I wanted to know if this is feasible, I do not want the workshops have login system on the site.

It seemed?

Thank you guys!

1 answer

0

I will make an example based on what I understood, and using the standard models and relationships through models.

Controller in question:

public function acao1 ($id_orcamento){
    return view('view.digitar.cpf');
}

public function acao2 ($cpf,$id_orcamento){
    try{
        $usuario = UsuarioModel::where('cpf', $cpf')->firstOrFail();
        $orcamento = OrcamentoModel::find($id_orcamento);
        return view('info.orcamento', compact('orcamento'));
    } catch (ModelNotFoundException $e) {
        return view('usuario.nao.encontrado');
    }
}

You could do something like that. Of course you can structure it better there, but as I’m making an example just to give you a north, this is a good start.

You don’t necessarily need to use firstorfail inside a trycatch, you can simply use first() after a if( isset($usuario) ){...} else {...}

  • All right, Matheus, I’ve already got a North. I’m going to study what happened to me.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.