/** * 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()); }