Skip to content

Instantly share code, notes, and snippets.

@mariowhowrites
Created February 27, 2018 20:37
Show Gist options
  • Save mariowhowrites/a98e597ece59e2e233dd5cd26b02432e to your computer and use it in GitHub Desktop.
Save mariowhowrites/a98e597ece59e2e233dd5cd26b02432e to your computer and use it in GitHub Desktop.
class RemoveCoinCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'remove';
/**
* Execute the console command.
*
* @return void
*/
public function handle($arguments)
{
if (empty($arguments)) {
$this->replyWithMessage(['text' => 'Please enter a coin.']);
return;
}
$coin = Coin::find([$arguments])->first();
if ($coin) {
$coin->active = false;
$coin->save();
}
$message = $coin ? "Purged! $coin->ticker has been mercilessly removed from the list." : "No coin on the list by that ticker. Did you mean to add?";
$this->replyWithMessage(['text' => $message]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment