2013-11-26 13:45:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Product extends Eloquent
|
|
|
|
{
|
|
|
|
protected $softDelete = true;
|
2013-11-27 08:38:37 +01:00
|
|
|
|
2013-12-03 18:32:33 +01:00
|
|
|
public function scopeScope($query)
|
2013-11-27 08:38:37 +01:00
|
|
|
{
|
2013-12-03 18:32:33 +01:00
|
|
|
return $query->whereAccountId(Auth::user()->account_id);
|
2013-11-27 08:38:37 +01:00
|
|
|
}
|
|
|
|
|
2013-12-03 18:32:33 +01:00
|
|
|
public static function findProductByKey($key)
|
2013-11-27 08:38:37 +01:00
|
|
|
{
|
2013-12-03 18:32:33 +01:00
|
|
|
return Product::scope()->where('key','=',$key)->first();
|
2013-11-27 08:38:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function getProductKeys($products)
|
|
|
|
{
|
2013-11-28 17:40:13 +01:00
|
|
|
$products = array_pluck($products, 'key');
|
2013-11-27 08:38:37 +01:00
|
|
|
$products = array_combine($products, $products);
|
|
|
|
|
|
|
|
return $products;
|
|
|
|
}
|
2013-11-26 13:45:07 +01:00
|
|
|
}
|