<?php

namespace Database;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Capsule\Manager as DB;

class Shop extends Model
{
    protected $table = 'shop';

    public static function getItems()
    {
        return DB::table('shop')->get();
    }

    public static function getItemsByiId($id)
    {
        return DB::table('shop')->where('id', $id)->first();
    }

    public static function getItemByCoin($coin)
    {
        return DB::table('shop')->where('coin', $coin)->get();
    }


    public static function hasItem($coin, $price)
    {
        return DB::table('shop')->where('coin', $coin)->where('price', $price)->exists();
    }


    public static function addItem($coin, $price)
    {
        return DB::table('shop')->insertGetId(['coin' => $coin, 'price' => $price]);
    }

    public static function updateHot($id, $values)
    {
        DB::table('shop')->where('id', $id)->update(['hot' => $values]);
        return true;
    }

    public static function removeItem($id)
    {
        return DB::table('shop')->where('id', $id)->delete();
    }
}
