blessing-skin-server/app/Models/Texture.php

33 lines
715 B
PHP
Raw Normal View History

2016-07-21 22:01:57 +08:00
<?php
namespace App\Models;
2016-10-23 11:41:52 +08:00
use Illuminate\Database\Eloquent\Model;
class Texture extends Model
2016-07-21 22:01:57 +08:00
{
public $primaryKey = 'tid';
public $timestamps = false;
public static function checkTextureOccupied($tid)
{
$skin_type_map = ["steve", "alex", "cape"];
for ($i = 0; $i <= 2; $i++) {
2016-10-16 18:16:15 +08:00
if (Player::where('tid_'.$skin_type_map[$i], $tid)->count() > 0)
2016-07-21 22:01:57 +08:00
return true;
}
return false;
}
public function setPrivacy($public)
{
$this->public = $public ? "1" : "0";
return $this->save();
}
public function scopeLike($query, $field, $value)
{
return $query->where($field, 'LIKE', "%$value%");
}
}