<?php

namespace App\Models\Graphics;

use Illuminate\Database\Eloquent\Model;

class Shape extends Model
{
    //
    // explicitly define tables
    protected $table = 'shapes';

    protected $fillable = [
        'owner_id', 'name','description', 'data', 'svg', 'type'
    ];

    public function path()
    {
        return \url('/shapes') . '/' . $this->id;
    }

    // clipart owner
    public function owner()
    {
        return $this->hasOne('App\Models\Auth\User', 'id', 'owner_id');
    }

    // get only polygons
    public function scopePolygons($query)
    {
        return $query->where('type', 'polygon');
    }

}
