#10 Promotion Modul, Kommentar 2

This commit is contained in:
Kevin Adametz 2021-11-09 18:40:18 +01:00
parent f0da981737
commit c9e1545693
128 changed files with 8194 additions and 637 deletions

View file

@ -45,6 +45,14 @@ use Illuminate\Database\Eloquent\Collection;
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereTo($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereUpdatedAt($value)
* @mixin \Eloquent
* @property int|null $type
* @property bool $shop
* @property-read Collection|\App\Models\PromotionAdminProduct[] $promotion_admin_products
* @property-read int|null $promotion_admin_products_count
* @property-read Collection|\App\Models\PromotionAdminProduct[] $promotion_admin_products_active
* @property-read int|null $promotion_admin_products_active_count
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereShop($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereType($value)
*/
class PromotionAdmin extends Model
{
@ -167,15 +175,22 @@ class PromotionAdmin extends Model
public static function getActiveAdminPromotionsAsArray(){
$query = PromotionAdmin::where('active', true)
->where(function ($query) {
$PromotionAdmins = PromotionAdmin::where('active', true)->get();
$ret = [];
foreach($PromotionAdmins as $PromotionAdmin){
$temp = $PromotionAdmin->name;
$temp .= $PromotionAdmin->from ? " | vom: ".$PromotionAdmin->from : '';
$temp .= $PromotionAdmin->to ? " | bis: ".$PromotionAdmin->to : '';
$ret[$PromotionAdmin->id] = $temp;
}
/*->where(function ($query) {
$query->where('from', '<', Carbon::now())
->orWhereNull('from');
})
->where(function ($query) {
$query->where('to', '>=', Carbon::now())
->orWhereNull('to');
});
return $query->pluck('name', 'id')->toArray();
});*/
return $ret;
}
}