示例#1
0
 /**
  * Listen to the Block saved event.
  *
  * @param \Soda\Cms\Models\Block $block
  */
 public function saved(Block $block)
 {
     if ($block->isDirty('is_shared')) {
         if (!$block->type) {
             $block->load('type');
         }
         ModelBuilder::fromTable('soda_' . $block->type->identifier)->where($block->getRelatedField(), $block->id)->update(['is_shared' => $block->is_shared]);
     }
 }
示例#2
0
文件: Soda.php 项目: sodacms/sodacms
 /**
  * Get a block by its identifier
  *
  * @param $identifier
  *
  * @return mixed
  */
 public function getBlock($identifier)
 {
     if (!isset($this->blocks[$identifier])) {
         $this->blocks[$identifier] = Block::with('type')->where('identifier', $identifier)->first();
     }
     return $this->blocks[$identifier];
 }
 protected function bootObservers()
 {
     Block::observe(BlockObserver::class);
     Page::observe(PageObserver::class);
     BlockType::observe(DynamicObserver::class);
     PageType::observe(DynamicObserver::class);
 }
示例#4
0
文件: Cms.php 项目: sodacms/sodacms
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @param  string|null              $guard
  *
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     config()->set('auth.defaults.guard', 'soda');
     //this is a work around for a laravel bug - the guard flicks back to the default when run through an auth Gate
     //so we need to temporarily set the guard to the incomming guard here instead.
     Block::disableDrafts();
     BlockType::disableDrafts();
     Page::disableDrafts();
     PageType::disableDrafts();
     return $next($request);
 }