コード例 #1
0
 /**
  * Update the business service types.
  *
  * @param Business $business
  * @param Request  $request
  *
  * @return Response
  */
 public function update(Business $business, Request $request)
 {
     logger()->info(__METHOD__);
     logger()->info(sprintf('businessId:%s', $business->id));
     $this->authorize('manageServices', $business);
     // BEGIN
     $servicetypeSheet = $request->input('servicetypes');
     $regex = '/(?P<name>[a-zA-Z\\d\\-\\ ]+)\\:(?P<description>[a-zA-Z\\d\\ ]+)/im';
     preg_match_all($regex, $servicetypeSheet, $matches, PREG_SET_ORDER);
     $publishing = collect($matches)->map(function ($item) {
         $data = array_only($item, ['name', 'description']);
         $data['slug'] = str_slug($data['name']);
         return $data;
     });
     foreach ($business->servicetypes as $servicetype) {
         if (!$this->isPublished($servicetype, $publishing)) {
             $servicetype->delete();
         }
     }
     foreach ($publishing as $servicetypeData) {
         $servicetype = ServiceType::firstOrNew($servicetypeData);
         $business->servicetypes()->save($servicetype);
     }
     flash()->success(trans('servicetype.msg.update.success'));
     return redirect()->route('manager.business.service.index', [$business]);
 }
コード例 #2
0
ファイル: run.php プロジェクト: jyothu/Rates
 $policyName = $row["CHARGINGPOLICYNAME"];
 $seasonId = $row["SEASONTYPEID"];
 $seasonName = $row["SEASONTYPENAME"];
 $seasonStart = $row["SEASONSTARTDATE"];
 $seasonEnd = $row["SEASONENDDATE"];
 $contractId = $row["ORGANISATIONSUPPLIERCONTRACTID"];
 $contractName = $row["ORGANISATIONSUPPLIERCONTRACTNAME"];
 $contractPeriodId = $row["CONTRACTDURATIONID"];
 $contractPeriodName = $row["CONTRACTDURATIONNAME"];
 $contractStart = $row["CONTRACTDURATIONSTARTDATE"];
 $contractEnd = $row["CONTRACTDURATIONENDDATE"];
 $currency = $row["CURRENCYISOCODE"];
 $buyPrice = $row["BUYPRICE"];
 $margin = $row["MARGIN"];
 $sellPrice = $row["SELLING"];
 $serviceTypeObj = Models\ServiceType::firstOrCreate(array('name' => $serviceType));
 $currencyObj = Models\Currency::firstOrCreate(array('code' => $currency));
 $regionObj = Models\Region::firstOrCreate(array('name' => $region));
 $supplierObj = $regionObj->suppliers()->firstOrCreate(array('name' => $supplierName, 'ts_id' => $supplierId));
 if ($occupancyId) {
     $occupancyObj = Models\Occupancy::firstOrCreate(array('id' => $occupancyId, 'name' => $occupancyName));
 }
 if ($mealName) {
     $mealObj = Models\Meal::firstOrCreate(array('name' => $mealName));
 }
 // Find or Create Service
 $serviceParams = array('ts_id' => $serviceId, 'name' => $serviceName, 'region_id' => $regionObj->id, 'currency_id' => $currencyObj->id, 'service_type_id' => $serviceTypeObj->id, 'supplier_id' => $supplierObj->id, 'name' => $serviceName);
 $serviceObj = Models\Service::firstOrCreate($serviceParams);
 // Find or Create Policies
 $policyParams = array('ts_id' => $policyId, 'name' => $policyName);
 Models\Policy::firstOrCreate($policyParams);