/**
  * Setup initial data for use in tests
  */
 public function setup()
 {
     parent::setup();
     $this->seed('RedminSeeder');
     // Add membership
     $membership = new Membership();
     $membership->name = "Gold";
     $membership->rank = 5;
     $membership->save();
     // Add module
     $module = new Module();
     $module->name = 'This is title';
     $module->sku = 'UNIQUESKU001';
     $module->short_description = 'This is body';
     $module->long_description = 'This is long body';
     $module->featured = true;
     $module->active = true;
     $module->category_id = 1;
     $module->save();
     // Create a new Pricelist for use later
     $pricelist = new Pricelist();
     $pricelist->price = 0;
     $pricelist->module_id = 1;
     $pricelist->membership_id = 1;
     $pricelist->save();
 }
 /**
  * Setup initial data for use in tests
  */
 public function setup()
 {
     parent::setup();
     // Add membership
     $membership = new Membership();
     $membership->name = "Gold";
     $membership->rank = 5;
     $membership->save();
     // Add module
     $module = new Module();
     $module->name = 'This is title';
     $module->sku = 'UNIQUESKU001';
     $module->short_description = 'This is body';
     $module->long_description = 'This is long body';
     $module->featured = true;
     $module->active = true;
     $module->category_id = 1;
     $module->save();
     // Create a new Pricelist for use later
     $pricelist = new Pricelist();
     $pricelist->module_id = 1;
     $pricelist->membership_id = 1;
     $pricelist->price = 1;
     $pricelist->save();
     // Create a new Product for use later
     $product = new Product();
     $product->name = 'This is the title';
     $product->sku = 'UNIQUESKU001';
     $product->short_description = 'This is the body';
     $product->category_id = 1;
     $product->active = true;
     $product->save();
     // Create a new Category for use later
     $category = new Category();
     $category->name = 'This is a name';
     $category->short_description = 'This is short description';
     $category->long_description = 'This is long description';
     $category->active = true;
     $category->order = 1;
     $category->save();
 }
 public function getDelete($sid)
 {
     // Find the module using the user id
     $module = Module::find($sid);
     if ($module == null) {
         $errors = new \Illuminate\Support\MessageBag();
         $errors->add('deleteError', "We are having problem deleting this entry. Please try again.");
         return \Redirect::to('admin/modules')->withErrors($errors);
     }
     $purchases = UserPricelist::join('pricelists', 'pricelists.id', '=', 'user_pricelists.pricelist_id')->where('pricelists.module_id', $sid)->get();
     if (count($purchases) > 0) {
         $errors = new \Illuminate\Support\MessageBag();
         $errors->add('deleteError', "This module has been purchased before. You cannot delete it. Please change disable it instead.");
         return \Redirect::to('admin/modules')->withErrors($errors);
     }
     // Delete the module
     $module->delete();
     return \Redirect::to('admin/modules');
 }