コード例 #1
0
ファイル: AgencyRepository.php プロジェクト: sibasbo/sibas
 /**
  * @param int $retailer_id
  * @return mixed
  */
 public function getAgenciesByRetailer($retailer_id)
 {
     return Agency::with('retailerCityAgencies.retailerCity')->whereHas('retailerCityAgencies.retailerCity', function ($q) use($retailer_id) {
         $q->where('ad_retailer_id', $retailer_id);
     })->get();
 }
コード例 #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request)
 {
     $slug = Str::slug($request->input('txtAgencia'));
     try {
         $query_update = Agency::where('id', $request->input('id_agency'))->first();
         $query_update->name = $request->input('txtAgencia');
         $query_update->code = $request->input('txtCodigo');
         $query_update->slug = $slug;
         if ($query_update->save()) {
             return redirect()->route('admin.agencies.list', ['nav' => 'agency', 'action' => 'list']);
         }
     } catch (QueryException $e) {
         return redirect()->back()->with(array('error' => $e->getMessage()));
     }
 }