Fix missing likes
field
This commit is contained in:
parent
3a147c8ec4
commit
13fade2773
@ -151,7 +151,7 @@ class SkinlibController extends Controller
|
||||
public function info($tid)
|
||||
{
|
||||
if ($t = Texture::find($tid)) {
|
||||
return json(array_merge($t->toArray(), ['likes' => $t->likes]));
|
||||
return json($t->toArray());
|
||||
} else {
|
||||
return json([]);
|
||||
}
|
||||
|
@ -9,11 +9,6 @@ class Texture extends Model
|
||||
public $primaryKey = 'tid';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'tid' => 'integer',
|
||||
'size' => 'integer',
|
||||
@ -21,6 +16,10 @@ class Texture extends Model
|
||||
'public' => 'boolean',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'likes'
|
||||
];
|
||||
|
||||
public function getLikesAttribute()
|
||||
{
|
||||
return $this->likers()->count();
|
||||
|
Loading…
Reference in New Issue
Block a user