Exemplo n.º 1
0
 static function goal()
 {
     return Tier::where('type', 'Goal');
 }
 function import_tier()
 {
     $o = $this->o;
     $pt = Tier::where('ref', $o->ref)->where('type', $o->type)->first();
     if (!$pt) {
         $pt = new Tier();
     }
     $pt->ref = $o->ref;
     $pt->type = $o->type;
     $pt->name = $o->name;
     $pt->banner = $this->process_image($o->banner_url, 'tier_banners');
     $pt->se_title = $o->se_title;
     $pt->se_description = $o->se_description;
     $pt->url_slug = $o->url_slug;
     $pt->save();
     TierDescription::where('tier_id', $pt->id)->delete();
     for ($i = 1; $i <= 3; $i++) {
         $ptd = new TierDescription();
         $title_field = "title_{$i}";
         if (!$o->{$title_field}) {
             continue;
         }
         $ptd->title = $o->{$title_field};
         $content_field = "content_{$i}";
         if (!$o->{$content_field}) {
             $this->errors[] = sprintf("Cannont have empty %s in Product Tier %s %s (row %d). Skipping attribute.", $content_field, $o->ref, $o->type, $this->idx);
             continue;
         }
         $ptd->content = $o->{$content_field};
         $ptd->tier_id = $pt->id;
         $ptd->save();
     }
 }