/** @test **/ public function it_destroys_the_given_an_existing_model() { $this->createPostsTable(); $this->insertOn('posts', ['title' => 'House', 'content' => 'Repeating']); $this->insertOn('posts', ['title' => 'Sherlock', 'content' => 'Elementary Watson.']); $this->insertOn('posts', ['title' => 'Psych!', 'content' => 'Repeating']); $this->assertEquals(3, Object::count()); Post::find(2)->destroy(); $this->assertEquals(2, Object::count()); }
/** * Convert the eloquent 'object' into an alchemy model. * * @param Object $object * @return Model */ public function transformObjectToModel(Object $object) { $object->load('values', 'values.attribute'); $attributes = []; foreach ($object->values as $value) { $attributes[$value->attribute->name] = $value->content; } return $this->newAlchemyModel($attributes, $object->id); }