public function run() { $attributes = Site\Admin\Models\Attribute::all()->first(); $types = Site\Admin\Models\Type::all()->first(); $typeAttributes = Site\Admin\Models\TypeAttribute::all()->first(); if (!is_null($attributes) && !is_null($types) && is_null($typeAttributes)) { $type = Site\Admin\Models\Type::where('name', '=', 'Insurance')->get()->first(); $attributes = array(); array_push($attributes, Site\Admin\Models\Attribute::where('name', '=', 'Monthly cost')->get()->first()); array_push($attributes, Site\Admin\Models\Attribute::where('name', '=', 'Annual cost')->get()->first()); array_push($attributes, Site\Admin\Models\Attribute::where('name', '=', 'Quality score')->get()->first()); foreach ($attributes as $attribute) { Site\Admin\Models\TypeAttribute::create(array('type_id' => $type->id, 'attribute_id' => $attribute->id)); } $type = Site\Admin\Models\Type::where('name', '=', 'Smart phone')->get()->first(); $attributes = array(); array_push($attributes, Site\Admin\Models\Attribute::where('name', '=', 'Cost')->get()->first()); array_push($attributes, Site\Admin\Models\Attribute::where('name', '=', 'Quality score')->get()->first()); foreach ($attributes as $attribute) { Site\Admin\Models\TypeAttribute::create(array('type_id' => $type->id, 'attribute_id' => $attribute->id)); } $type = Site\Admin\Models\Type::where('name', '=', 'Game console')->get()->first(); foreach ($attributes as $attribute) { Site\Admin\Models\TypeAttribute::create(array('type_id' => $type->id, 'attribute_id' => $attribute->id)); } $type = Site\Admin\Models\Type::where('name', '=', 'Tablet computer')->get()->first(); foreach ($attributes as $attribute) { Site\Admin\Models\TypeAttribute::create(array('type_id' => $type->id, 'attribute_id' => $attribute->id)); } } }
public function run() { $attributes = Site\Admin\Models\Attribute::all()->first(); if (is_null($attributes)) { Site\Admin\Models\Attribute::create(array('name' => 'Monthly cost', 'alias' => 'monthlyCost')); Site\Admin\Models\Attribute::create(array('name' => 'Annual cost', 'alias' => 'annualCost')); Site\Admin\Models\Attribute::create(array('name' => 'Cost', 'alias' => 'cost')); Site\Admin\Models\Attribute::create(array('name' => 'Quality score', 'alias' => 'qualityScore')); } }