예제 #1
0
 public function getFeatured()
 {
     $featuredSetting = Setting::where('meta_key', '=', 'featured-doc')->first();
     $doc = Doc::with('categories')->with('sponsor')->with('statuses')->with('dates');
     if ($featuredSetting) {
         $featuredId = (int) $featuredSetting->meta_value;
         $doc = $doc->where('id', $featuredId)->where('private', '!=', '1')->first();
     } else {
         $doc = $doc->orderBy('created_at', 'desc')->where('private', '!=', '1')->first();
         $doc->thumbnail = '/img/default/default.jpg';
     }
     $doc->enableCounts();
     $return_doc = $doc->toArray();
     $return_doc['introtext'] = $doc->introtext()->first()['meta_value'];
     $return_doc['updated_at'] = date('c', strtotime($return_doc['updated_at']));
     $return_doc['created_at'] = date('c', strtotime($return_doc['created_at']));
     return Response::json($return_doc);
 }
예제 #2
0
 public function getAllStatuses()
 {
     $doc = Doc::with('statuses')->first();
     $statuses = $doc->statuses;
     return Response::json($statuses);
 }
예제 #3
0
 public function getFeatured()
 {
     $featuredSetting = Setting::where('meta_key', '=', 'featured-doc')->first();
     if ($featuredSetting) {
         // Make sure our featured document can be viewed by the public.
         $featuredId = (int) $featuredSetting->meta_value;
         $doc = Doc::with('categories')->with('sponsor')->with('statuses')->with('dates')->where('id', $featuredId)->where('private', '!=', '1')->where('is_template', '!=', '1')->first();
     }
     // If we don't have a document, just find anything recent.
     if (empty($doc)) {
         $doc = Doc::with('categories')->with('sponsor')->with('statuses')->with('dates')->where('private', '!=', '1')->where('is_template', '!=', '1')->orderBy('created_at', 'desc')->first();
         if (!empty($doc)) {
             $doc->thumbnail = '/img/default/default.jpg';
         }
     }
     // If we still don't have a document, give up.
     if (empty($doc)) {
         return Response::make(null, 404);
     }
     $doc->enableCounts();
     $return_doc = $doc->toArray();
     $return_doc['introtext'] = $doc->introtext()->first()['meta_value'];
     $return_doc['updated_at'] = date('c', strtotime($return_doc['updated_at']));
     $return_doc['created_at'] = date('c', strtotime($return_doc['created_at']));
     return Response::json($return_doc);
 }
예제 #4
0
 public static function getEager()
 {
     return Doc::with('categories')->with('sponsor')->with('statuses')->with('dates');
 }
예제 #5
0
파일: feed.php 프로젝트: krues8dr/madison
<?php

/**
 *   RSS Feed Route.
 */
Route::get('docs/feed', function () {
    //Grab all documents
    $docs = Doc::with('sponsor', 'content')->orderBy('updated_at', 'DESC')->take(20)->get();
    $feed = Feed::make();
    $feed->title = 'Madison Documents';
    $feed->description = 'Latest 20 documents in Madison';
    $feed->link = URL::to('rss');
    $feed->pubdate = $docs->first()->updated_at;
    $feed->lang = 'en';
    foreach ($docs as $doc) {
        $sponsor = $doc->sponsor->first();
        if ($sponsor instanceof User) {
            $display_name = $sponsor->fname . ' ' . $sponsor->lname;
        } elseif ($sponsor instanceof Group) {
            $display_name = $sponsor->display_name;
        } else {
            $display_name = '';
        }
        $item = array();
        $item['title'] = $doc->title;
        $item['author'] = $display_name;
        $item['link'] = URL::to('docs/' . $doc->slug);
        $item['pubdate'] = $doc->updated_at;
        $item['description'] = $doc->title;
        $item['content'] = $doc->content->html();
        array_push($feed->items, $item);