/** * 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); }
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); }
/** * 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); } }
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]); }
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')); }
public function commandDetail($id) { $command = Command::find($id); return view('admin/command/commandDetail', ['title' => 'Command n°' . $command->id, 'commandDetails' => $command->commandDetails()->with('product')->get(), 'price' => $command->price]); }
public function setCommand(Command $cmd) { $this->command = $cmd->__toString(); }
if ($parameters === null) { return; } if (!is_array($parameters)) { throw new CommandParserException('"parameters" must be an array. ' + $parameters); } // all parameters must contain only numbers if (!array_reduce($parameters, function ($acc, $item) { return $acc && self::valid($item); }, true)) { throw new CommandParserException('Command parameters must be numeric'); } // parameters must be at most 'arduino.max_command_parameters' if (count($parameters) > self::$PARAMETERS_LENGTH) { throw new CommandParserException('Command parameters must be at most ' . self::$PARAMETERS_LENGTH); } $this->parameters = $parameters; } public function __toString() { $str = $this->key; if (!empty($this->parameters)) { $str .= self::$COMMAND_FIELD_SEPARATOR; $str .= implode(self::$COMMAND_FIELD_SEPARATOR, $this->parameters); } $str .= self::$COMMAND_TERMINATOR; return $str; } } Command::init();