Guest User

Untitled

a guest
Aug 21st, 2015
147
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php namespace Wetzel\Aktiviteiten\Models;
  2.  
  3. use Str;
  4. use Model;
  5. use Wetzel\Aktiviteiten\Models\Aktiviteit;
  6.  
  7. class Aktiviteit extends Model
  8. {
  9.     public $table = 'wetzel_aktiviteiten_aktiviteiten';
  10.     protected $jsonable = ['form_data', 'registrations'];
  11.  
  12.     /*
  13.      * Validation
  14.      */
  15.     use \October\Rain\Database\Traits\Validation;
  16.     public $rules = [
  17.         'title' => 'required',
  18.         'form_data' => 'required'
  19.     ];
  20.  
  21.     protected $guarded = [];
  22.  
  23.     public function aktiviteiten()
  24.     {
  25.         return $this->aktiviteiten()
  26.                     ->isPublished()
  27.                     ->orderBy('published_at', 'desc');
  28.     }
  29.  
  30.     public function getHeaders(){
  31.         foreach ($this->form_data as $form) {
  32.             $headers[] = $form['label'];
  33.         }
  34.         return $headers;
  35.     }
  36.  
  37.     public function aktiviteitenCount()
  38.     {
  39.         return $this->aktiviteiten()->count();
  40.     }
  41.  
  42.     public function scopeIsPublished($query)
  43.     {
  44.         return $query
  45.             ->whereNotNull('published')
  46.             ->where('published', '=', 1);
  47.     }
  48.  
  49. }
RAW Paste Data