Exemple #1
0
 /**
  * Fire command
  *
  * @return void
  * @author Dan Cox
  */
 public function fire()
 {
     try {
         $first = $this->input->getArgument('first');
         $last = $this->input->getArgument('last');
         $email = $this->input->getArgument('email');
         $phone = $this->input->hasOption('phone') ? $this->input->getOption('phone') : NULL;
         $contact = new Contact();
         $contact->first = $first;
         $contact->last = $last;
         $contact->email = $email;
         $contact->phone = $phone;
         $contact->createdAt = new \DateTime("NOW");
         $contact->updatedAt = new \DateTime("NOW");
         $contact->save();
         $this->output->writeln("Successfully saved new contact");
     } catch (\Exception $e) {
         $this->output->writeln("There was an issue saving this contact:");
         $this->output->writeln($e->getMessage());
     }
 }
Exemple #2
0
 /**
  * Fire the command
  *
  * @return void
  * @author Dan Cox
  */
 public function fire()
 {
     $email = $this->input->getArgument('email');
     // Check if the contact exists
     if (Contact::exists($email, 'email')) {
         try {
             $contact = Contact::db()->first(['email', $email]);
             $contact->delete();
             $this->output->writeln("Successfully removed contact");
         } catch (\Exception $e) {
             $this->output->writeln("Failed removing contact from database:");
             $this->output->writeln($e->getMessage());
         }
     } else {
         $this->output->writeln("Contact with email {$email} does not exist");
     }
 }