unioil-mobile-api/app/CodeCity.php

54 lines
963 B
PHP

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CodeCity extends Model
{
/**
* Table name of model
*
* @var string
*/
protected $table = 'code_city';
/**
* Primary key field name of table
*
* @var string
*/
protected $primaryKey = 'city_id';
/**
* Additional fields from other connected tables
*
* @var array
*/
protected $appends = [];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = ['city_id'];
// public function province()
// {
// return $this->hasOne('App\CodeProvince','province_id','province_id');
// }
public function station()
{
return $this->hasMany('App\Station','city_id','city_id');
}
public function scopeUuid($query,$uuid)
{
$query->where('is_active',1);
$query->where('city_uuid',$uuid);
}
}