<?php

namespace Hilco\Models;
use Hilco\SoftDeletes;

/**
 * Hilco\Models\CustomerDiscount
 *
 * @property mixed $id
 * @property string $cust_no
 * @property mixed $customer_id
 * @property string $prod_fam
 * @property string $part_no
 * @property mixed $part_id
 * @property float $disc_val
 * @property string $date_created
 * @property string $date_modified
 * @property string $deleted_at
 * @property-read mixed $id_string
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount whereId($value)
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount whereCustNo($value)
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount whereCustomerId($value)
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount whereProdFam($value)
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount wherePartNo($value)
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount wherePartId($value)
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount whereDiscVal($value)
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount whereDateCreated($value)
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount whereDateModified($value)
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount whereDeletedAt($value)
 * @mixin \Eloquent
 * @property mixed $productfamily_id
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount whereProductfamilyId($value)
 * @property string $date_uploaded
 * @method static \Illuminate\Database\Query\Builder|\Hilco\Models\CustomerDiscount whereDateUploaded($value)
 */
class CustomerDiscount extends UuidModel {
	protected $table = 'CustomerDiscounts';

    use SoftDeletes;

    public function scopeForPart($query, Part $part) {
        return $query->where(function ($query) use ($part) {
            return $query
                ->where('productfamily_id', '=', $part->productfamily_id)
                ->orWhere('part_id', '=', $part->id)
            ;
        });
    }
}
