<?php

namespace App;

class Sale extends Master
{
  protected $appends = ['status_display'];

  protected $table='sales';

  protected $fillable = array('folio', 'total', 'status');

  protected $hidden = ['created_at','updated_at'];

  const PENDING = 1;
  const APPROVED = 2;
  const CANCELLED = 3;
  const PAID = 4;

  public function getStatusDisplayAttribute()
  {
    switch ($this->status) {
      case 1:
      return 'PENDING';
      case 2:
      return 'APPROVED';
    }
  }

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