bztang-admin/app/common/models/Address.php

54 lines
971 B
PHP

<?php
namespace app\common\models;
/**
* Created by PhpStorm.
* Author:
* Date: 2017/2/27
* Time: 上午9:11
*/
class Address extends BaseModel
{
public $timestamps = false;
public $table = 'yz_address';
protected $guarded = [''];
protected $fillable = [''];
public static function getProvince()
{
return self::where('level', '1')->get();
}
public static function getCityByParentId($parentId)
{
return self::where('parentid', $parentId)
->where('level', '2')
->get();
}
public static function getAreaByParentId($parentId)
{
return self::where('parentid', $parentId)
->where('level', '3')
->get();
}
public static function getAddress($data)
{
return self::whereIn('id', $data)
->get();
}
public function hasOneParent()
{
return $this->hasOne(self::class, 'id', 'parentid');
}
}