<?php

namespace App\Models;

use App\Models\Siparisler;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class Uyeler extends Authenticatable
{
    protected $table = 'uyelers';


    use HasApiTokens, HasFactory, Notifiable;
    protected $guard="uye";

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'name',
        'email',
        'username',
        'password',
        'profile_image',
        'google_id',
        'username',
        'facebook_id',
        'telefon',
        'surname',
        'faturaadres',
        'tckimlik',
        'adres',
        'il',
        'ilce',
        'bayimi',
        'iskonto',
        'active',
        'mailonay',
        'bakiye',
        'vergi_dairesi',
        'vergi_numarasi',
    ];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var array<int, string>
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];





    public function siparisler()
    {
        return $this->hasMany('App\Models\Siparisler', 'kullanici_id', 'id')->latest();

    }


    public function sonsiparisler()
    {
        return $this->hasMany('App\Models\Siparisler', 'kullanici_id', 'id')->latest()->limit(1);

    }

    public function talepler()
    {
        return $this->hasMany('App\Models\Destektalep', 'kullanici_id', 'id')->latest();

    }

    public function sontalepler()
    {
        return $this->hasMany('App\Models\Destektalep', 'kullanici_id', 'id')->latest()->limit(1);

    }


}
