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;
|
|
|
|
|
2018-02-23 09:51:23 +08:00
|
|
|
/**
|
|
|
|
* The attributes that should be cast to native types.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $casts = [
|
|
|
|
'tid' => 'integer',
|
|
|
|
'likes' => 'integer',
|
|
|
|
'size' => 'integer',
|
|
|
|
'uploader' => 'integer',
|
|
|
|
'public' => 'integer',
|
|
|
|
];
|
|
|
|
|
2016-07-21 22:01:57 +08:00
|
|
|
public function setPrivacy($public)
|
|
|
|
{
|
|
|
|
$this->public = $public ? "1" : "0";
|
|
|
|
return $this->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function scopeLike($query, $field, $value)
|
|
|
|
{
|
|
|
|
return $query->where($field, 'LIKE', "%$value%");
|
|
|
|
}
|
|
|
|
}
|