コード例 #1
0
ファイル: OrdersController.php プロジェクト: skosm/LaraShop
 public function update(Request $request, $id)
 {
     //
     $order = Purchase::findOrFail($id);
     $validator = Validator::make($request->all(), ['name' => 'required|min:2|max:255', 'tel' => 'required|min:2', 'email' => 'required|email']);
     if ($validator->fails()) {
         return back()->withErrors($validator)->withInput();
     } else {
         $client = Clients::findOrFail($order->client_id);
         $client->update(['name' => $request->name, 'tel' => $request->tel, 'email' => $request->email]);
         $order->update(['code' => $request->code, 'delivery_type' => $request->delivery_type, 'pay_type' => $request->pay_type, 'delivery_city' => $request->delivery_city, 'delivery_np' => $request->delivery_np, 'delivery_adr' => $request->delivery_adr, 'comment' => $request->comment, 'ttn' => $request->ttn]);
         $request->session()->flash('alert-success', 'Заказ отредактирован!');
         return redirect('orders/' . $id);
     }
 }
コード例 #2
0
ファイル: ClientsController.php プロジェクト: skosm/LaraShop
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     $client = Clients::findOrFail($id);
     $client->delete();
 }