/** * Execute the job. * * @return \Illuminate\Database\Eloquent\Model */ public function handle() { $status = $this->request->input('status'); $title = $this->request->input('title'); $description = $this->request->input('description'); return $this->service->records()->create(compact('status', 'title', 'description')); }
/** * Execute the job. * * @return bool */ public function handle() { $this->service->name = $this->request->input('name'); $this->service->description = $this->request->input('description'); if ($this->service->save()) { $this->dispatch(new CreateFirst($this->service)); return true; } return false; }
public function import($devices) { $subscriptionCount = 0; foreach ($devices as $device) { if (isset($device['type']) && isset($device['address'])) { if (!($deviceModel = Device::find()->where(array('type' => $device['type'], 'address' => $device['address']))->one())) { $deviceModel = new Device(); } } $deviceModel->setAttributes($device); $identity = Yii::$app->user->identity; $deviceModel->user = $identity->id; //return $identity->id; if ($deviceModel->save()) { $deviceIndex = $deviceModel->getPrimaryKey(); //return $deviceIndex; if (isset($device['services'])) { //die(print_r($device['services'],true)); $subscriptionCount += Service::import($device['services'], $deviceIndex); } } /*else { return $deviceModel->getErrors(); }*/ return $subscriptionCount; } }
/** * post Store. * * @param Request $request Input data of booking form * * @return Response Redirect to Appointments listing */ public function postStore(Request $request) { $this->log->info(__METHOD__); ////////////////// // FOR REFACTOR // ////////////////// $issuer = auth()->user(); $business = Business::findOrFail($request->input('businessId')); $contact = $issuer->getContactSubscribedTo($business->id); $service = Service::find($request->input('service_id')); $strDateTime = $request->input('_date') . ' ' . $business->pref('start_at'); $datetime = Carbon::parse($strDateTime . ' ' . $business->timezone)->setTimezone('UTC'); $comments = $request->input('comments'); $this->concierge->setBusiness($business); $appointment = $this->concierge->makeReservation($issuer, $business, $contact, $service, $datetime, $comments); if (false === $appointment) { $this->log->info('[ADVICE] Unable to book'); Flash::warning(trans('user.booking.msg.store.error')); return redirect()->route('user.agenda'); } if (!$appointment->exists) { $this->log->info('[ADVICE] Appointment is duplicated'); Flash::warning(trans('user.booking.msg.store.sorry_duplicated', ['code' => $appointment->code])); return redirect()->route('user.agenda'); } $this->log->info('Appointment saved successfully'); event(new NewBooking($issuer, $appointment)); Flash::success(trans('user.booking.msg.store.success', ['code' => $appointment->code])); return redirect()->route('user.agenda'); }
/** * Displays the index (home) page. * Use it in case your home page contains static content. * * @return string */ public function actionIndex() { $searchModel = new ServiceSearch(); $searchModel->promo = true; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('tempindex', ['cat' => Category::find()->orderBy('name_pt')->all(), 'serv' => Service::find()->orderBy('title_pt')->all(), 'modelImg' => Campaign::find()->one(), 'dataProvider' => $dataProvider]); }
public function postDestroy() { $service = Service::find(Input::get('id')); if ($service) { $service->delete(); return Redirect::back()->with('message', 'Элемент удален'); } return Redirect::back()->with('message', "Ошибка"); }
/** * Create a new controller instance. * * @return void */ public function index(Request $request) { $email = Option::where('key', 'contact.email')->first()->value; $phone = Option::where('key', 'contact.phone')->first()->value; $slogan = Option::where('key', 'site.slogan')->first()->value; $social_links = array('facebook' => Option::where('key', 'facebook.link')->first()->value, 'twitter' => Option::where('key', 'twitter.link')->first()->value, 'youtube' => Option::where('key', 'youtube.link')->first()->value, 'linkedin' => Option::where('key', 'linkedin.link')->first()->value, 'instagram' => Option::where('key', 'instagram.link')->first()->value); $data = array('services' => Service::orderBy('sort_order')->get(), 'clients' => Client::orderBy('sort_order')->get(), 'photos' => Photo::orderBy('sort_order')->get(), 'email' => $email, 'phone' => $phone, 'slogan' => $slogan, 'social_links' => $social_links); return view('home', $data); }
public function getTimes($businessId, $serviceId, $date) { logger()->info(__METHOD__); logger()->info("businessId:{$businessId} serviceId:{$serviceId} date:{$date}"); $business = Business::findOrFail($businessId); $service = Service::findOrFail($serviceId); $vacancies = $business->vacancies()->forDate(Carbon::parse($date))->get(); $times = $this->splitTimes($vacancies, $service); return response()->json(['business' => $businessId, 'service' => ['id' => $service->id, 'duration' => $service->duration], 'date' => $date, 'times' => $times], 200); }
/** * Deletes the specified service. * * @param int|string $id * * @return \Illuminate\Http\RedirectResponse */ public function destroy($id) { $service = $this->service->findOrFail($id); if ($service->delete()) { flash()->success('Success!', 'Successfully deleted service.'); return redirect()->route('services.index'); } flash()->error('Error!', 'There was an issue deleting this service. Please try again.'); return redirect()->route('services.show', [$id]); }
/** * AJAX * Добавляет site_update * Делает рассылку * * @param integer $id - идентификатор услуги * * @return string */ public function actionSubscribe($id) { $item = Service::find($id); if (is_null($item)) { return self::jsonError(101, 'Не найдено послание'); } Subscribe::add($item); SiteUpdate::add($item); $item->update(['is_added_site_update' => 1]); return self::jsonSuccess(); }
/** * @covers App\Models\Service::scopeSlug * @test */ public function it_scopes_by_slug() { $business = $this->createBusiness(); $service = $this->makeService(); $business->services()->save($service); $services = Service::slug($service->slug); $count = $services->count(); $service = $services->first(); /* Perform Test */ $this->assertInstanceOf(Service::class, $service); $this->assertEquals($count, 1); }
public function all($params) { $params['order'] = isset($params['order']) ? $params['order'] : ['services.id|DESC']; $services = Service::select("services.*"); $services->leftJoin("companies", "companies.id", "=", "services.company_id"); $services->leftJoin("company_person as internal_contact", "internal_contact.id", "=", "services.internal_contact_id"); $services->leftJoin("company_person as external_contact", "external_contact.id", "=", "services.external_contact_id"); $services->leftJoin('people as internals', 'internal_contact.person_id', '=', 'internals.id'); $services->leftJoin('people as externals', 'external_contact.person_id', '=', 'externals.id'); $services->leftJoin('hotels', 'hotels.id', '=', 'services.hotel_id'); $services = parent::execute($services, $params); return $services; }
public function up() { $this->execute('ALTER TABLE galaxysss_1.gs_services ADD column_name int NULL;'); $rows = \app\models\Service::query()->select(['id', 'date_insert'])->all(); foreach ($rows as $row) { $date = new DateTime($row['date_insert']); \app\models\Service::find($row['id'])->update(['column_name' => $date->format('U')]); } // удаляю старую колонку $this->execute('ALTER TABLE galaxysss_1.gs_services DROP date_insert;'); // переименовываю вновь созданную колонку $this->execute('ALTER TABLE galaxysss_1.gs_services CHANGE column_name date_insert int NULL;'); }
public function import($services, $deviceIndex) { $subscriptionCount = 0; foreach ($services as $service) { if (isset($service['serviceUuid']) && is_array($service['serviceUuid'])) { $service['serviceUuid'] = $service['serviceUuid'][0]; } if (!($serviceModel = Service::find()->where(array('device' => $deviceIndex, 'serviceUuid' => $service['serviceUuid']))->one())) { $serviceModel = new Service(); } $service = array_merge($service, array('device' => $deviceIndex)); $serviceModel->setAttributes($service); if ($serviceModel->save()) { $serviceIndex = $serviceModel->getPrimaryKey(); if (isset($service['charasteristics'])) { $subscriptionCount += \app\models\Charasteristic::import($service['charasteristics'], $serviceIndex); } } //else { //die(print_r( $serviceModel->getErrors(),true)); //} } return $subscriptionCount; }
/** * Display a listing of the resource. * * @return Response */ public function index(Region $region, TrainRoad $trainRoad, Stantion $stantion) { $regionsCount = $region->count(); $tRoadsCount = $trainRoad->count(); $stationsCount = $stantion->count(); $condCount = Condition::count(); $productsCount = Product::count(); $servicesCount = Service::count(); $catCount = Category::count(); $statusesCount = Status::count(); $serviceStatusesCount = ServiceStatus::count(); $newOrdersCount = Order::where('is_new', 1)->count(); $newServiceOrdersCount = ServiceOrder::where('is_new', 1)->count(); $customers = Firm::where('accountant_fio', null)->get(); return view('admin.adminArea', ['regionsCount' => $regionsCount, 'tRoadsCount' => $tRoadsCount, 'stationsCount' => $stationsCount, 'condCount' => $condCount, 'catCount' => $catCount, 'productsCount' => $productsCount, 'servicesCount' => $servicesCount, 'statusesCount' => $statusesCount, 'newOrdersCount' => $newOrdersCount, 'serviceStatusesCount' => $serviceStatusesCount, 'newServiceOrdersCount' => $newServiceOrdersCount, 'customers' => $customers]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Service::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['catName'] = ['asc' => ['category.name_' . Yii::$app->language => SORT_ASC], 'desc' => ['category.name_' . Yii::$app->language => SORT_DESC]]; $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); $query->joinWith(['category']); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'price' => $this->price, 'promo' => $this->promo, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'sku', $this->sku])->andFilterWhere(['like', 'title_en', $this->title_en])->andFilterWhere(['like', 'title_pt', $this->title_pt])->andFilterWhere(['like', 'summary_en', $this->summary_en])->andFilterWhere(['like', 'summary_pt', $this->summary_pt])->andFilterWhere(['like', 'description_en', $this->description_en])->andFilterWhere(['like', 'description_pt', $this->description_pt])->andFilterWhere(['like', 'availability_en', $this->availability_en])->andFilterWhere(['like', 'availability_pt', $this->availability_pt])->andFilterWhere(['like', 'promo_txt_en', $this->promo_txt_en])->andFilterWhere(['like', 'promo_txt_pt', $this->promo_txt_pt]); $query->joinWith(['category' => function ($q) { $q->where('category.name_' . Yii::$app->language . ' LIKE "%' . $this->catName . '%"'); }]); return $dataProvider; }
public static function getFirstServiceOfBranch($branch_id) { return Service::where('branch_id', '=', $branch_id)->first(); }
protected function processServiceStatements($business, $date, $services) { $changed = false; foreach ($services as $serviceSlug => $statements) { $service = Service::where('slug', $serviceSlug)->get()->first(); if ($service === null) { continue; } $vacancy = $business->vacancies()->forDate(Carbon::parse($date))->forService($service); if ($vacancy) { $vacancy->delete(); } $changed |= $this->processStatements($business, $date, $service, $statements); } return $changed; }
public static function postEditService() { if (Auth::check()) { $validation = \App\Models\Service::validate(Input::all()); if ($validation->passes()) { $raw = 'UPDATE sluzby SET Cena = ' . Input::get('price') . ', Nazov = "' . Input::get('name') . '" WHERE CisSluzby = ' . Input::get('id'); DB::select(DB::raw($raw)); return Redirect::route('home')->with('message', 'Editing of service was successfull!'); } else { foreach (\App\Models\Service::showService(Input::get('id')) as $value) { $my_service = $value; } return Redirect::route('editservice')->withErrors($validation)->withInput()->with('service', $my_service); } } else { return Redirect::route('home')->with('message', 'You are not logged in!'); } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($yy, $qq, $aa) { $fin = array(); $fm = Helpers::getSetting('first_month'); $m1 = $qq * 3 - 3 + $fm; $y1 = $yy; $m2 = $qq * 3 - 2 + $fm; $y2 = $yy; $m3 = $qq * 3 - 1 + $fm; $y3 = $yy; if ($m2 > 12) { $m2 = $m2 - 12; $y2 = $y2 + 1; } if ($m3 > 12) { $m3 = $m3 - 12; $y3 = $y3 + 1; } if ($aa == "edit") { $perms = Permission::where('user_id', '=', Auth::user()->id)->get(); foreach ($perms as $perm) { if ($perm->preaching or $perm->admin) { $data['authsoc'][] = $perm['society_id']; } } if (!isset($data['authsoc'])) { $aa = "view"; } } $firstDateTime = mktime(0, 0, 0, $m1, 1, $y1); $firstDay = date("N", $firstDateTime); $firstSunday = date("d M Y", mktime(0, 0, 0, $m1, 8 - $firstDay, $y1)); $lastSunday = strtotime($firstSunday); $lastDay = mktime(23, 59, 59, $m3, cal_days_in_month(CAL_GREGORIAN, $m3, $y3), $y3); $extras = Weekday::where('servicedate', '>=', $firstDateTime)->where('servicedate', '<=', $lastDay)->orderBy('servicedate')->get()->toArray(); $data['meetings'] = Meeting::where('meetingdatetime', '<', $lastDay)->where('meetingdatetime', '>', $firstDateTime)->orderBy('meetingdatetime')->get(); $dum['dt'] = $lastSunday; $dum['yy'] = intval(date("Y", $lastSunday)); $dum['mm'] = intval(date("n", $lastSunday)); $dum['dd'] = intval(date("j", $lastSunday)); $sundays[] = $dum; $data['societies'] = Society::orderBy('society')->with('service')->get(); $data['ministers'] = Minister::has('individual')->get(); $data['preachers'] = Preacher::has('individual')->get(); $data['guests'] = Guest::where('active', '=', 1)->get(); while (date($lastSunday + 604800 <= $lastDay)) { $lastSunday = $lastSunday + 604800; $dum['dt'] = $lastSunday; $dum['yy'] = intval(date("Y", $lastSunday)); $dum['mm'] = intval(date("n", $lastSunday)); $dum['dd'] = intval(date("j", $lastSunday)); $sundays[] = $dum; } if (count($extras)) { $xco = 0; for ($q = 0; $q < count($sundays); $q++) { if ($xco < count($extras) and $extras[$xco]['servicedate'] < $sundays[$q]['dt']) { $dum['dt'] = $extras[$xco]['servicedate']; $dum['yy'] = intval(date("Y", $extras[$xco]['servicedate'])); $dum['mm'] = intval(date("n", $extras[$xco]['servicedate'])); $dum['dd'] = intval(date("j", $extras[$xco]['servicedate'])); $data['sundays'][] = $dum; $xco++; $q = $q - 1; } else { $data['sundays'][] = $sundays[$q]; } } } else { $data['sundays'] = $sundays; } $pm1 = Plan::where('planyear', '=', $y1)->where('planmonth', '=', $m1)->get(); foreach ($pm1 as $p1) { $soc = Society::find($p1->society_id)->society; $ser = Service::find($p1->service_id)->servicetime; if ($p1->preachable) { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['preacher'] = substr($p1->preachable_type, 11, 1) . "_" . $p1->preachable->id); if ($p1->preachable_type == "App\\Models\\Guest") { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['pname'] = substr($p1->preachable->firstname, 0, 1) . " " . $p1->preachable->surname); } else { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['pname'] = substr($p1->preachable->individual->firstname, 0, 1) . " " . $p1->preachable->individual->surname); } } else { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['preacher'] = ""); } if ($p1->tag_id) { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['tag'] = $p1->tag_id); @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['tname'] = Tag::find($p1->tag_id)->abbr); } else { @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['tag'] = ""); } } $pm2 = Plan::where('planyear', '=', $y2)->where('planmonth', '=', $m2)->get(); foreach ($pm2 as $p2) { $soc = Society::find($p2->society_id)->society; $ser = Service::find($p2->service_id)->servicetime; if ($p2->preachable) { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['preacher'] = substr($p2->preachable_type, 11, 1) . "_" . $p2->preachable->id); if ($p2->preachable_type == "App\\Models\\Guest") { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['pname'] = substr($p2->preachable->firstname, 0, 1) . " " . $p2->preachable->surname); } else { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['pname'] = substr($p2->preachable->individual->firstname, 0, 1) . " " . $p2->preachable->individual->surname); } } else { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['preacher'] = ""); } if ($p2->tag_id) { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['tag'] = $p2->tag_id); @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['tname'] = Tag::find($p2->tag_id)->abbr); } else { @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['tag'] = ""); } } $pm3 = Plan::where('planyear', '=', $y3)->where('planmonth', '=', $m3)->get(); foreach ($pm3 as $p3) { $soc = Society::find($p3->society_id)->society; $ser = Service::find($p3->service_id)->servicetime; if ($p3->preachable) { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['preacher'] = substr($p3->preachable_type, 11, 1) . "_" . $p3->preachable->id); if ($p3->preachable_type == "App\\Models\\Guest") { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['pname'] = substr($p3->preachable->firstname, 0, 1) . " " . $p3->preachable->surname); } else { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['pname'] = substr($p3->preachable->individual->firstname, 0, 1) . " " . $p3->preachable->individual->surname); } } else { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['preacher'] = ""); } if ($p3->tag_id) { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['tag'] = $p3->tag_id); @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['tname'] = Tag::find($p3->tag_id)->abbr); } else { @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['tag'] = ""); } } $data['tags'] = Tag::orderBy('abbr')->get(); if ($qq == 1) { $data['prev'] = "plan/" . strval($yy - 1) . "/4"; } else { $data['prev'] = "plan/{$yy}/" . strval($qq - 1); } if ($qq == 4) { $data['next'] = "plan/" . strval($yy + 1) . "/1"; } else { $data['next'] = "plan/{$yy}/" . strval($qq + 1); } if ($aa == "edit") { return View::make('plans.edit', $data); } else { $data['pb'] = Helpers::getSetting('presiding_bishop'); if (!$data['pb']) { return view('errors.errors')->with('errormessage', 'Before you can view the plan, please enter the name of the Presiding Bishop'); } $data['gs'] = Helpers::getSetting('general_secretary'); if (!$data['gs']) { return view('errors.errors')->with('errormessage', 'Before you can view the plan, please enter the name of the General Secretary'); } $data['db'] = Helpers::getSetting('district_bishop'); if (!$data['db']) { return view('errors.errors')->with('errormessage', 'Before you can view the plan, please enter the name of the District Bishop'); } $data['super'] = Individual::find(Helpers::getSetting('superintendent')); if (!$data['super']) { return view('errors.errors')->with('errormessage', 'Before you can view the plan, please specify who the Circuit Superintendent is'); } $this->report($data); } }
/** * Remove the specified resource from storage. * * @param Business $business Business to destroy service of * @param Service $service Service to destroy * * @return Response */ public function destroy(Business $business, Service $service) { logger()->info(__METHOD__); logger()->info(sprintf('businessId:%s serviceId:%s', $business->id, $service->id)); $this->authorize('manageServices', $business); // BEGIN ////////////////// // FOR REFACTOR // ////////////////// $service->forceDelete(); flash()->success(trans('manager.services.msg.destroy.success')); return redirect()->route('manager.business.service.index', $business); }
/** * Finds the Service model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Service the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Service::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Remove the specified resource from storage. * * @param Business $business Business to destroy service of * @param Service $service Service to destroy * @return Response */ public function destroy(Business $business, Service $service) { $this->log->info(__METHOD__); $this->log->info(sprintf("businessId:%s serviceId:%s", $business->id, $service->id)); /////////////////////////////// // TODO: AUTH GATE GOES HERE // /////////////////////////////// ////////////////// // FOR REFACTOR // ////////////////// $service->forceDelete(); Flash::success(trans('manager.services.msg.destroy.success')); return redirect()->route('manager.business.service.index', $business); }
public function storeServiceOrder(ServiceOrder $serviceOrder, StoreServiceOrder $request) { $status = ServiceStatus::where('is_first', Order::IS_FIRST)->first(); $user = Auth::user(); $service = Service::find($request->service_id); $serviceOrder->service_status_id = $status->id; $serviceOrder->user_id = $user->id; $serviceOrder->firm_id = $user->firm->id; $serviceOrder->service_name = $service->short_name; $serviceOrder->service_price = $service->price; $serviceOrder->more_info = $request->more_info; if ($request->need_station) { $serviceOrder->station_names = $request->station_names; } $serviceOrder->save(); $messageParams['service'] = $serviceOrder; Bus::dispatch(new SendWithTanksForServiceOrder($messageParams)); return view('orders.serviceSuccess', ['p' => 'purchases', 'serviceName' => $service->short_name]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($soc_id, $id) { $service = Service::find($id); $service->delete(); return Redirect::back()->with('okmessage', 'Preacher has been deleted'); }
public function getService() { return $this->hasOne(Service::className(), ['id' => 'service_id']); }
public function actionServices_item($id) { return $this->render(['item' => Service::find($id)]); }
protected function processServiceStatements($business, $date, $services) { $changed = false; foreach ($services as $serviceSlug => $statements) { $service = Service::where('slug', $serviceSlug)->get()->first(); if ($service === null) { // Invalid services are skipped to avoid user frustration. // TODO: Still, a user-level WARNING should be raised with no fatal error continue; } $vacancy = $business->vacancies()->forDate(Carbon::parse($date))->forService($service); if ($vacancy) { $vacancy->delete(); } $changed |= $this->processStatements($business, $date, $service, $statements); } return $changed; }
public function getServices() { return $this->hasMany(Service::className(), ['category_id' => 'id']); }
/** * Execute the job. * * @return bool */ public function handle() { $this->service->name = $this->request->input('name', $this->service->name); $this->service->description = $this->request->input('description', $this->service->description); return $this->service->save(); }