Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php namespace Wetzel\Aktiviteiten\Models;
- use Str;
- use Model;
- use Wetzel\Aktiviteiten\Models\Aktiviteit;
- class Aktiviteit extends Model
- {
- public $table = 'wetzel_aktiviteiten_aktiviteiten';
- protected $jsonable = ['form_data', 'registrations'];
- /*
- * Validation
- */
- use \October\Rain\Database\Traits\Validation;
- public $rules = [
- 'title' => 'required',
- 'form_data' => 'required'
- ];
- protected $guarded = [];
- public function aktiviteiten()
- {
- return $this->aktiviteiten()
- ->isPublished()
- ->orderBy('published_at', 'desc');
- }
- public function getHeaders(){
- foreach ($this->form_data as $form) {
- $headers[] = $form['label'];
- }
- return $headers;
- }
- public function aktiviteitenCount()
- {
- return $this->aktiviteiten()->count();
- }
- public function scopeIsPublished($query)
- {
- return $query
- ->whereNotNull('published')
- ->where('published', '=', 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement