/** * Show the form for editing the specified resource. * * @param int $id * @param CarrierRepository $carriers * @return Response */ public function edit($id, CarrierRepository $carriers) { try { return view('carriers.edit')->with('model', $carriers->findById($id)); } catch (ModelNotFoundException $e) { flash()->warning(trans('carriers.not_found')); return redirect()->route('carrier.index'); } }
/** * Execute the command. * * @param CarrierRepository $carriers * @return Carrier */ public function handle(CarrierRepository $carriers) { $carrier = Carrier::register($this->name); try { $carriers->findDefaultCarrier(); } catch (ModelNotFoundException $e) { $carrier->is_default_carrier = true; } $carriers->save($carrier); return $carrier; }
/** * Execute the command. * * @param CarrierRepository $carriers * @return Carrier */ public function handle(CarrierRepository $carriers) { if ($this->is_default_carrier) { try { $carrier = $carriers->findDefaultCarrier()->fill(['is_default_carrier' => false]); $carriers->save($carrier); } catch (ModelNotFoundException $e) { } } $carrier = $carriers->findById($this->id)->fill($this->getProperties()); $carriers->save($carrier); return $carrier; }
/** * Execute the command. * * @param CarrierRepository $carriers * @return Paginator */ public function handle(CarrierRepository $carriers) { return $carriers->query($this->q); }
/** * Show the form for creating a new resource. * * @param CarrierRepository $carriers * @param CountryRepository $countries * @return Response */ public function create(CarrierRepository $carriers, CountryRepository $countries) { return view('shipping-rules.create')->with('carriers', $carriers->all())->with('countries', $countries->all()); }