/**
  * Here we'll decide what command the user wants.
  * This isn't the way the packages wants to work, but I like
  * to do it my own way and be more flexible in the future
  */
 public function message()
 {
     $result = false;
     $command = explode(" ", $this->command, 2);
     $command[0] = stripslashes($command[0]);
     if ($command[0] == '/start') {
         $result = $this->getStarted();
     } elseif ($command[0] == '/class') {
         $result = $this->setClass($command[1]);
     } elseif ($command[0] == '/now') {
         $result = $this->getNow();
     } elseif ($command[0] == '/today') {
         $result = $this->getToday();
     } elseif ($command[0] == '/tomorrow') {
         $result = $this->getTomorrow();
     } elseif ($command[0] == '/week') {
         $result = $this->getWeekly();
     } elseif ($command[0] == '/nextweek') {
         $result = $this->getNextWeek();
     } elseif ($command[0] == '/contact') {
         $result = $this->getContact();
     }
     //If no valid command has been given
     if (!$result) {
         $result = $this->invalidRequest();
     } else {
         //Create new command (for logging purposes)
         $data = ['user_id' => $this->chatId, 'command' => str_replace('/', '', $command[0])];
         Command::create($data);
     }
     //Reply with a message
     $reply_markup = $this->telegram->replyKeyboardMarkup($this->keyboard, true, false);
     $this->telegram->sendMessage($this->chatId, $result, false, null, $reply_markup);
 }
Пример #2
0
 public function run()
 {
     $laravel = Project::create(['name' => 'Laravel', 'is_template' => true, 'group_id' => 1]);
     Project::create(['name' => 'Wordpress', 'is_template' => true, 'group_id' => 1]);
     Command::create(['name' => 'Down', 'script' => 'php artisan down', 'project_id' => $laravel->id, 'user' => 'vagrant', 'step' => Command::BEFORE_ACTIVATE]);
     Command::create(['name' => 'Run Migrations', 'script' => 'php artisan migrate --force', 'project_id' => $laravel->id, 'user' => 'vagrant', 'step' => Command::BEFORE_ACTIVATE]);
     Command::create(['name' => 'Up', 'script' => 'php artisan up', 'project_id' => $laravel->id, 'user' => 'vagrant', 'step' => Command::BEFORE_ACTIVATE]);
 }
 public function create(Request $request)
 {
     $filename = '';
     if ($request->hasFile('logo')) {
         $filename = md5('logo' . uniqid()) . '.' . $request->file('logo')->guessExtension();
         $request->file('logo')->move(__DIR__ . "/../../../public/uploads", $filename);
     }
     $command = Command::create(['title' => $request->get('title'), 'short_description' => $request->get('short_description'), 'description' => $request->get('description'), 'logo' => $filename]);
     return response()->json($command, 201);
 }
Пример #4
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $template = Project::findOrFail($this->template_id);
     foreach ($template->commands as $command) {
         $data = $command->toArray();
         $data['project_id'] = $this->project->id;
         Command::create($data);
     }
     foreach ($template->sharedFiles as $file) {
         $data = $file->toArray();
         $data['project_id'] = $this->project->id;
         SharedFile::create($data);
     }
     foreach ($template->projectFiles as $file) {
         $data = $file->toArray();
         $data['project_id'] = $this->project->id;
         ProjectFile::create($data);
     }
 }
Пример #5
0
 public function run()
 {
     DB::table('commands')->delete();
     Command::create(['name' => 'Welcome', 'script' => 'echo "Before Clone {{ release }}"', 'project_id' => 1, 'user' => 'vagrant', 'step' => Command::BEFORE_CLONE])->servers()->attach([1, 2]);
     Command::create(['name' => 'Goodbye', 'script' => 'echo "After Purge {{ release }}"', 'project_id' => 1, 'user' => 'vagrant', 'step' => Command::AFTER_PURGE])->servers()->attach([1, 2]);
 }
Пример #6
0
 public function finalizeCart(Request $request)
 {
     if (!$request->session()->has('cart')) {
         return back();
     }
     $carts = $request->session()->get('cart');
     $totalPrice = $this->getTotalPrice();
     $command = Command::create(['customer_id' => Auth::user()->id, 'commanded_at' => NULL, 'price' => $totalPrice, 'nb_product' => count($carts), 'status' => 'EN_COURS']);
     foreach ($carts as $key => $value) {
         $product = Product::find($key);
         CommandDetail::create(['command_id' => $command->id, 'product_id' => $product->id, 'price' => $product->price, 'quantity' => $value]);
     }
     $request->session()->forget('cart');
     $customer = Customer::where('user_id', Auth::user()->id)->first();
     Customer::where('user_id', Auth::user()->id)->update(['number_command' => ++$customer->number_command]);
     $title = "Confirmation of your cart";
     $message = 'Your cart has been recorded';
     $typeMessage = 'success';
     $uri = '/';
     return view('front/message', compact('title', 'message', 'typeMessage', 'uri'));
 }