<?php

namespace App\Models;

use App\User;
use App\Models\Categories;
use App\Models\Suppliers;
use App\Models\Coupon;
use App\Models\Status;
use App\Models\Report;
use App\Models\Payments;
use App\NoHome;
use Illuminate\Database\Eloquent\Model;
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;

class FinishedContracts extends Model
{
    //
    use SpatialTrait;

    protected $fillable = [
        'user_id',
        'supplier_id',
        'category_id',
        'address',
        'int_number',
        'references',
        'appointment',
        'amount',
        'details',
        'code',
        'coupon_id',
        'transaction_id',
        'score',
        'status_id',
    ];

    protected $spatialFields = [
        'location',
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function categories()
    {
        return $this->belongsTo('App\Models\Categories', 'category_id');
    }

    public function suppliers()
    {
        return $this->belongsTo('App\Models\Suppliers', 'supplier_id');
    }

    public function coupon()
    {
        return $this->belongsTo(Coupon::class);
    }

    public function status()
    {
        return $this->belongsTo(Status::class);
    }

    public function payments()
    {
        return $this->hasOne(Payments::class);
    }

    public function reports()
    {
        return $this->hasOne(Report::class);
    }

    public function nohome()
    {
        return $this->hasOne(NoHome::class);
    }

}
