chagouani

Experience

4,260

0 Best Reply Awards

  • Member Since 5 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

17th August, 2018

chagouani left a reply on Laravel : Check Before Insertion • 2 days ago

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'))

chagouani started a new conversation Laravel : Check Before Insertion • 2 days ago

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');  
}

27th July, 2018

chagouani left a reply on How To Convert This Store Function To Json • 3 weeks ago

@lostdreamer_nl can you helping me to solved please

chagouani left a reply on How To Convert This Store Function To Json • 3 weeks ago

@lostdreamer_nl

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: in file C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php on line 255 Stack trace:

  1. Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException->() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php:255
  2. Illuminate\Routing\RouteCollection->methodNotAllowed() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php:242
  3. Illuminate\Routing\RouteCollection->getRouteForMethods() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php:176
  4. Illuminate\Routing\RouteCollection->match() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Router.php:612
  5. Illuminate\Routing\Router->findRoute() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Router.php:601
  6. Illuminate\Routing\Router->dispatchToRoute() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Router.php:590
  7. Illuminate\Routing\Router->dispatch() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:176
  8. Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:30
  9. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\xampp\htdocs\projet\vendor\fideloper\proxy\src\TrustProxies.php:56
  10. Fideloper\Proxy\TrustProxies->handle() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:149
  11. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  12. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:30
  13. Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:149
  14. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  15. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:30
  16. Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:149
  17. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  18. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php:27
  19. Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:149
  20. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  21. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php:46
  22. Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:149
  23. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  24. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:102
  25. Illuminate\Pipeline\Pipeline->then() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:151
  26. Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:116
  27. Illuminate\Foundation\Http\Kernel->handle() C:\xampp\htdocs\projet\public\index.php:55

chagouani left a reply on How To Convert This Store Function To Json • 3 weeks ago

@lostdreamer_nl this is my table migration

 public function up()
{
    Schema::create('avis_interventions', function (Blueprint $table) {
        $table->increments('id');
        $table->string('qualité');
        $table->integer('nbr_heure');
        $table->string('service');
        $table->float('note', 1,1);
        $table->integer('client_id')->unsigned();
        $table->foreign('client_id')->references('id')->on('clients');
        $table->integer('intervention_id')->unsigned();
        $table->foreign('intervention_id')->references('id')->on('interventions');
        $table->timestamps();
    });
}

chagouani left a reply on How To Convert This Store Function To Json • 3 weeks ago

@cmdobueno when i have make your code i have this error :

Could not get any response
There was an error connecting to http://192.168.1.233/projet/public/api/avs.
Why this might have happened:
The server couldn't send a response:
Ensure that the backend is working properly
Self-signed SSL certificates are being blocked:
Fix this by turning off 'SSL certificate verification' in Settings > General
Proxy configured incorrectly
Ensure that proxy is configured correctly in Settings > Proxy
Request timeout:
Change request timeout in Settings > General

26th July, 2018

chagouani left a reply on How To Convert This Store Function To Json • 3 weeks ago

@lostdreamer_nl sorry i have problém whith my application so i have solved now and i have make you function i have this error

Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint 
    violation

23rd July, 2018

chagouani started a new conversation Show The Result Of Relative Selects Box On Table • 3 weeks ago

1/ I have 2 relative select box I must choose a "metier" well a relative " tache" well I would like to display the list of the "technicien" who had the spot selected in a table

2/ when I had the table I must choose a "technicien" in the table to record his "id" on "intervention table"

I have not found any solution for a long time

create.blade.php

    @extends('Layouts/app')

@extends('Layouts/master')

@section('content')
<!--  jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" 
 rel="stylesheet">

<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap- 
 datepicker.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap- 
datepicker.js"></script>


    <script type="text/javascript">

    
    var getTachesByMetierUrl = "{{url('/tachesbymetier')}}";
    var getAdresseByClientUrl = "{{url('/adressebyclient')}}";
    var getTarificationsByTacheUrl = "{{url('/tarificationsbytache')}}";
    var getTechniciensByTarificationtacheUrl = "{{url('/techniciensbytarificationtache')}}";
    //console.log(getMetiersByTechnicienUrl, 
    getTachesByMetierUrl,getTarificationsByTacheUrl);
    

    function getAdresseByClient(val) {
        if(val.length>0) {
            var client_id = val;
            $.get(getAdresseByClientUrl+'/'+client_id,function(res) {
                var html = '<option value="">-Select-</option>' ;
                $.each(res.adresses,function(index,item) {
                    html+='<option value="'+item.id+'">'+item.code_postal+'</option>';
                });
                $('#adresses').html(html);

            });
        }
    }


    function getTachesByMetier(val) {
        if(val.length>0) {
            var metier_id = val;
            $.get(getTachesByMetierUrl+'/'+metier_id,function(res) {
                var html = '<option value="">-Select-</option>' ;
                $.each(res.taches,function(index,item) {
                    html+='<option value="'+item.id+'">'+item.libelle_tache+'</option>';
                });
                $('#taches').html(html);

            });
        }
    }

     function getTechniciensByTache(val) {
        if(val.length>0) {
            var tache_id = val;
            $.get(getTechniciensByTacheUrl+'/'+tarificationtache_id,function(res) {
                var html = '<option value="">-Select-</option>' ;
                $.each(res.techniciens,function(index,item) {
                    html+='<option value="'+item.id+'">'+item.nom+'</option>';
                });
                $('#techniciens').html(html);

            });
        }
    }



    function getTarificationsByTache(val) {

        if(val.length>0) {
            var tache_id = val;
            $.get(getTarificationsByTacheUrl+'/'+tache_id,function(res) {
                var html = '<option value="">-Select-</option>' ;
                $.each(res.tarifications,function(index,item) {
                    html+='<option value="'+item.id+'">'+item.tarif+'</option>';
                });
                $('#tarifications').html(html);

            });
        }
    }

   
    function rowSelect(currentRow){
        //this is the code to set a dropdown menu using jquery
        var technicien_id = selectedRow.children[0].innerHTML;
        $("#your_technicien_dropdown_menu_id").val(technicien_id);
    }




</script>



@if(count($errors))
    <div class="alert alert-danger" role="alert">
        <ul>
            @foreach($errors ->all() as $message)
                <li>{{$message}}</li>
            @endforeach
        </ul>
    </div>
 @endif
 <div class="container">
    <div class="row"></div>
    <div class="col-md-10">
        <h1>Ajout Intervention</h1>
        <form action=" {{url ('intervention')  }}" method="post">
            {{csrf_field()}}
            <div class="form-group">
                <label for="client">Client</label>
                <select onchange="getAdresseByClient(this.value)" name="client_id" id="client" 
  class="form-control">
                    <option value="">-Select-</option>
                    @foreach($client as $t)
                        <option value="{{$t->id }}">
                            {{$t->user->nom}}
                        </option>
                    @endforeach
                </select>
            </div>


            <div class="form-group">
                <label for="">date et heure </label>
                <input class="form-control" type="datetime-local"  name ="duree_prevu" value=" 
  {{old('duree_prevu')}}">
            </div>

            <div class="form-group">
                <label for="">description</label>
                <input type="text"  name ="description" class="form-control"value=" 
  {{old('description')}}">
            </div>

    <div class="form-group">
                <div class="col-md-12">
                <div class="col-md-4">
                <label>Metier: </label>
                <select onchange="getTachesByMetier(this.value)" style="width: 200px" 
  class="productm form-control" id="metiers">
               <option value="">-Select-</option>
                    @foreach($metiers as $t)
                        <option value="{{$t->id }}">
                            {{$t->libelle_metier}}
                        </option>
                    @endforeach
                </select>
            </div>

            <div class="col-md-4">
                <label>tache: </label>
                <select onchange="getTarificationsByTache(this.value)" style="width: 200px" 
  class="productname form-control" name="tache" id="taches">
                 <option value="">-Select-</option>
                </select>
            </div>

            <table class="table table-bordered bg-light">
        <thead class="bg-dark" style=" color: white">
                <tr>
                     <th class="light-table-filter" data-table="order-table" placeholder="Filter" style=" 
 color: #337ab7">technicien </th>
                     <th class="light-table-filter" data-table="order-table" placeholder="Filter" style=" 
 color: #337ab7">Tache </th>
                    <th class="light-table-filter" data-table="order-table" placeholder="Filter" style=" 
 color: #337ab7">tarif </th>
                    
                   
                    <th style="color: #337ab7" width="220px" style="vertical-align: 
   middle">Action</th>
                    
                </tr>
                </thead>
                <tbody>
                @foreach($tarifications as $tarifications)
                <tr>
                    <td>{{$tarifications->technicien->user->nom}}</td>
                    <td>{{$tarifications->tache->libelle_tache}}</td>
                    <td>{{$tarifications->tarif}}</td>
                    
                    <td>
                        <div class="form-group">
                            <div class="form-group">
                            
                            <input type="checkbox"  name ="tarifications" value="id">
                        </div>
                    </td>
                </tr>
                @endforeach
                </body>
            </table>
 </div>
            <div class="form-group">
                <div class="form-group">
                <label for="">statut    :   </label>
                <input type="checkbox"  name ="statut" value="1" required autofocus>
            </div>
            <div class="form-group">
                <label for="">payement</label>
                <input type="checkbox"  name ="payement" value="">
            </div>
            <div class="form-group">

                <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
            </div>
  </div>
  </div>
   </div>
  <script>
     function getMessage(){
         $.ajax({
                  type:'GET',
                  url:your_url,
                  dataType: 'json',
                  success:function(tarifications_list){
                    $table_body = $("#tbl_body_name");
                    $table_body.empty();

                    if (tarifications_list.length > 0) {
                        div_no_data.style.display = 'none';
                        $.each(tarifications_list, function (index, value) {
                            $table_body.append('<tr class="deselected" onclick="rowSelect(this)">' +
                                '<td style="text-align: left;">' + value.technicien_id  + '</td>' +
                                '<td style="text-align: left;">' + value.tache_id + '</td>' +
                                '</tr>');
                        });
                    }
                  }
                });
     }
  </script>
 @endsection

controller

 public function create()

{

    $client = client::orderBy('id', 'asc')->get();
    $metiers = metier::orderBy('id', 'asc')->get();
    $technicien = Technicien::orderBy('id', 'desc')->get();
    $tarifications=tarificationtache::with(['technicien','tache'])->get(); 
    
    return view('intervention.create')->with('technicien', $technicien)->with('client',$client)- 
    >with('metiers',$metiers)->with('tarifications',$tarifications);
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(InterventionRequest $request)
{
    $intervention = new Intervention();
    
    $intervention ->description =$request->input('description');
    $intervention ->duree_prevu =$request->input('duree_prevu');
    

    if($request->has('statut')){
    $intervention->statut = $request->input('statut');
    }else{
           $intervention->statut = 0;
    }
    
    $intervention ->technicien_id = $request->input('technicien_id');
    $intervention ->client_id = $request->input('client_id');
    $intervention ->tarification_id = $request->tarificationtache_id;
    $intervention->save();
    return redirect('intervention');




}

20th July, 2018

chagouani started a new conversation Slect Box Shown Table With Ajax • 4 weeks ago

I have to make à view with 2 relative select box wen i choise the secend a table is displayed and in its table I can choose a line for inserting data can some redirects me to the solution and if I can see an example

I have more than months I seek the solution and I have not managed to find it ,

and this is my question , can some one help me please

18th July, 2018

chagouani started a new conversation How To Convert This Store Function To Json • 1 month ago

Strore function

public function store(Request $request)
    {

    $avis = new AvisIntervention();
    $avis ->qualité =$request->input('qualité');
    $avis ->nbr_heure =$request->input('nbr_heure');
    $avis ->service =$request->input('service');
    $avis ->note =$request->input('note');
    $avis ->client_id =$request->input('client_id');
    $avis ->intervention_id = $request->input('intervention_id');
    $avis->save();
    return redirect('avis');

  }

6th July, 2018

chagouani left a reply on Syntax Error Or Access Violation: 1305 FUNCTION Projet2.input Does Not Exist • 1 month ago

@tomopongrac thanks for your answer when i have try your answer i have this 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'))

chagouani started a new conversation Syntax Error Or Access Violation: 1305 FUNCTION Projet2.input Does Not Exist • 1 month ago

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

("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'))”)

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();
    });

chagouani left a reply on Syntax Error Or Access Violation: 1305 FUNCTION Projet2.input Does Not Exist • 1 month ago

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

chagouani started a new conversation “Parse Error: Syntax Error, Unexpected 'public' (T_PUBLIC)” • 1 month ago

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();
    });

26th June, 2018

chagouani left a reply on Column Not Found: 1054 Unknown Column • 1 month ago

@tomopongrac i have change on my model like this but

 return $this->hasMany(intervention::class, 'tarification_id');

but now i have this error

"Property [intervention] does not exist on this collection instance."

chagouani started a new conversation Column Not Found: 1054 Unknown Column • 1 month ago

I have a function that displays the 'tarificationtaches' whith the avg of moyenne_avis from table avis intervention related to intervention i have this error

"SQLSTATE[42S22]: Column not found: 1054 Unknown column      
    'interventions.tarificationtache_id' in 'where clause' (SQL: select * from `interventions` 
where `interventions`.`tarificationtache_id` in (1, 2, 3, 4))

tarificationtaches_tables

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();
    });

techniciens_tables

 Schema::create('techniciens', function (Blueprint $table) {
        $table->increments('id');
        $table->boolean('actif')->default(1);
        $table->float('moyenne_avis')->nullable();
        $table->integer('user_id')->unsigned();
        $table->foreign('user_id')->references('id')->on('users');
        $table->datetime('deleted_at')->nullable();
        $table->timestamps();
        
    });

avis_interventions_tables

Schema::create('avis_interventions', function (Blueprint $table) {
        $table->increments('id');
        $table->string('qualité');
        $table->integer('nbr_heure');
        $table->string('service');
        $table->float('note', 1,1);
        $table->integer('client_id')->unsigned();
        $table->foreign('client_id')->references('id')->on('clients');
        $table->integer('intervention_id')->unsigned();
        $table->foreign('intervention_id')->references('id')- 
        >on('interventions');
        $table->timestamps();
    });

interventions_tables

 Schema::create('interventions', function (Blueprint $table) {
        $table->increments('id');
        $table->date('date_intervention')->nullable();
        $table->string('description');
        $table->dateTime('duree_prevu');
        $table->boolean('statut');
        $table->integer('technicien_id')->unsigned();
        $table->foreign('technicien_id')->references('id')- 
        >on('techniciens');
        $table->integer('tarification_id')->unsigned();
        $table->foreign('tarification_id')->references('id')- 
        >on('tarificationtaches');
        $table->integer('client_id')->unsigned();
        $table->foreign('client_id')->references('id')->on('Clients');


        $table->timestamps();
    });

this is my function

 public function getTar(){
     $tarifications = tarificationtache::with('technicien','intervention')->get();
        $notes = $tarifications->intervention->avisinterventions->pluck('note');
        $moyenne = $tarifications->intervention()->avisinterventions()->avg('note');
        return $tarifications->map(function ($tarification) {
            return [
                'nom' => $tarification->technicien->user->nom,
                'moyenne_avis' => $tarification->intervention->avisinterventions->avg('note'),
                'tache' => $tarification->tache->libelle_tache,
                'tarif' => $tarification->tarif,
            ];
        });    


   
}

chagouani started a new conversation Json • 1 month ago

I have a function that displays the 'tarificationtaches' list i would like to add an avg to get the average 'techniciens' moyenne_avis from tables avis_intervention where "intervention.technicien_id" = "tarificationtaches.techncien_id" , in this is my schema .

tarificationtaches_tables

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();
    });

techniciens_tables

 Schema::create('techniciens', function (Blueprint $table) {
        $table->increments('id');
        $table->boolean('actif')->default(1);
        $table->float('moyenne_avis')->nullable();
        $table->integer('user_id')->unsigned();
        $table->foreign('user_id')->references('id')->on('users');
        $table->datetime('deleted_at')->nullable();
        $table->timestamps();
        
    });

avis_interventions_tables

Schema::create('avis_interventions', function (Blueprint $table) {
        $table->increments('id');
        $table->string('qualité');
        $table->integer('nbr_heure');
        $table->string('service');
        $table->float('note', 1,1);
        $table->integer('client_id')->unsigned();
        $table->foreign('client_id')->references('id')->on('clients');
        $table->integer('intervention_id')->unsigned();
        $table->foreign('intervention_id')->references('id')->on('interventions');
        $table->timestamps();
    });

interventions_tables

 Schema::create('interventions', function (Blueprint $table) {
        $table->increments('id');
        $table->date('date_intervention')->nullable();
        $table->string('description');
        $table->dateTime('duree_prevu');
        $table->boolean('statut');
        $table->integer('technicien_id')->unsigned();
        $table->foreign('technicien_id')->references('id')->on('techniciens');
        $table->integer('tarification_id')->unsigned();
        $table->foreign('tarification_id')->references('id')->on('tarificationtaches');
        $table->integer('client_id')->unsigned();
        $table->foreign('client_id')->references('id')->on('Clients');


        $table->timestamps();
    });

this is my function

public function getTar(){
     $tarifications = tarificationtache::with('technicien')->get();

        return $tarifications->map(function ($tarification) {
            return [
                'nom' => $tarification->technicien->user->nom,
                'moyenne_avis' => $tarification->technicien->moyenne_avis,
                'tache' => $tarification->tache->libelle_tache,
                'tarif' => $tarification->tarif,
            ];
        });    


   
}

it shown like this

[{"nom":"tech 1","moyenne_avis":null,"tache":"tache 2","tarif":29.55},{"nom":"tech   
    2","moyenne_avis":null,"tache":"tache 3","tarif":55.12},{"nom":"tech 
    1","moyenne_avis":null,"tache":"tache 3","tarif":253},{"nom":"tech 
    2","moyenne_avis":null,"tache":"tache 3","tarif":28.22}]

NB: the moyenne_avis is null because he display moyenne_avis from technicien and i dont have any insert on .

25th June, 2018

chagouani started a new conversation How To Check An Existing 'tarificationtache' • 1 month ago

I have an interface of 'tarificationtache' in this interface the 'technicien' can have pricing for its 'taches' and for each 'tache' a single 'tarif', I would like to check if this 'tache' it has a 'tarif' for this 'technicien' if yes it retur a message 'tarifi exist' if it creates it .

table 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();
    });

create.blade.php

@extends('Layouts/app')
@extends('Layouts.master')
@section('content')
 @if(count($errors))
    <div class="alert alert-danger" role="alert">
    <ul>
    @foreach($errors ->all() as $message)
     <li>{{$message}}</li>
        @endforeach
    </ul>
    </div>
 @endif
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script type="text/javascript">
    var getMetiersByTechnicienUrl = "{{url('/metiersbytechnicien')}}";
    var getTachesByMetierUrl = "{{url('/tachesbymetier')}}";
    //console.log(getMetiersByTechnicienUrl,getTachesByMetierUrl, 
     getTarificationsByTacheUrl);
    function getMetiersByTechnicien(val) {
        if(val.length>0) {
            var technicien_id = val;
            $.get(getMetiersByTechnicienUrl+'/'+technicien_id,function(res) {
                var html = '<option value=">-Select-"</option>' ;
                $.each(res.metiers,function(index,item) {
                    html+='<option value="'+item.id+'">'+item.libelle_metier+'</option>';
                });
                $('#metiers').html(html);

            });
        }
    }

   


    function getTachesByMetier(val) {
        if(val.length>0) {
            var metier_id = val;
            $.get(getTachesByMetierUrl+'/'+metier_id,function(res) {
                var html = '<option value="">-Select-</option>' ;
                $.each(res.taches,function(index,item) {
                    html+='<option value="'+item.id+'">'+item.libelle_tache+'</option>';
                });
                $('#taches').html(html);

            });
        }
    }
    </script>

<div class="container">
    <div class="row"></div>
    <div class="col-md-12">
       
       <div class="col-md-10">
            <h1>Tarification tache</h1>
        <form action=" {{url ('tarification')  }}" method="post">
         {{csrf_field()}}

        <div class="form-group">
            <label for="technicien">Technicien</label>
               <select onchange="getMetiersByTechnicien(this.value)" name="technicien_id" 
                  id="technicien_id" class="form-control">
                       <option value="">-Select-</option>
                       @foreach($technicien as $t)
                              <option value="{{$t->id }}" {{ $t->id == $technicien_id ? 'selected = "selected"' 
                              : '' }}>
                                    {{$t->user->nom}}
                              </option>
                       @endforeach
                </select>
        </div>
        <div class="form-group">
            <div class="col-md-12">
                    <div class="col-md-4">
<label>Metier: </label>
<select onchange="getTachesByMetier(this.value)" style="width: 
200px" class="productm form-control" id="metiers">
    <option value="">-Select-</option>
@foreach($metiers as $metier)
      <option value={{$metier->id}}>{{$metier->libelle_metier}}</option>
@endforeach

tache: -Select- tarification:

    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap- 
    datepicker.css" rel="stylesheet">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap- 
    datepicker.js"></script>
   @endsection

controller

 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->save();
    
    return redirect('technicien');  }

chagouani started a new conversation Laravel Query Join As Json • 1 month ago

I'm trying to build one service json Laravel. I want to show liste of tarificationtaches groupe by tache .

table techniciens

    Schema::create('techniciens', function (Blueprint $table) {
        $table->increments('id');
        $table->boolean('actif')->default(1);
        $table->float('moyenne_avis')->nullable();
        $table->integer('user_id')->unsigned();
        $table->foreign('user_id')->references('id')->on('users');
        $table->datetime('deleted_at')->nullable();
        $table->timestamps();
        
    });

table users

    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('email');
        $table->string('password');
        $table->string('nom');
        $table->string('prenom');
        $table->string('tel');
        $table->string('mobil');
        $table->boolean('role')->default(0);
        $table->datetime('deleted_at')->nullable();
        $table->rememberToken();
        $table->timestamps();
    });

table 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();
    });

function

public function getTar($id){
$taches=  Tache::with("tarificationtache")->get();
return response(compact('taches'));
}

i have this function it shown like this

{"taches":[{"id":1,"libelle_tache":"montage  porte   
 simple","Tarif":null,"metier_id":1,"deleted_at":null,"created_at":"2018-06- 
 08 11:41:41","updated_at":"2018-06-08 11:41:41","tarificationtache":[]}, 
 {"id":2,"libelle_tache":"tache 
 1","Tarif":null,"metier_id":1,"deleted_at":null,"created_at":"2018-06-08 
 11:41:55","updated_at":"2018-06-08 11:41:55","tarificationtache":[]}, 
 {"id":3,"libelle_tache":"tache 
 2","Tarif":null,"metier_id":2,"deleted_at":null,"created_at":"2018-06-08 
 11:42:01","updated_at":"2018-06-08 11:42:01","tarificationtache": 
 [{"id":1,"tarif":29.55,"tache_id":3,"technicien_id":1,"deleted_at":null, 
 "created_at":"2018-06-08 11:58:54","updated_at":"2018-06-08 11:58:54"}]}, 
 {"id":4,"libelle_tache":"tache 
 3","Tarif":null,"metier_id":3,"deleted_at":null,"created_at":"2018-06-08 
 12:00:15","updated_at":"2018-06-08 12:00:15","tarificationtache": 
 [{"id":2,"tarif":55.12,"tache_id":4,"technicien_id":2,"deleted_at":null 
 ,"created_at":"2018-06-08 12:00:37","updated_at":"2018-06-08 12:00:37"}, 
 {"id":3,"tarif":253,"tache_id":4,"technicien_id":1,"deleted_at":null 
 ,"created_at":"2018-06-15 23:17:23","updated_at":"2018-06-15 23:17:23"}, 
 {"id":4,"tarif":28.22,"tache_id":4,"technicien_id":2,"deleted_at":null 
 ,"created_at":"2018-06-20 17:03:32","updated_at":"2018-06-20 17:03:32"}]}]}

but i would like to have the 'nom' of technicien not the 'technicien_id'

id: N,
tache_id: "tache",
technicien_id: 5
     nom: "user.nom",
     

22nd June, 2018

chagouani left a reply on Json • 1 month ago

@biishmar when i make return $taches; he shown me like this

[{"id":1,"libelle_tache":"montage  porte 
    simple","Tarif":null,"metier_id":1,"deleted_at":null,"created_at":"2018-06-08 
    11:41:41","updated_at":"2018-06-08 11:41:41","tarificationtache":[]}, 
     {"id":2,"libelle_tache":"tache 
    1","Tarif":null,"metier_id":1,"deleted_at":null,"created_at":"2018-06-08 
    11:41:55","updated_at":"2018-06-08 11:41:55","tarificationtache":[]}, 
    {"id":3,"libelle_tache":"tache 
    2","Tarif":null,"metier_id":2,"deleted_at":null,"created_at":"2018-06-08 
    11:42:01","updated_at":"2018-06-08 11:42:01","tarificationtache": 
    [{"id":1,"tarif":29.55,"tache_id":3,"technicien_id":1,"deleted_at":null,"created_at":"2018- 
    06-08 11:58:54","updated_at":"2018-06-08 11:58:54"}]},{"id":4,"libelle_tache":"tache 
    3","Tarif":null,"metier_id":3,"deleted_at":null,"created_at":"2018-06-08 
   12:00:15","updated_at":"2018-06-08 12:00:15","tarificationtache": 
    [{"id":2,"tarif":55.12,"tache_id":4,"technicien_id":2,"deleted_at":null,"created_at":"2018- 
   06-08 12:00:37","updated_at":"2018-06-08 12:00:37"}, 
   {"id":3,"tarif":253,"tache_id":4,"technicien_id":1,"deleted_at":null,"created_at":"2018-06- 
    15 23:17:23","updated_at":"2018-06-15 23:17:23"}, 
    {"id":4,"tarif":28.22,"tache_id":4,"technicien_id":2,"deleted_at":null,"created_at":"2018- 
    06-20 17:03:32","updated_at":"2018-06-20 17:03:32"}]}]

but me i would like to shown the "nom" of "techniciens" from table "users" not the technicien_id from tarification

chagouani started a new conversation Json • 1 month ago

I have 3 table

techniciens(id, user_id,actif , moyenne_avis) 
users (nom , prenom , adresse )
tarificationtaches (id , tarif , technicien_id,tache_id , tarif) 

I have a function to display the 'tarificationtache' list with the 'id' of technicien but i would to shown his 'nom' and 'moyenne_avis' group by (tache_id)

this is my service :

 public function getTar($id){

$taches=  Tache::with("tarificationtache")->get();
return response(compact('taches'));
}

he shown like this :

{"taches":[{"id":1,"libelle_tache":"montage  porte   
  simple","Tarif":null,"metier_id":1,"deleted_at":null,"created_at":"2018-06-08 
  11:41:41","updated_at":"2018-06-08 11:41:41","tarificationtache":[]},{"id":2,"libelle_tache":"tache 
  1","Tarif":null,"metier_id":1,"deleted_at":null,"created_at":"2018-06-08 
  11:41:55","updated_at":"2018-06-08 11:41:55","tarificationtache":[]},{"id":3,"libelle_tache":"tache 
  2","Tarif":null,"metier_id":2,"deleted_at":null,"created_at":"2018-06-08 
  11:42:01","updated_at":"2018-06-08 11:42:01","tarificationtache": 
  [{"id":1,"tarif":29.55,"tache_id":3,"technicien_id":1,"deleted_at":null,"created_at":"2018-06-08 
 11:58:54","updated_at":"2018-06-08 11:58:54"}]},{"id":4,"libelle_tache":"tache 
 3","Tarif":null,"metier_id":3,"deleted_at":null,"created_at":"2018-06-08 
 12:00:15","updated_at":"2018-06-08 12:00:15","tarificationtache": 
[{"id":2,"tarif":55.12,"tache_id":4,"technicien_id":2,"deleted_at":null,"created_at":"2018-06-08 
12:00:37","updated_at":"2018-06-08 12:00:37"}, 
{"id":3,"tarif":253,"tache_id":4,"technicien_id":1,"deleted_at":null,"created_at":"2018-06-15 
23:17:23","updated_at":"2018-06-15 23:17:23"}, 
{"id":4,"tarif":28.22,"tache_id":4,"technicien_id":2,"deleted_at":null,"created_at":"2018-06-20 
17:03:32","updated_at":"2018-06-20 17:03:32"}]}]}

21st June, 2018

chagouani started a new conversation Json Function To Shown Name And Avg Note • 1 month ago

I have 5 table

techniciens(id, user_id,actif) 
users (nom , prenom , adresse )
tarificationtaches (id , tarif , technicien_id,tache_id , tarif) 
intervention(id , tarification_id , technicien_id....)
avis_interventions( id , intervention_id , note )

I have a web service function to display the 'tarificationtache' list with the id of technicien but i would to shown his name and the avg of 'avis_interventions'

this is my service :

 public function getTar($id){

$taches=  Tache::with("tarificationtache")->get();
return response(compact('taches'));
}

he shown like this :

{"taches":[{"id":1,"libelle_tache":"montage  porte   
  simple","Tarif":null,"metier_id":1,"deleted_at":null,"created_at":"2018-06-08 
  11:41:41","updated_at":"2018-06-08 11:41:41","tarificationtache":[]},{"id":2,"libelle_tache":"tache 
  1","Tarif":null,"metier_id":1,"deleted_at":null,"created_at":"2018-06-08 
  11:41:55","updated_at":"2018-06-08 11:41:55","tarificationtache":[]},{"id":3,"libelle_tache":"tache 
  2","Tarif":null,"metier_id":2,"deleted_at":null,"created_at":"2018-06-08 
  11:42:01","updated_at":"2018-06-08 11:42:01","tarificationtache": 
  [{"id":1,"tarif":29.55,"tache_id":3,"technicien_id":1,"deleted_at":null,"created_at":"2018-06-08 
 11:58:54","updated_at":"2018-06-08 11:58:54"}]},{"id":4,"libelle_tache":"tache 
 3","Tarif":null,"metier_id":3,"deleted_at":null,"created_at":"2018-06-08 
 12:00:15","updated_at":"2018-06-08 12:00:15","tarificationtache": 
[{"id":2,"tarif":55.12,"tache_id":4,"technicien_id":2,"deleted_at":null,"created_at":"2018-06-08 
12:00:37","updated_at":"2018-06-08 12:00:37"}, 
{"id":3,"tarif":253,"tache_id":4,"technicien_id":1,"deleted_at":null,"created_at":"2018-06-15 
23:17:23","updated_at":"2018-06-15 23:17:23"}, 
{"id":4,"tarif":28.22,"tache_id":4,"technicien_id":2,"deleted_at":null,"created_at":"2018-06-20 
17:03:32","updated_at":"2018-06-20 17:03:32"}]}]}

saying that the average rating i perform in laravel with this functin

 public function show($id)
{
    $technicien = technicien::findOrFail($id);
    $notes = $technicien->avisinterventions->pluck('note');
    $moyenne = $technicien->avisinterventions()->avg('note');
    

    $user = $technicien->user;
    $metier = $technicien->metier;
    $tarificationtache = $technicien->tarificationtache;
    $zoneintervention = $technicien->zoneintervention;


    return view('technicien.show' , compact('technicien'))->with('user',$user)- 
   >with('metier',$metier)->with('zoneintervention',$zoneintervention)- 
   >with('tarificationtache',$tarificationtache)->with('moyenne',$moyenne);

}

chagouani left a reply on JSON • 1 month ago

chagouani left a reply on Json • 1 month ago

@tykus please i have 1 more json function can you help me

https://laracasts.com/discuss/channels/laravel/json-8

chagouani left a reply on Display Table Where 'tache_id' On Table 'tarificationtache' Equal The Values Of Select Box' Id' From Table 'tache' • 1 month ago

@Vilfago I find that you always want to block me I'm looking for a solution if you can help me with a solution or with a link to understand like frater otherwise you do not stay with my question please

chagouani left a reply on JSON • 1 month ago

@Vilfago i would like a json fonction to call it in android application

chagouani left a reply on JSON • 1 month ago

@Vilfago i would like to shown the 'nom' and the avg note of technicien not the technicien_id

chagouani started a new conversation JSON • 1 month ago

I have 5 table techniciens(id, user_id,actif) users (nom , prenom , adresse ) tarificationtaches (id , tarif , technicien_id,tache_id , tarif) intervention(id , tarification_id , technicien_id....) avis_interventions( id , intervention_id , note )

I have a web service function to display the 'tarificationtache' list with the id of technicien but i would to shown his name and the avg of 'avis_interventions'

this is my service :

 public function getTar($id){

$taches=  Tache::with("tarificationtache")->get();
return response(compact('taches'));
}

he shown like this :

{"taches":[{"id":1,"libelle_tache":"montage  porte   
  simple","Tarif":null,"metier_id":1,"deleted_at":null,"created_at":"2018-06-08 
  11:41:41","updated_at":"2018-06-08 11:41:41","tarificationtache":[]},{"id":2,"libelle_tache":"tache 
  1","Tarif":null,"metier_id":1,"deleted_at":null,"created_at":"2018-06-08 
  11:41:55","updated_at":"2018-06-08 11:41:55","tarificationtache":[]},{"id":3,"libelle_tache":"tache 
  2","Tarif":null,"metier_id":2,"deleted_at":null,"created_at":"2018-06-08 
  11:42:01","updated_at":"2018-06-08 11:42:01","tarificationtache": 
  [{"id":1,"tarif":29.55,"tache_id":3,"technicien_id":1,"deleted_at":null,"created_at":"2018-06-08 
 11:58:54","updated_at":"2018-06-08 11:58:54"}]},{"id":4,"libelle_tache":"tache 
 3","Tarif":null,"metier_id":3,"deleted_at":null,"created_at":"2018-06-08 
 12:00:15","updated_at":"2018-06-08 12:00:15","tarificationtache": 
[{"id":2,"tarif":55.12,"tache_id":4,"technicien_id":2,"deleted_at":null,"created_at":"2018-06-08 
12:00:37","updated_at":"2018-06-08 12:00:37"}, 
{"id":3,"tarif":253,"tache_id":4,"technicien_id":1,"deleted_at":null,"created_at":"2018-06-15 
23:17:23","updated_at":"2018-06-15 23:17:23"}, 
{"id":4,"tarif":28.22,"tache_id":4,"technicien_id":2,"deleted_at":null,"created_at":"2018-06-20 
17:03:32","updated_at":"2018-06-20 17:03:32"}]}]}

saying that the average rating i perform in laravel with this functin

 public function show($id)
{
    $technicien = technicien::findOrFail($id);
    $notes = $technicien->avisinterventions->pluck('note');
    $moyenne = $technicien->avisinterventions()->avg('note');
    

    $user = $technicien->user;
    $metier = $technicien->metier;
    $tarificationtache = $technicien->tarificationtache;
    $zoneintervention = $technicien->zoneintervention;


    return view('technicien.show' , compact('technicien'))->with('user',$user)- 
   >with('metier',$metier)->with('zoneintervention',$zoneintervention)- 
   >with('tarificationtache',$tarificationtache)->with('moyenne',$moyenne);

}

20th June, 2018

chagouani left a reply on Display Table Where 'tache_id' On Table 'tarificationtache' Equal The Values Of Select Box' Id' From Table 'tache' • 1 month ago

@Vilfago i have do it with combobox he shown relative 'tarifcationtache' to tache but i like to shown on table

chagouani left a reply on Display Table Where 'tache_id' On Table 'tarificationtache' Equal The Values Of Select Box' Id' From Table 'tache' • 1 month ago

@vilfago this is the **find solution ** but i don't know how to impliment there with my code

<div class="modal-body">
//put your table in here
</div> 

After populate the table using this Javacript code

$.ajax({
type:'GET',
url:your_url,
dataType: 'json',
success:function(employee_list){
$table_body = $("#tbl_body_name");
$table_body.empty();

if (employee_list.length > 0) {
    div_no_data.style.display = 'none';
 $.each(employee_list, function (index, value) {
    $table_body.append('<tr class="deselected" 
 onclick="rowSelect(this)">' +
        '<td style="text-align: left;">' + value.technician_id  + 
 '</td>' +
        '<td style="text-align: left;">' + value.tache_id + '</td>' +
        '</tr>');
 });
}
 }
 });

Next use this function to get selected row information and set it to your desired dropdown

function rowSelect(currentRow){
//this is the code to set a dropdown menu using jquery
var technician_id = selectedRow.children[0].innerHTML;
$("#your_technician_dropdown_menu_id").val(technician_id);
}

chagouani left a reply on Display Table Where 'tache_id' On Table 'tarificationtache' Equal The Values Of Select Box' Id' From Table 'tache' • 1 month ago

@Vilfago I find this code on the internet and I do not know how to integrate it into my work because it is my first project with laravel if you have a link that I can see or if you can help me to solve my problém please

chagouani left a reply on Display Table Where 'tache_id' On Table 'tarificationtache' Equal The Values Of Select Box' Id' From Table 'tache' • 1 month ago

@Vilfago i have make table like this but he shown all tarificationtaches

<table class="table table-bordered bg-light">
        <thead class="bg-dark" style=" color: white">
                <tr>
                     <th class="light-table-filter" data-table="order-table" placeholder="Filter"    
   style=" color: #337ab7">technicien </th>
                     <th class="light-table-filter" data-table="order-table" placeholder="Filter" 
   style=" color: #337ab7">Tache </th>
                    <th class="light-table-filter" data-table="order-table" placeholder="Filter" 
   style=" color: #337ab7">tarif </th>
                    
                   
                    <th style="color: #337ab7" width="220px" style="vertical-align: 
        middle">Action</th>
                    
                </tr>
                </thead>
                <tbody>
                @foreach($tarifications as $tarifications)
                <tr>
                    <td>{{$tarifications->technciens}}</td>
                    <td>{{$tarifications->tache->libelle_tache}}</td>
                    <td>{{$tarifications->tarif}}</td>
                    
                    <td>
                        <form action="{{url ('tarifications/'.$tarifications->id)}}" method="post">
                            {{csrf_field()}}
                            {{method_field('DELETE')}}
                            <a href="{{url('tarifications/'.$tarifications->id.'/show')}}" 
     type="checkbox"  name ="action" value="" >choisir</a>
                            
                        </form>

                    </td>
                </tr>
                @endforeach
                </body>
            </table>

chagouani left a reply on Display Table Where 'tache_id' On Table 'tarificationtache' Equal The Values Of Select Box' Id' From Table 'tache' • 1 month ago

@Vilfago I tried with the ajax code to display the table but nothing is displayed

chagouani started a new conversation Display Table Where 'tache_id' On Table 'tarificationtache' Equal The Values Of Select Box' Id' From Table 'tache' • 1 month ago

I have a vieu that contion 2 combobox connect

we choose a 'metier' the list of 'tache' is displayed we choose a 'tache' I would like to display a table that contains the list of' tarificationtaches' that are the selected' tache' in the selectbox

iterventioncontroller

public function create()

{
    $client = client::orderBy('id', 'asc')->get();
    $metiers = metier::orderBy('id', 'asc')->get();
    $technicien = Technicien::orderBy('id', 'desc')->get();
    $tarifications = tarificationtache::orderBy('id', 'desc')->get();

    return view('intervention.create')->with('technicien', $technicien)->with('client',$client)- 
>with('metiers',$metiers)->with('tarifications',$tarifications);
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(InterventionRequest $request)
{
    $intervention = new Intervention();
    $intervention ->date_intervention =$request->input('date_intervention');
    $intervention ->description =$request->input('description');
    $intervention ->duree_prevu =$request->input('duree_prevu');
     if($request->has('statut')){
    $intervention->statut = $request->input('statut');
    }else{
           $intervention->statut = 0;
    }
    
    $intervention ->technicien_id = $request->input('technicien_id');
    $intervention ->client_id = $request->input('client_id');
    $intervention ->tarification_id = $request->tarification_id;
    $intervention->save();
    return redirect('intervention');




}

create.blade.php

     @extends('Layouts/app')
    @extends('Layouts/master')
 @section('content')
    <!--  jQuery -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
 <script type="text/javascript">
var getTachesByMetierUrl = "{{url('/tachesbymetier')}}";
    var getAdresseByClientUrl = "{{url('/adressebyclient')}}";
    var getTarificationsByTacheUrl = "{{url('/tarificationsbytache')}}";
    var getTechniciensByTarificationtacheUrl = "{{url('/techniciensbytarificationtache')}}";
    //console.log(getMetiersByTechnicienUrl,getTachesByMetierUrl 
    ,getTarificationsByTacheUrl);
    

    function getAdresseByClient(val) {
        if(val.length>0) {
            var client_id = val;
            $.get(getAdresseByClientUrl+'/'+client_id,function(res) {
                var html = '<option value="">-Select-</option>' ;
                $.each(res.adresses,function(index,item) {
                    html+='<option value="'+item.id+'">'+item.code_postal+'</option>';
                });
                $('#adresses').html(html);

            });
        }
    }


    function getTachesByMetier(val) {
        if(val.length>0) {
            var metier_id = val;
            $.get(getTachesByMetierUrl+'/'+metier_id,function(res) {
                var html = '<option value="">-Select-</option>' ;
                $.each(res.taches,function(index,item) {
                    html+='<option value="'+item.id+'">'+item.libelle_tache+'</option>';
                });
                $('#taches').html(html);

            });
        }
    }

     function getTechniciensByTache(val) {
        if(val.length>0) {
            var tache_id = val;
            $.get(getTechniciensByTacheUrl+'/'+tarificationtache_id,function(res) {
                var html = '<option value="">-Select-</option>' ;
                $.each(res.techniciens,function(index,item) {
                    html+='<option value="'+item.id+'">'+item.nom+'</option>';
                });
                $('#techniciens').html(html);

            });
        }
    }
 
   
    function rowSelect(currentRow){
        //this is the code to set a dropdown menu using jquery
        var technicien_id = selectedRow.children[0].innerHTML;
        $("#your_technicien_dropdown_menu_id").val(technicien_id);
    }




</script>



@if(count($errors))
    <div class="alert alert-danger" role="alert">
        <ul>
            @foreach($errors ->all() as $message)
                <li>{{$message}}</li>
            @endforeach
        </ul>
    </div>
@endif
<div class="container">
    <div class="row"></div>
    <div class="col-md-10">
        <h1>Ajout Intervention</h1>
        <form action=" {{url ('intervention')  }}" method="post">
            {{csrf_field()}}
            <div class="form-group">
                <label for="client">Client</label>
                <select onchange="getAdresseByClient(this.value)" name="client_id" id="client" 
 class="form-control">
                    <option value="">-Select-</option>
                    @foreach($client as $t)
                        <option value="{{$t->id }}">
                            {{$t->user->nom}}
                        </option>
                    @endforeach
                </select>
            </div>


            <div class="form-group">
                <label for="">date et heure </label>
                <input class="form-control" type="datetime-local"  name ="duree_prevu" value=" 
 {{old('duree_prevu')}}">
            </div>

            <div class="form-group">
                <label for="">description</label>
                <input type="text"  name ="description" class="form-control"value=" 
 {{old('description')}}">
            </div>

    <div class="form-group">
                <div class="col-md-12">
                <div class="col-md-4">
                <label>Metier: </label>
                <select onchange="getTachesByMetier(this.value)" style="width: 200px" 
  class="productm form-control" id="metiers">
               <option value="">-Select-</option>
                    @foreach($metiers as $t)
                        <option value="{{$t->id }}">
                            {{$t->libelle_metier}}
                        </option>
                    @endforeach
                </select>
            </div>

            <div class="col-md-4">
                <label>tache: </label>
                <select onchange="getTarificationsByTache(this.value)" style="width: 200px" 
  class="productname form-control" name="tache" id="taches">
                <option value="">-Select-</option>
                </select>
            </div>

            
</div>
            <div class="form-group">
                <div class="form-group">
                <label for="">statut    :   </label>
                <input type="checkbox"  name ="statut" value="1" required autofocus>
            </div>
            <div class="form-group">
                <label for="">payement</label>
                <input type="checkbox"  name ="payement" value="">
            </div>
            <div class="form-group">

                <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
            </div>
</div>
</div>
</div>
<script>
     function getMessage(){
         $.ajax({
                  type:'GET',
                  url:your_url,
                  dataType: 'json',
                  success:function(tarifications_list){
                    $table_body = $("#tbl_body_name");
                    $table_body.empty();

                    if (tarifications_list.length > 0) {
                        div_no_data.style.display = 'none';
                        $.each(tarifications_list, function (index, value) {
                            $table_body.append('<tr class="deselected" onclick="rowSelect(this)">' +
                                '<td style="text-align: left;">' + value.technicien_id  + '</td>' +
                                '<td style="text-align: left;">' + value.tache_id + '</td>' +
                                '</tr>');
                        });
                    }
                  }
                });
     }
  </script>

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"   
     rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-         
     datepicker.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap- 
    datepicker.js"></script>
@endsection

table tarificationtaches

 public function up()
{
    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();
    });
}

18th June, 2018

chagouani left a reply on How To Get "ajax" Table From Dynamic Data Whith ("jQuery") • 2 months ago

@mballaag peut tu m'aider a résoudre ça

15th June, 2018

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballaag mais avec ce code j'ai plus d'erreur mais il m'affiche la liste de tous les metier pas les metier du technicien selectionné

controller

 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);
}

create.blade.php

<div class="form-group">
            <div class="col-md-12">
                    <div class="col-md-4">
            <label>Metier: </label>
            <select onchange="getTachesByMetier(this.value)" style="width: 
            200px" class="productm form-control" id="metiers">
                <option value="">-Select-</option>
            @foreach($metiers as $metier)
                  <option value={{$metier->id}}>{{$metier->libelle_metier}}</option>
            @endforeach
           </select>
        </div>

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballaag maintenant j'ai afficher la liste des technicien puis j'ai appuier suer le bouton ajouter tarification pour accceder à notre interface tarification tache j'ai us cette erreur

"Trying to get property of non-object (View: 
    C:\xampp\htdocs\projet\resources\views\tarification\create.blade.php)" 

et voila le fichier log

[2018-06-15 23:07:06] local.ERROR: Trying to get property of non-object (View: C:\xampp\htdocs\projet\resources\views\tarification\create.blade.php) {"exception":"[object] (ErrorException(code: 0): Trying to get property of non-object (View: C:\xampp\htdocs\projet esources\views\tarification\create.blade.php) at C:\xampp\htdocs\projet\storage\framework\views\693a3f0d31735a2b8d627760cad9675360196a8e.php:74, ErrorException(code: 0): Trying to get property of non-object at C:\xampp\htdocs\projet\storage\framework\views\693a3f0d31735a2b8d627760cad9675360196a8e.php:74) [stacktrace] #0 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\View\Engines\PhpEngine.php(45): Illuminate\View\Engines\CompilerEngine->handleViewException(Object(ErrorException), 1) #1 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\View\Engines\CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('C:\\xampp\\htdocs...', Array) #2 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\View\View.php(137): Illuminate\View\Engines\CompilerEngine->get('C:\\xampp\\htdocs...', Array) #3 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\View\View.php(120): Illuminate\View\View->getContents() #4 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\View\View.php(85): Illuminate\View\View->renderContents() #5 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Http\Response.php(42): Illuminate\View\View->render() #6 C:\xampp\htdocs\projet\vendor\symfony\http-foundation\Response.php(201): Illuminate\Http\Response->setContent(Object(Illuminate\View\View)) #7 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Router.php(724): Symfony\Component\HttpFoundation\Response->__construct(Object(Illuminate\View\View)) #8 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Router.php(698): Illuminate\Routing\Router::toResponse(Object(Illuminate\Http\Request), Object(Illuminate\View\View)) #9 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Router.php(658): Illuminate\Routing\Router->prepareResponse(Object(Illuminate\Http\Request), Object(Illuminate\View\View)) #10 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #11 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #12 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure)) #13 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #14 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php(67): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #15 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure)) #16 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #17 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #18 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #19 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #20 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #21 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #22 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #23 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #24 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure)) #25 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #26 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #27 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure)) #28 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #29 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #30 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Router.php(660): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #31 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Router.php(635): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request)) #32 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Router.php(601): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route)) #33 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Router.php(590): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) #34 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) #35 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request)) #36 C:\xampp\htdocs\projet\vendor\fideloper\proxy\src\TrustProxies.php(56): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #37 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure)) #38 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #39 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #40 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure)) #41 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #42 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #43 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure)) #44 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #45 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #46 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure)) #47 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #48 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #49 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure)) #50 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #51 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #52 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Foundation\Http\ Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #53 C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\ Foundation\Http\Kernel.php(116): Illuminate\Foundation\Http\Kernel- >sendRequestThroughRouter(Object(Illuminate\Http\Request)) #54 C:\xampp\htdocs\projet\public\index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #55 {main} "}

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballaag

[2018-06-14 13:33:53] local.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'technicien_id' in 'where clause' (SQL: select * from metiers where technicien_id = 2 and metiers.deleted_at is null order by libelle_metier asc) {"exception":"[object] (Illuminate\Database\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'technicien_id' in 'where clause' (SQL: select * from metiers where technicien_id = 2 and metiers.deleted_at is null order by libelle_metier asc) at C:\xampp\htdocs\projet\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664, Doctrine\DBAL\Driver\PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'technicien_id' in 'where clause' at C:\xampp\htdocs\projet\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:79

14th June, 2018

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballag object(Illuminate\Database\Eloquent\Collection)#121 (1) { ["items":protected]=> array(1) { [0]=> object(App\metier)#361 (27) { ["guarded":protected]=> array(0) { } ["dates":protected]=> array(1) { [0]=> string(10) "deleted_at" } ["connection":protected]=> string(5) "mysql" ["table":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(5) { ["id"]=> int(3) ["libelle_metier"]=> string(8) "metier 2" ["deleted_at"]=> NULL ["created_at"]=> string(19) "2018-06-08 11:41:36" ["updated_at"]=> string(19) "2018-06-08 11:41:36" } ["original":protected]=> array(5) { ["id"]=> int(3) ["libelle_metier"]=> string(8) "metier 2" ["deleted_at"]=> NULL ["created_at"]=> string(19) "2018-06-08 11:41:36" ["updated_at"]=> string(19) "2018-06-08 11:41:36" } ["changes":protected]=> array(0) { } ["casts":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["dispatchesEvents":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=> bool(true) ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["forceDeleting":protected]=> bool(false) } } }

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballaag j'ai modifier le model et j'ai l'aisser la vue et le controller comme suite

<div class="col-md-4">
    <label>Metier: </label>
    <select onchange="getTachesByMetier(this.value)" style="width: 
    200px" class="productm form-control" id="metiers">
        <option value="">-Select-</option>
    @foreach($metiers as $metier)
          <option value={{$metier->id}}>{{$metier->libelle_metier}}</option>
    @endforeach
   </select>
            </div>

cotroller

 public function create($technicien_id)   
{
    $technicien = technicien::find($technicien_id);
    $taches = Tache::orderBy('libelle_tache', 'asc')->get();
    $metiers = Metier::orderBy('libelle_metier', 'asc')->whereHas('techniciens', 
    function($query) use ($technicien_id){
        $query->where('id',$technicien_id);
    })
    ->get();
    return view('tarification.create')->with('technicien', $technicien)->with('metiers', 
   $metiers);
}

j'ai u ce message d'erreur

"Trying to get property of non-object (View: 
   C:\xampp\htdocs\projet\resources\views\tarification\create.blade.php)"

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballaag nn la table intermédiaire entre metier et technicien 'technicien_metier'

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballaag

pas grave je vous remercie pour le temps que vous m'avais sacré

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 
'technicien_zone.metier_id' in 'where clause' (SQL: select * from `metiers` where 
exists (select * from `techniciens` inner join `technicien_zone` on `techniciens`.`id` 
= `technicien_zone`.`technicien_id` where `metiers`.`id` = 
`technicien_zone`.`metier_id` and `id` = 2 and `techniciens`.`deleted_at` is null) 
and `metiers`.`deleted_at` is null order by `libelle_metier` asc) ◀"    

chagouani left a reply on Get Id On Slect Box • 2 months ago

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'techniciens' in 'where 
clause' (SQL: select * from `metiers` where `techniciens` = (select * where `id` = 2) 
and `metiers`.`deleted_at` is null order by `libelle_metier` asc) ◀"

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballaag

"Missing argument 2 for 
    App\Http\Controllers\TarificationController::App\Http\Controllers\{closure}()"

chagouani left a reply on Get Id On Slect Box • 2 months ago

"Parse error: syntax error, unexpected ';', expecting ',' or ')'"

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballaag le nom du champ est comme dans le code et quand je suprime where j'ai cette erreur

Trying to get property of non-object (View: 
   C:\xampp\htdocs\projet\resources\views\tarification\create.blade.php)"

et entre metier et technicien j'ai une relation many to many comme ceci

model metier

 public function techniciens()
{
    return $this- 
    >belongsToMany('App\technicien','technicien_zone','metier_id','technicien_id');

}

model technicien

public function metier()
{
    return $this- 
>belongsToMany('App\metier','technicien_metier','technicien_id','metier_id');

}

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballaag when i have change like this i have this erreur

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'technicien_id' in 
    'where clause' (SQL: select * from `metiers` where `technicien_id` = 2 and 
   `metiers`.`deleted_at` is null order by `libelle_metier` asc) 

this is my view

<div class="form-group">
            <div class="col-md-12">
                    <div class="form-group">
                        <div class="col-md-12">
                                <div class="col-md-4">
                        <label>Metier: </label>
                        <select onchange="getTachesByMetier(this.value)" style="width: 
                        200px" class="productm form-control" id="metiers">
                            <option value="">-Select-</option>
                        @foreach($metiers as $metier)
                            <option value="{{$metier->id}}">{{$metier->libelle_metier}}</option>
                        @endforeach
                       </select>
                    </div>
                    <div class="col-md-4">
                        <label>tache: </label>
                        <select style="width: 200px" class="productname form-control" 
       name="tache_id" id="taches">
                            <option value="">-Select-</option>
                        </select>
                    </div>
                    <div class="col-md-4">
                        <label>tarification: </label>
                        <input style="width: 200px" class="productname form-control" 
          type="text"  name ="Tarif" class="form-control" value="{{old('tarif')}}">
                           
                        
                    </div>


                </div>
                </div>
                <div class="form-group">
                <input type="submit" value = "enregistrer" class="form-control btn btn- 
      primary">
            </div>
            </div>
                </div>

13th June, 2018

chagouani left a reply on Get Id On Slect Box • 2 months ago

@mballaag j'ai 2 interface la 1er affiche la liste des technicien avec un bouton ajouter tarification car chaque technicien à plusieurs tarification quand on appui sur le bouton ajouter tarification pour un technicien sélectionné dans la 1er interface elle nous redirige vers une interface qui contient des Select box relative ('technicien'->'metier'->'tache') le technicien doit être sélectionné automatiquement Mon problème maintenant c'est que l'interface tarification affiche le technicien automatiquement mais e sélect box n'affiche rien et si je sélectionne manuellement un technicien il affiche ses metier

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.