示例#1
0
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot(Router $router)
 {
     require_once __DIR__ . '/../Components/Helpers.php';
     //publishes
     $this->publishes([__DIR__ . '/../../public/' => public_path('ryzr/core')], 'public');
     $this->publishes([__DIR__ . '/../../database/migrations/' => database_path('migrations')], 'migrations');
     $this->publishes([__DIR__ . '/../../database/seeds/' => database_path('seeds')], 'seeds');
     $this->publishes([__DIR__ . '/../../config/core.php' => config_path('ryzr/core.php')], 'config');
     //load middleware, helpers, views, routes
     $router->middleware('permissions', Permissions::class);
     //views
     $this->loadViewsFrom(__DIR__ . '/../../views', 'ryzr.core');
     if (!$this->app->routesAreCached()) {
         require __DIR__ . '/../routes.php';
     }
     if (!$this->app->runningInConsole()) {
         Event::listen('auth.login', function ($user) {
             $user->loggedin_at = Carbon::now();
             $user->save();
         });
         View::share('current_application', CurrentApplication::get()->id);
         View::composer('*', function ($view) {
             $view->with('current_user', Auth::user());
         });
     }
 }
示例#2
0
 /**
  * Apply scope on the query.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $builder
  * @param  \Illuminate\Database\Eloquent\Model $model
  *
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     $column = $model->getApplicationForeignKey(true);
     $builder->whereHas('applications', function ($q) use($column) {
         $q->where($column, CurrentApplication::get()->id);
     });
     $this->addAllApplications($builder);
 }
示例#3
0
文件: routes.php 项目: ryzr/core
<?php

use Ryzr\Core\Applications\CurrentApplication;
$application = CurrentApplication::get();
if (!$application) {
    Route::any('{any}/{all?}', function () {
        return Response::make(view('ryzr.core::errors.no-app'), 404);
    });
}
示例#4
0
 public function __construct()
 {
     $this->application = CurrentApplication::get();
 }
示例#5
0
 /**
  * Apply scope on the query.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $builder
  * @param  \Illuminate\Database\Eloquent\Model $model
  *
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     $column = $model->getApplicationForeignKey();
     $builder->where($column, CurrentApplication::get()->id);
     $this->addAllApplications($builder);
 }