Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda