public function run()
 {
     /* WidgetDescriptor: Update or create all */
     /* Personal widgets */
     WidgetDescriptor::updateOrCreate(['name' => 'Clock'], array('name' => 'Clock', 'description' => 'A simple clock', 'type' => 'clock', 'category' => 'personal', 'is_premium' => FALSE));
     WidgetDescriptor::updateOrCreate(['name' => 'Quotes'], array('name' => 'Quotes', 'description' => 'Get inspired every day, by this awesome widget.', 'type' => 'quote', 'category' => 'personal', 'is_premium' => FALSE));
     WidgetDescriptor::updateOrCreate(['name' => 'Greetings'], array('name' => 'Greetings', 'description' => 'Wouldn\'t it be great to receive a greeting message from your favourite browser every time you open a new tab?', 'type' => 'greetings', 'category' => 'personal', 'is_premium' => FALSE));
     WidgetDescriptor::updateOrCreate(['name' => 'Reminder'], array('name' => 'Reminder', 'description' => '', 'type' => 'reminder', 'category' => 'personal', 'is_premium' => FALSE));
     WidgetDescriptor::updateOrCreate(['name' => 'Iframe'], array('name' => 'Iframe', 'description' => 'Include your favourite sites into this dashboard.', 'type' => 'iframe', 'category' => 'personal', 'is_premium' => FALSE));
     WidgetDescriptor::updateOrCreate(['name' => 'Note'], array('name' => 'Note', 'description' => '', 'type' => 'note', 'category' => 'personal', 'is_premium' => FALSE));
     WidgetDescriptor::updateOrCreate(['name' => 'Timer'], array('name' => 'Timer', 'description' => 'A simple timer', 'type' => 'timer', 'category' => 'personal', 'is_premium' => FALSE));
     WidgetDescriptor::updateOrCreate(['name' => 'Todo list'], array('name' => 'Todo list', 'description' => 'Orgainze your daily/wekkly todos in this widget', 'type' => 'todo_list', 'category' => 'personal', 'is_premium' => FALSE));
     /* Financial widgets | STRIPE */
     WidgetDescriptor::updateOrCreate(['name' => 'Stripe MRR'], array('name' => 'Stripe MRR', 'description' => 'Stripe Monthly recurring revenue', 'type' => 'stripe_mrr', 'category' => 'stripe', 'is_premium' => TRUE));
     WidgetDescriptor::updateOrCreate(['name' => 'Stripe ARR'], array('name' => 'Stripe ARR', 'description' => 'Stripe Annual recurring revenue', 'type' => 'stripe_arr', 'category' => 'stripe', 'is_premium' => TRUE));
     WidgetDescriptor::updateOrCreate(['name' => 'Stripe ARPU'], array('name' => 'Stripe ARPU', 'description' => 'Stripe Average revenue per user', 'type' => 'stripe_arpu', 'category' => 'stripe', 'is_premium' => TRUE));
     WidgetDescriptor::updateOrCreate(['name' => 'Stripe events'], array('name' => 'Stripe events', 'description' => 'Your stripe events', 'type' => 'stripe_events', 'category' => 'stripe', 'is_premium' => TRUE));
     /* Financial widgets | BRAINTREE */
     WidgetDescriptor::updateOrCreate(['name' => 'Braintree MRR'], array('name' => 'Braintree MRR', 'description' => 'Braintree Monthly recurring revenue', 'type' => 'braintree_mrr', 'category' => 'braintree', 'is_premium' => TRUE));
     WidgetDescriptor::updateOrCreate(['name' => 'Braintree ARR'], array('name' => 'Braintree ARR', 'description' => 'Braintree Annual recurring revenue', 'type' => 'braintree_arr', 'category' => 'braintree', 'is_premium' => TRUE));
     WidgetDescriptor::updateOrCreate(['name' => 'Braintree ARPU'], array('name' => 'Braintree ARPU', 'description' => 'Braintree Average revenue per user', 'type' => 'braintree_arpu', 'category' => 'braintree', 'is_premium' => TRUE));
     /* Send message to console */
     error_log('WidgetDescriptorSeeder | All WidgetDescriptors updated');
 }
Example #2
0
 /**
  * Overriding save to add descriptor automatically.
  *
  * @return the saved object.
  */
 public function save(array $options = array())
 {
     // Associating descriptor.
     $widgetDescriptor = WidgetDescriptor::where('type', $this->getType())->first();
     /* Checking descriptor. */
     if ($widgetDescriptor === null) {
         throw new DescriptorDoesNotExist("The descriptor for " . get_class($this) . " does not exist", 1);
     }
     // Assigning descriptor.
     $this->descriptor()->associate($widgetDescriptor);
     // Calling parent.
     parent::save($options);
     // Always saving settings to keep integrity.|
     $this->saveSettings(array(), FALSE);
     $this->checkIntegrity(FALSE);
     /* Saving integrity/settings.
      * Please note, that the save won't hit the db,
      * if no change has been made to the model.
      */
     return parent::save();
 }
 public function showSelectPersonalWidgets()
 {
     return View::make('select_personal_widgets')->with('personalWidgets', WidgetDescriptor::where('type', '!=', 'financial')->get());
 }
 /**
  * getWidgetDescriptor
  * --------------------------------------------------
  * Returns the widget descriptor's data in json.
  * @param  (int)  ($descriptorID) The ID of the descriptor.
  * @return Json with descriptor data.
  * --------------------------------------------------
  */
 public function getWidgetDescriptor()
 {
     /* Escaping invalid data. */
     if (!Input::get('descriptorID')) {
         return Response::json(array('error' => 'Descriptor not found'));
     }
     /* Getting descriptor from DB. */
     $descriptor = WidgetDescriptor::find(Input::get('descriptorID'));
     /* Descriptor not found */
     if (is_null($descriptor)) {
         return Response::json(array('error' => 'Descriptor not found'));
     }
     /* Returning widget descriptor description. */
     return Response::json(array('description' => $descriptor->description, 'name' => $descriptor->name, 'type' => $descriptor->type));
 }