<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Item extends Model
{
    public static function explodeItems($items)
    {
        $array_items = explode("-",$items);
        $col_items = collect();

        foreach ($array_items as $item) {
            $col_items->push(Item::find($item));
        }
        $col_items->forget(0);
        return $col_items;
    }

    protected $casts = [
        'metadata' => 'array',
    ];

    public function bookings()
    {
        return $this->hasMany('App\Booking');
    }

    public function category()
    {
        return \App\ItemCategory::find($this->category_id);
    }
}
