123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- namespace app\admin\model;
- use support\Db;
- use support\Model;
- /**
- * 地块模型
- * Class Users
- * @package app\admin\model
- */
- class LifeFarmLand extends Model
- {
- const ROLE_STATUS = 1;
- const IS_DEL_YES = 1;
- const IS_DEL_NO = 0;
- const GOODS_IS_SHOW = [
- self::IS_DEL_YES => '已删除',
- self::IS_DEL_NO => '未删除'
- ];
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'life_farm_land';
- public $timestamps = false;
- /**
- * Notes:获取地块列表
- * @param string $keywords
- * @param int $page
- * @param int $limit
- * @return array
- * User: YCP
- * Date: 2022/10/17
- */
- public static function getLandList(int $page, int $limit, string $keywords)
- {
- $list = static::select('*')
- ->where(['land_is_del'=>static::IS_DEL_NO])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('land_name', 'like', '%' . $keywords . '%');
- })
- ->orderBy('land_create_time','DESC')
- ->forPage($page, $limit)
- ->get();
- $count = static::where(['land_is_del'=>static::IS_DEL_NO])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('land_name', 'like', '%' . $keywords . '%');
- })
- ->count();
- return [$list, $count];
- }
- /**
- * Notes:获取地块列表
- * @return array
- * User: YCP
- * Date: 2022/10/17
- */
- public static function getLandAll()
- {
- $list = static::select(['land_id','land_name'])
- ->where(['land_is_del'=>static::IS_DEL_NO])
- ->orderBy('land_create_time','DESC')
- ->get();
- return $list;
- }
- /**
- * Notes:获取地块名称
- * @param string $account
- * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
- * User: YCP
- * Date: 2022/10/17
- */
- public static function landMation($admin_land)
- {
- $where = [];
- $where['land_is_del'] = static::IS_DEL_NO;
- $mation = static::where($where)
- ->when($admin_land != '', function ($query) use ($admin_land){
- $query->whereIn('land_id', $admin_land);
- })
- ->get('land_name');
- return $mation;
- }
- /**
- * Notes:检测地块名是否存在
- * @param $doctor_name
- * @param $doctor_mobile
- * @return bool
- * User: YCP
- * Date: 2022/10/17
- * 验证条件:地块名存在的情况下
- */
- public static function checkLandName($land_name)
- {
- return static::where(['land_name' => $land_name, 'land_is_del' => static::IS_DEL_NO])->exists();
- }
- /**
- * Notes:检测坐标是否存在
- * @param $doctor_name
- * @param $doctor_mobile
- * @return bool
- * User: YCP
- * Date: 2022/10/17
- * 验证条件:经度纬度同时存在的情况下
- */
- public static function checkLandPoint($land_longitude,$land_latitude)
- {
- return static::where(['land_longitude' => $land_longitude, 'land_latitude' => $land_latitude, 'land_is_del' => static::IS_DEL_NO])->exists();
- }
- }
|