Exemplo n.º 1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function getDelete($id, $c_id = null)
 {
     $id = $c_id ? $c_id : $id;
     $phone_number = PhoneNumber::find($id);
     $phone_number->delete();
     Event::fire('logger', array(array('phone_number_remove', array('id' => $id, 'extension' => $phone_number->extension), 2)));
     $path = Request::segment(2) == "manage" ? "manage/" . Request::segment(3) : "";
     return Output::push(array('path' => 'phone_number/' . $path, 'messages' => array('success' => _('Phone number  has been deleted'))));
 }
Exemplo n.º 2
0
 OrmTest::assertTrue('Testing fetching object by id on new object.', $user->getName() === $name);
 $users = User::select('1=?', 1);
 OrmTest::assertTrue('Testing fetching objects by select() method.', count($users) === 4 and $users->current()->getName() !== '');
 OrmTest::assertTrue('Testing array access by id of results set.', $users[$id]->getName() !== '');
 $users = User::find(array('active' => 1));
 OrmTest::assertTrue('Testing fetching objects by find() method.', count($users) === 4 and $users->current()->getName() !== '');
 $user = User::one(array('name' => 'Jason'));
 OrmTest::assertTrue('Testing fetching object by one() method.', $user->getName() === 'Jason');
 $phone = $user->create(new PhoneNumber(array('type' => 'home', 'number' => '607-000-0000')));
 OrmTest::assertTrue('Testing create new object through create() method.', $phone instanceof PhoneNumber and $phone->getUserId() === $user->getId());
 foreach (array(111, 222, 333, 444, 555) as $prefix) {
     $user->create(new PhoneNumber(array('type' => 'home', 'number' => '607-' . $prefix . '-0000', 'location' => null)))->save();
 }
 OrmTest::assertTrue('Loading records to test method appication to entire results set.', true);
 PhoneNumber::select('`number` like "607%" and `location` IS NULL order by `number`')->setLocation('Ithaca, NY')->setType('Cell Phone')->save();
 $phones = PhoneNumber::find(array('location' => 'Ithaca, NY', 'type' => 'Cell Phone'));
 OrmTest::assertTrue('Checking to see if method application applied correctly.', count($phones) === 5);
 OrmTest::assertTrue('Testing getRelationClassName style magic method (singular).', $user->getPhoneNumber()->getLocation() === 'Ithaca, NY');
 OrmTest::assertTrue('Testing getRelationClassName style magic method (list) .', count($user->getPhoneNumber(true)) === 5 and $user->getPhoneNumber(true)->current()->getLocation() === 'Ithaca, NY');
 OrmTest::assertTrue('Testing getRelationClassName style magic method (custom) .', $user->getPhoneNumber('`number` like ?', "%111%")->current()->getNumber() === '607-111-0000');
 $post = $user->create(new Post(array('title' => 'test post', 'body' => "I ain't got no body..")));
 $post->addMeta(array('background' => 'blue', 'border' => '1px solid grey'));
 $post->setMeta('border', '2px solid white');
 OrmTest::assertTrue('Testing addMeta(), setMeta() and getMeta() methods.', $post->getMeta('background') === 'blue' and $post->getMeta('border') === '2px solid white');
 $post->save();
 $post = $user->getPost();
 OrmTest::assertTrue('Testing getMeta() methods after save().', $post->getMeta('background') === 'blue' and $post->getMeta('border') === '2px solid white');
 $post->delete();
 OrmTest::assertTrue('Testing delete() method on an object.', count($user->getPost(true)) === 0);
 OrmTest::assertTrue('Testing complete. (' . OrmTest::$fails . ' fails)', !OrmTest::$fails);
 Db::execute("drop database {$dbname}");