コード例 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $log = new Process();
     $log->name = "make-history";
     $log->status = "running";
     $log->save();
     $today = Carbon::today();
     $topToday = array();
     $newspapers = Newspaper::select('id')->get();
     $tags = Tag::select('id')->get();
     foreach ($newspapers as $key => $n) {
         $top = $this->getTopLink($today, $n->id, false);
         if ($top) {
             $topToday[] = $top;
         }
     }
     foreach ($tags as $key => $t) {
         $top = $this->getTopLink($today, false, $t->id);
         if ($top) {
             $topToday[] = $top;
         }
     }
     $topToday = array_unique($topToday);
     //Remove links for today
     History::where('date', '=', $today)->delete();
     //Save history
     foreach ($topToday as $key => $t) {
         $this->info($t->title);
         try {
             $h = new History();
             $h->id_ref = $t->id;
             unset($t->id);
             $h->fill($t->toArray());
             $h->date = $today;
             $h->save();
         } catch (Exception $e) {
         }
     }
     $log->status = "finished";
     $log->save();
 }
コード例 #2
0
ファイル: InheritanceTest.php プロジェクト: pradosoft/prado
 function AssertNewspaper(Newspaper $news, $id, $title, $city)
 {
     $this->assertEquals($id, $news->getId());
     $this->assertEquals($title, $news->getTitle());
     $this->assertEquals($city, $news->getCity());
 }
コード例 #3
0
/**
* Observer,that who recieves news
*/
class Reader implements SplObserver
{
    private $name;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function update(\SplSubject $subject)
    {
        echo $this->name . ' is reading breakout news <b>' . $subject->getContent() . '</b><br>';
    }
}
$newspaper = new Newspaper('Newyork Times');
$allen = new Reader('Allen');
$jim = new Reader('Jim');
$linda = new Reader('Linda');
//add reader
$newspaper->attach($allen);
$newspaper->attach($jim);
$newspaper->attach($linda);
//remove reader
$newspaper->detach($linda);
var_dump('----debug----', $newspaper, '----debug----');
//set break outs
$newspaper->breakOutNews('USA break down!');
//=====output======
//Allen is reading breakout news USA break down! (Newyork Times)
//Jim is reading breakout news USA break down! (Newyork Times)
コード例 #4
0
ファイル: observer.php プロジェクト: pihh/mariana-framework
}
/**
 * Observer,that who recieves news
 */
class Reader implements SplObserver
{
    private $name;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function update(\SplSubject $subject)
    {
        echo $this->name . ' is reading breakout news <b>' . $subject->getContent() . '</b><br>';
    }
}
$newspaper = new Newspaper('Newyork Times');
$allen = new Reader('Allen');
$jim = new Reader('Jim');
$linda = new Reader('Linda');
//add reader
$newspaper->attach($allen);
$newspaper->attach($jim);
$newspaper->attach($linda);
//remove reader
$newspaper->detach($linda);
//set break outs
$newspaper->breakOutNews('USA break down!');
//=====output======
//Allen is reading breakout news USA break down! (Newyork Times)
//Jim is reading breakout news USA break down! (Newyork Times)
コード例 #5
0
 public function getNewspapers()
 {
     return Response::json(Newspaper::select('id', 'name', 'logo')->orderBy('name', 'ASC')->get());
 }