HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/punjabcabs/app/ProviderService.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class ProviderService extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'service_type_id', 'taxi_type', 'fleet_id', 'provider_id', 'status','service_model','service_number','service_type_id','license_number','license_expire','insurance_number','insurance_expire','certificate_number','certificate_expire','license_status','insurance_status','certificate_status'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'created_at', 'updated_at'
    ];

    /**
     * The services that belong to the user.
     */
    public function provider()
    {
        return $this->belongsTo('App\Provider');
    }

    public function fleet()
    {
        return $this->belongsTo('App\Fleet');
    }
    
    public function service_type()
    {
        return $this->belongsTo('App\ServiceType');
    }

    public function scopeCheckService($query, $provider_id, $service_id)
    {
        return $query->where('provider_id' , $provider_id)->where('service_type_id' , $service_id);
    }

    public function scopeAvailableServiceProvider($query, $service_id)
    {
        return $query->where('service_type_id', $service_id)->where('status', 'active');
    }

    public function scopeAllAvailableServiceProvider($query)
    {
        return $query->where('status', 'active');
    }
    public function scopeActiveServiceProvider($query)
    {
        return $query->where('status','active');
    }
}