如何在弹出窗口中显示错误消息

时间:2018-09-13 09:59:28

标签: php laravel laravel-5

每个技术人员对一个特定的“ tache”只有一个“ Tarification”,如果“ tarification”存在,我就提出条件,它返回错误消息,但在另一页中,我会在弹出窗口中以相同的方式显示它。 ................................................... ................................................... ............................

public function store(Request $request){
    $count = tarificationtache::where('technicien_id', 
        $request->input('technicien_id')
    )
    ->where('tache_id', $request->input('tache_id'))
    ->count();
    if ($count > 0) {
        // TODO: adjust response according to your need
            return response()->json(['error' => "Ce technicien a cette 
tarification"], 400);
    } else {
        $tarification = new tarificationtache;    
        $tarification->tache_id = $request->input('tache_id');
        $tarification->Tarif = $request->input('Tarif');
        $tarification->technicien_id = $request->input('technicien_id');
        $tarification->save();
        // TODO: adjust response according to your need
        return redirect('technicien');
    }
}

这是我的观点

<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
 </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>
            </div>

0 个答案:

没有答案