<?php

  class User extends ContentTypeModel
  {
    use LanguageSupportTrait;

    protected $hidden = ['languages', "websites"];
    protected $with = ['languages', "websites"];

    public function submissions()
    {
      return $this->hasMany("Submission");
    }

    public function submission() {
      return $this->hasOne("Submission");
    }

    public function donations()
    {
      return $this->hasMany("Donation");
    }

    public function tracking()
    {
      return $this->hasOne("Tracking");
    }

    public function scopeEmail($query, $email)
    {
      return $query->where('email', $email);
    }

    // this is a recommended way to declare event handlers
    protected static function boot()
    {
      parent::boot();

      static::deleting(function ($user) { // before delete() method call this
        $user->submissions()->delete();
        // do the rest of the cleanup...
      });
    }

  }
