laravel : Syntax error or access violation

Published 1 month ago by chagouani

I have to insert to 'technicien'='technician' there 'tache'='task' and 'tarification' ='price'

Schema::create('tarificationtaches', function (Blueprint $table) {
        $table->increments('id');
        $table->float('tarif', 8,2);
        $table->integer('tache_id')->unsigned();
        $table->foreign('tache_id')->references('id')->on('taches');
        $table->integer('technicien_id')->unsigned();
        $table->foreign('technicien_id')->references('id')->on('techniciens');
        $table->datetime('deleted_at')->nullable();
        $table->timestamps();
    });

each techncien have to make there 'tache' then I would like to add a condition in my function to check the insertion if the 'tache' already exists if yes it displays to me existing' tache' if it does not insert in the database

 public function store(Request $request)
    {
   
    $tarification = new tarificationtache();
    $tarification ->tache_id = $request->input('tache_id');
    $tarification ->Tarif =$request->input('Tarif');
    $tarification->technicien_id = $request->input('technicien_id');
    $tarification->save();
    
    return redirect('technicien');  
}

I have tried this function but i have some error

 public function store(Request $request)
  {
   
    $tarification = new tarificationtache();
    $tarification ->tache_id = $request->input('tache_id');
    $tarification ->Tarif =$request->input('Tarif');
    $tarification->technicien_id = $request->input('technicien_id');
    $tarification = DB::select("select * FROM tarificationtaches where 
     technicien_id = 'technicien_id' and tache_id = input('tache_id')");
        if(request($tarification) > 1)
         echo "Ce technicien a cette tarification";
        else{
        
        $tarification->save();
        
 }}

errors

SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION projet2.input 
    does not exist (SQL: select * FROM tarificationtaches where \n
     technicien_id = 'technicien_id' and tache_id = input('tache_id'))
theFinalArbiter

Maybe not the answer you are looking for, but how about sticking to english in the migration and all other code, and then solve your problem with localization?

Please sign in or create an account to participate in this conversation.