/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $firstCondition = new Condition(['type' => 'if', 'field' => 'event.type', 'operator' => '==', 'value' => 'push']);
     $firstCondition->save();
     $splitter = new Splitter();
     $splitter->save();
     $firstSplit = new Split();
     $firstSplit->save();
     $secondSplit = new Split();
     $secondSplit->save();
     $secondCondition = new Condition(['type' => 'contains', 'field' => '', 'operator' => '==', 'value' => '']);
     $secondCondition->save();
     $firstAction = new Action(['type' => 'ssh']);
     $host = new Host(['host' => 'ssh', 'port' => '22']);
     $auth = new Auth();
     $accountAuth = new AuthAccount();
     $accountAuth->username = getenv('SSH_USERNAME');
     $accountAuth->password = getenv('SSH_PASSWORD');
     $accountAuth->save();
     try {
         $file = new File();
         $keyAuth = new AuthKey();
         $keyAuth->username = '******';
         $keyAuth->key = $file->get('.docker/builds/ssh/ssh_keys/id_rsa');
         $keyAuth->key_public = $file->get('.docker/builds/ssh/ssh_keys/id_rsa.pub');
         $keyAuth->save();
     } catch (Illuminate\Filesystem\FileNotFoundException $exception) {
         dump("SSH Key Not Found");
     }
     $auth->credentials()->associate($keyAuth);
     $auth->save();
     $host->auth()->associate($auth);
     $host->save();
     $firstAction->host()->associate($host);
     $firstAction->save();
     $firstAction->addCommand('touch testing');
     $firstAction->addCommand('ls');
     $secondAction = new Action();
     $secondAction->save();
     $secondAction->addCommand('composer install');
     $secondCondition->successPipeable()->associate($secondAction)->save();
     $firstSplit->pipeable()->associate($secondCondition);
     $secondSplit->pipeable()->associate($firstAction);
     $splitter->splits()->save($firstSplit);
     $splitter->splits()->save($secondSplit);
     $firstCondition->successPipeable()->associate($splitter)->save();
     $project = new Project();
     $project->name = 'example';
     $project->group = 'exampleGroup';
     $project->url = 'http://localhost/exampleGroup/example';
     $project->project_id = 2;
     $project->save();
     $project->conditions()->save($firstCondition);
 }
Example #2
0
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         Condition::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }
 public function actionExecute($id)
 {
     $model = Condition::one($id);
     $return = Condition::execute($id);
     $session = Yii::$app->session;
     if (true === $return) {
         Yii::$app->session->setFlash('success', Yii::t('app', 'Yes {name} !', ['name' => $model->name]));
     } elseif (false === $return) {
         Yii::$app->session->setFlash('warning', Yii::t('app', 'No {name} !', ['name' => $model->name]));
     } else {
         Yii::$app->session->setFlash('info', Yii::t('app', '{name} = {return} !', ['name' => $model->name, 'return' => $return]));
     }
     return $this->redirect(['condition/index']);
 }
Example #4
0
 /**
  * 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]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $cond = Condition::find($id);
     $cond->delete();
     //Region::destroy($id);
     return back()->with('alert-success', 'Состояние ' . $cond->condition . ' удалено');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit(Condition $condition, Category $category, $id)
 {
     try {
         $product = Product::with(['price', 'price.stantion', 'price.stantion.train_road'])->where('id', $id)->first();
     } catch (ModelNotFoundException $e) {
         abort(404);
     }
     if (!$product) {
         abort(404);
     }
     $VAT_rate = Product::getAllVAT_rate();
     $conditions = $condition->all();
     $categories = $category->all();
     $prices = $product->price;
     $pricesArr = [];
     foreach ($prices as $price) {
         $pricesArr[$price->stantion[0]->train_road->id][$price->stantion[0]->train_road->tr_name][] = ['stantion_name' => $price->stantion[0]->stantion_name, 'stantion_id' => $price->stantion[0]->id, 'price' => $price->price, 'amount' => $price->amount, 'nds' => $price->nds];
     }
     unset($prices);
     return view('products.edit', ['product' => $product, 'conditions' => $conditions, 'conditionID' => $product->condition_id, 'categories' => $categories, 'categoryID' => $product->category_id, 'id' => $product->id, 'prices' => $pricesArr, 'VAT_rate' => $VAT_rate]);
 }