0
votes

my table proverbe

My table proverbe_jour

i have a bug with my laravel project when i try to insert a new object in a table

SQLSTATE[42703]: Undefined column: 7 ERROR: column "id" does not exist LINE 1: ... "theme") values ($1, $2, $3, $4, $5, $6, $7) returning "id" ^ (SQL: insert into "proverbe_jour" ("id_proverbe", "date", "proverbe", "signification", "ethnie", "pays", "theme") values (62, 2017-06-11 01:05:31, Couvert aux épaules mais nu aux hanches., Qui tape sur un panier couvert de suie reçoit la suie sur sa tête., Basonge, Congo, Bon sens) returning "id")

This is my controller

 <?php


namespace App\Http\Controllers;

use App\jour;
use App\Proverbe;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;


    public function rien(){

        return view('welcome');

    }

    public function jour($id){


        $proverbe = Proverbe::where('id' , '=' ,$id)->first();




        $proverbedujour  = new jour();
        $proverbedujour->id_proverbe = $id;
        $date = new \DateTime(null);
        $proverbedujour->date = $date;
        $proverbedujour->proverbe =$proverbe->proverbe;
        $proverbedujour->signification =$proverbe->signification;
        $proverbedujour->ethnie =$proverbe->ethnie;
        $proverbedujour->pays =$proverbe->pays;
        $proverbedujour->theme =$proverbe->theme;
        $proverbedujour->save();




    }

    public function listproverbe(){


        $proverbes = Proverbe::paginate(10);



        return view('listproverbe')->with('proverbes' , $proverbes);

    }



    public function valide(Request $request){
        $parameters = $request->except('_token');





        if(isset($parameters['proverbe'])  &&  isset($parameters['signification'])    &&  isset($parameters['theme']) && isset($parameters['pays'])){


            Proverbe::create($parameters);
            return redirect()->Route('home')->with('success',' proverb well added ');



        }else {

            return redirect()->Route('home')->with('error','Please complete all the fields');
        }



    }


}
3
Please include your migration file for the proverbe_jour table.user320487

3 Answers

0
votes

actually i think error is here :

$proverbe = Proverbe::where('id' , '=' ,$id)->first();

You are fetching a column(id) which doesn't exist, assuming u have id_proverbe as your primary key.

can u show me your table structure or migration file?

0
votes

Look at your migration, probably in the table proverbe_jour does not have the column id.

0
votes

It is highly recommended by Laravel to use unified attributes all along your app classes, so instead of altering between id and id_proverbe, use id for both.