("""Parse error: syntax error, unexpected 'public' (T_PUBLIC)"")

Published 2 months ago by chagouani

I have this function or the user will add a 'tarificationtaches' to the 'technicien' each 'technicien' have a single 'tarificationtaches'for a selected 'tache' I wanted to make a select to check if the 'technician_id' and the 'tache_id' already exist in the pricing table stain but I have this error

("""Parse error: syntax error, unexpected 'public' (T_PUBLIC)"")

this is my controller

 <?php

 namespace App\Http\Controllers;

 use Illuminate\Http\Request;
 use App\tarificationtache;
 use App\technicien;
 use App\tache;
 use App\metier;

 class TarificationController extends Controller
{
/**
 * Display a listing of the resource.
 *
 * @return \Illuminate\Http\Response
 */

public function index() { $Listtarifications=tarificationtache::with(['techniciens.user','tache'])- >find($tarificationtache_id);

    return view('tarification.index',['tarifications'=>$Listtarifications]);

   
}


/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create($technicien_id)   
{
    $technicien = technicien::orderBy('id','desc')->get();
    $taches = Tache::orderBy('libelle_tache', 'asc')->get();
    $metiers = Metier::orderBy('libelle_metier', 'asc')->get();
    return view('tarification.create')->with('taches', $taches)->with('technicien', $technicien)- 
   >with('metiers', $metiers)->with('technicien_id', $technicien_id);
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
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();
 }

/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function show($id)
{
    //
}

/**
 * Show the form for editing the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function edit($id)
{
    $tache=Tache::find($id);
    return view('tache.edit',['libelle_tache'=>$tache],['Tarif'=>$tache],['metier_id'=>$tache]);
}

/**
 * Update the specified resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function update(Request $request, $id)
{
    //
}

/**
 * Remove the specified resource from storage.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function destroy($id)
{
    $tache =Tache::find($id);
    $tache->delete();

    return redirect('tache');
}
public function getTarificationsByTache($tache_id)
{
    $t =tache::find($tache_id);
    return response()->json(['tarifications' => $t->tarificationtache]);
}
}

tabel tarificationtaches

 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();
    });
Best Answer (As Selected By chagouani)
Anwar

Check your "store" function, at the end the last "else" statement misses an accolade ;).

PHP thinks the "store" end accolade belongs to the "else" statement, so it throws a parse error because public is not allowed in class property of method function, but PHP parser thinks you still are in a method at this moment...

Anwar

Check your "store" function, at the end the last "else" statement misses an accolade ;).

PHP thinks the "store" end accolade belongs to the "else" statement, so it throws a parse error because public is not allowed in class property of method function, but PHP parser thinks you still are in a method at this moment...

chagouani

@Anwar thank you anwer but i have change my answer if you can help me please

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