title: Scopes in Yii - enforcing a pattern on new models
body: <p>For some models, we have soft deletion implemented using a <code>valid</code> boolean in MySQL.</p>
  
  <p>In the class, the scopes method is defined as follows:</p>
  
  <pre><code>public function scopes() {
      return array(
          'valid'=&gt;array(
              'condition'=&gt;"t.valid=1",
          )
      );
  }
  </code></pre>
  
  <p>This is so that when we load a model we can call the scope to make it include only valid (not deleted) models alongside the other find criteria, or whatever it happens to be.</p>
  
  <p>This isn't very DRY and I am wondering if there is an alternative way of achieving the same thing, that could perhaps be applied to an interface, the abstract Model class that all models derive from, or, if using 5.4, a trait.</p>