/** * Save all entry fields * @param integer $entryId * @param mixed $data * @return mixed */ public function saveAllForEntry($entryId, $data) { // Get entry and channel $entry = Entry::with(array('author', 'fields'))->where('id', $entryId)->first(); $entry = new Entities\EntryEntity($entry->toArray()); $channel = $this->channels->find($entry->channel); // Add specific entry fields $channel->addEntryFields($entry); foreach ($channel->fields as $field) { if ($field->save != 'direct') { // Get value from form $value = array_get($data, $field->name); // Set field entry $field->set('entry', $entry); // Pass through to field save method $value = $field->save($value); // And save accordinly $this->createOrUpdate($entryId, $field->name, $value, $field); } } }
/** * Find single entry by slug * @param string $slug * @return EntryEntity */ public function findBySlug($slug, $channel = null, $options = array()) { // Start query $this->query = Entry::with(array('author', 'fields'))->where('slug', $slug); // Channel if ($channel) { // Get channel config $this->channel = $this->channels->find($channel); $this->query->inChannel($this->channel->name); } // Status $this->query = $this->options($options); // Run query return $this->item(); }