Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

214
Visualizações
Data not getting inserted to db - laravel

I m try to insert data to db ! but function is working ok, it redirect to route assigned ! no error! but data is not getting added in db! I am not able to figure out ! anyhelp?

 public function addfav($webmasterId,$id)
    {
        // Check Permissions
        $data_sections_arr = explode(",", Auth::user()->permissionsGroup->data_sections);
        if (Auth::user()->id =='1') {
            return Redirect::to(route('NoPermission'))->send();
        }

        $dlt=DB::table('favads')->insertGetId([
    ['user_id' => Auth::user()->id, 'topic_id' => $id]
]);

        //
        // General for all pages
        $GeneralWebmasterSections = WebmasterSection::where('status', '=', '1')->orderby('row_no', 'asc')->get();
        // General END

        //Webmaster Topic Details
        $WebmasterSection = WebmasterSection::find($webmasterId);
        if (!empty($WebmasterSection)) {



            return redirect()->route('fav',['webmasterId'=>$webmasterId]);
        } else {
            return redirect()->route('NotFound');
        }
    }
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Why are you having two [] ? Remove one of them, I think this is the problem

Change

$dlt=DB::table('favads')->insertGetId([
  ['user_id' => Auth::user()->id, 'topic_id' => $id]
]);

To

$dlt=DB::table('favads')->insertGetId(
  ['user_id' => Auth::user()->id, 'topic_id' => $id]
);

Check with try and catch, what error are you receiving

try{
    $dlt=DB::table('favads')->insertGetId(
      ['user_id' => Auth::user()->id, 'topic_id' => $id]
    );

    dd($dlt);
}catch(\Exception $e){
  dd($e->getMessage());
}
over 4 years ago · Santiago Trujillo Relatório

0

You have to use like this

$dlt = new Favad();
$dlt->user_id =  Auth::user()->id;
$dlt->topic_id = $id;
$dlt->save();
over 4 years ago · Santiago Trujillo Relatório

0

Be sure that you are using the following code use App\Favad; in your controller.

You should insert data the following way:

$dlt = new Favad;

$dlt->user_id = Auth::user()->id;

$dlt->topic_id = $id;

$dlt->save();
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda