/**
  * @param $book
  * @param $city
  */
 protected function createAuthor($book, $city)
 {
     $author = new Models\Author(['name' => 'Author 1']);
     $author->save();
     $author->books()->save($book);
     $author->city()->associate($city);
     $author->save();
 }
 public function test_search_on_model_without_eloquence_trait()
 {
     $this->populateDatabase();
     $model = new Models\Author();
     $query = $model->query();
     $data = ['q' => 'Another Cat'];
     $modifier = $this->getSearchModifierInstance($query, $data);
     $this->setExpectedException(Exception::class);
     $modifier->modify($query);
 }
 public function test_does_add_required_fields_for_belongs_to_relation()
 {
     $this->populateDatabase();
     $model = new Models\Author();
     $query = $model->query()->with('city');
     $modifier = $this->_getInstance($query, ['fields' => 'name']);
     $modifier->modify($query);
     $reqFields = $modifier->addRequiredFields(['name']);
     $this->assertEquals(2, count($reqFields));
     $this->assertContains('city_id', $reqFields);
     $this->assertContains('name', $reqFields);
     $this->assertEquals(1, count($query->find(1)->city));
 }