<?php
/**
 * Created by PhpStorm.
 * User: jmartinez
 * Date: 5/12/2017
 * Time: 1:26 PM
 */

namespace Hilco\Models;
/**
 * @deprecated defunct promo action, has never been implemented or used
 */
class PromotionJobsonProfileTrigger extends PromotionTriggerDetails {
    protected $table = 'PromotionJobsonProfileTriggers';

    public function jobsonProfiles() {
        return $this->belongsToMany(JobsonData::class, 'PromotionJobsonProfileTrigger_JobsonData', 'promotionjobsonprofiletrigger_id', 'jobsondata_id');
    }

    public function isTriggered(Customer $soldToCustomer, $webCartItems, $distinctPartInfo = [])
    {
        $jobsonDatasForSoldTo = $soldToCustomer->jobsonDatas;
        $soldToJobsonids = $jobsonDatasForSoldTo->pluck('id');
        $triggerJobsonDatas = $this->jobsonProfiles;
        $triggerJobsonDataIds = $triggerJobsonDatas->pluck('id');
        $intersect = $triggerJobsonDataIds->intersect($soldToJobsonids);
        return $intersect->isEmpty();
    }

    public function postTriggerOperation($soldToCustomer)
    {
        // TODO: Implement postTriggerOperation() method.
    }
}