<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;


class Pendaftar extends Model
{
     /**
     * The database table used by the model.
     *
     * @var string
     */
    use SoftDeletes;
    protected $table = 't_pendaftar';
    protected $dates = ['deleted_at'];
    protected $fillable = ['no_pendaftar','nama','jeniskelamin','tempatlahir','tanggallahir','agama','alamat','kebutuhan_khusus','no_hp','user_id'];
    /**
    * The database primary key value.
    *
    * @var string
    */
    protected $primaryKey = 'id';

    public function user(){
        return $this->belongsTo('App\User','user_id');
    }

    public function periodiks(){
        return $this->belongsTo('App\Models\Pendaftar', 'id_pendaftar');
    }

    public function prestasis(){
        return $this->hasMany('App\Models\Prestasis', 'id_pendaftar');
    }
    
    public function tahun(){
        return $this->hasOne('App\Models\Tahunajaran','thnajaran_id','id');
    }

    public function ruang(){
        return $this->hasOne('App\Models\Ruang','ruang_id','id');
    }

   }
