/** * Event call to get the latest records * * @param integer $num * @param string $dateField * @param string $sort * @return array */ public function onGetLatest($num = 5, $dateField = 'created', $sort = 'DESC') { $model = CalEvent::getLatest($num, $dateField, $sort)->rows()->toObject(); $objects = array(); foreach ($model as $m) { $object = new stdClass(); $object->title = $m->title; $object->body = htmlspecialchars_decode($m->content); $object->date = Date::of($m->publish_up)->toLocal("F j, Y"); $object->path = 'events/details/' . $m->id; $object->id = $m->id; array_push($objects, $object); } return $objects; }
public static function getLatest($limit = 10, $dateField = 'created', $sort = 'DESC') { $rows = Event::all()->where('scope', '=', 'event')->where('state', '=', '1')->order($dateField, $sort)->limit($limit); return $rows; }