/** * @before */ protected function seedDatabase() { // set the standard models in the default scope parent::seedDatabase(); // several models outside of the default scope for ($x = 0; $x < 3; $x++) { $this->createNewStandardModel(['name' => 'model (outside of scope) ' . ($x + 1), 'scope' => 0]); } }
/** * @before */ protected function seedDatabase() { // set the standard models in the default scope parent::seedDatabase(); // flag all models as inactive foreach (TestModelWithGlobalScope::all() as $model) { $model->active = false; $model->save(); } // assert that we did in fact 'hide' them $this->assertEquals(0, TestModelWithGlobalScope::count(), "Setup failed for global scoped models"); }
/** * @before */ protected function seedDatabase() { // first we require related models to be able to set foreign keys for for ($x = 0; $x < 3; $x++) { TestRelatedModel::create(['name' => 'related ' . ($x + 1)]); } // set the standard models in the default scope parent::seedDatabase(); // several models outside of the default scope for ($x = 0; $x < 4; $x++) { $model = $this->makeNewStandardModel(['name' => 'model (outside of scope) ' . ($x + 1), 'test_related_model_id' => 1]); if ($x < 2) { $model->testRelatedModel()->associate(TestRelatedModel::find(1)); } $model->save(); } }
/** * @before */ protected function seedDatabase() { parent::seedDatabase(); // 1 model outside of the applicable scopes for ($x = 0; $x < 1; $x++) { $this->createNewModelWithCallableScope(['name' => 'model (null scope) ' . ($x + 1), 'scope' => null]); } // 2 models outside with scope '1' for ($x = 0; $x < 2; $x++) { $this->createNewModelWithCallableScope(['name' => 'model (scope 1) ' . ($x + 1), 'scope' => 1]); } }