private function _isUnread()
 {
     if (Auth::guest()) {
         return false;
     }
     $markAsReadAfter = value(Config::get('forums::forums.mark_as_read_after'));
     if (!IoC::registered('topicsview')) {
         IoC::singleton('topicsview', function () use($markAsReadAfter) {
             return Forumview::where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter))->where('user_id', '=', Auth::user()->id)->lists('topic_id');
         });
     }
     $tv = IoC::resolve('topicsview');
     $nb = count($tv);
     $view = Forumtopic::where('forumcategory_id', '=', $this->id)->where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter));
     if ($nb > 0) {
         $view = $view->where_not_in('id', $tv);
     }
     $view = $view->count();
     if ($nb == 0 && $view > 0) {
         return true;
     }
     if ($view > 0) {
         return true;
     }
     return false;
 }
Example #2
0
  */
 if ($cache and !is_dir($cache)) {
     mkdir($cache);
 }
 /**
  * Register the Twig library with the auto-loader
  */
 Laravel\Autoloader::underscored(array('Twig' => Bundle::path('twig') . 'lib/Twig'));
 /**
  * Instantiate a new Laravel Twig loader
  */
 include 'loader.php';
 /**
  * If it's registered in the IoC, resolve from there... otherwise use default
  */
 if (IoC::registered('twig::loader')) {
     $loader = IoC::resolve('twig::loader');
 } else {
     $loader = new Laravel_Twig_Loader($ext);
 }
 /**
  * Hook into the Laravel view loader
  */
 Laravel\Event::override(Laravel\View::loader, function ($bundle, $view) use($loader, $ext) {
     // Use the custom Laravel Twig loader for Twig views...
     if (starts_with($view, 'twig|')) {
         return $loader->getPath($bundle, substr($view, 5));
     } elseif (starts_with($bundle, 'twig|')) {
         return $loader->getPath(substr($bundle, 5), $view);
     } else {
         return View::file($bundle, $view);
Example #3
0
 /**
  * Test the IoC::controller method.
  *
  * @group laravel
  */
 public function testControllerMethodRegistersAController()
 {
     IoC::register('controller: ioc.test', function () {
     });
     $this->assertTrue(IoC::registered('controller: ioc.test'));
 }
Example #4
0
});
Event::listen('laravel.auth: logout', function () {
    Session::forget('oneauth');
});
/*
|--------------------------------------------------------------------------
| OneAuth IoC
|--------------------------------------------------------------------------
|
| Register Auth adapter as IoC, allow it to be replaced by any Authentication
| bundle that doesn't use Laravel\Auth\Drivers.
|
*/
if (!IoC::registered('oneauth.driver: auth.check')) {
    // Check whether current user is logged-in to the system or a guest
    IoC::register('oneauth.driver: auth.check', function () {
        return Auth::check();
    });
}
if (!IoC::registered('oneauth.driver: auth.user')) {
    // Get logged in user, if the user doesn't logged in yet, return null
    IoC::register('oneauth.driver: auth.user', function () {
        return Auth::user();
    });
}
if (!IoC::registered('oneauth.driver: auth.login')) {
    // Login the user by users.id
    IoC::register('oneauth.driver: auth.login', function ($user_id) {
        return Auth::login($user_id);
    });
}
 public function _isUnread()
 {
     if (Auth::guest()) {
         return false;
     }
     $markAsReadAfter = value(Config::get('forums::forums.mark_as_read_after'));
     // is the topic > delay, then return false;
     if (strtotime($this->updated_at) < $markAsReadAfter) {
         return false;
     }
     if (!IoC::registered('topicsview')) {
         IoC::singleton('topicsview', function () use($markAsReadAfter) {
             return Forumview::where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter))->where('user_id', '=', Auth::user()->id)->lists('topic_id');
         });
     }
     if (array_search($this->id, IoC::resolve('topicsview')) !== false) {
         return false;
     }
     return true;
 }
Example #6
0
 static function factory($block, $fail = true)
 {
     if (is_object($block)) {
         $class = $block;
     } else {
         \Bundle::start(\Bundle::resolve(\Bundle::name($block)));
         if (\IoC::registered($ioc = "vane.block: {$block}")) {
             $class = $block = IoC::resolve($ioc);
         } else {
             $class = static::classOf($block, false);
             class_exists($class) or $class = static::fromStd($block);
         }
     }
     if ($fail and !is_subclass_of($class, $parent = 'Laravel\\Routing\\Controller')) {
         throw new Error("Block class [{$class}] must inherit from [{$parent}].");
     } else {
         return is_object($block) ? $block : new $class();
     }
 }