예제 #1
0
파일: Human.php 프로젝트: Danielberry90/Txt
 public function generateTxt()
 {
     $humans = "";
     foreach (Human::all() as $human) {
         $humans .= '/* ' . $human->attribution . ' */' . PHP_EOL;
         foreach ($human->information as $information) {
             $humans .= $information->field . ': ' . $information->value . PHP_EOL;
         }
         $humans .= PHP_EOL;
     }
     return $humans;
 }
예제 #2
0
<?php

use Cms\Classes\Page;
use Mohsin\Txt\Models\Robot;
use Mohsin\Txt\Models\Human;
use Mohsin\Txt\Models\Setting;
Route::get('robots.txt', function () {
    if (!Setting::get('use_robots') || !Robot::first()) {
        return Redirect::to(Page::url(Setting::get('redirectpage')));
    }
    return Response::make(Robot::first()->generateTxt(), 200, array('Content-Type' => 'text/plain'));
});
Route::get('humans.txt', function () {
    if (!Setting::get('use_humans') || !Human::first()) {
        return Redirect::to(Page::url(Setting::get('redirectpage')));
    }
    return Response::make(Human::first()->generateTxt(), 200, array('Content-Type' => 'text/plain'));
});