/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         return redirect()->intended(cms_url());
     }
     return $next($request);
 }
Beispiel #2
0
 public function test_button_components()
 {
     // Test object
     $page = Page::find(1);
     // Check the create method.
     $group = ButtonGroup::create();
     $this->assertInstanceOf(ButtonGroup::class, $group);
     // Shouldn't have anything in it.
     $this->assertCount(0, $group->getButtons());
     // Should return a zero count.
     $this->assertEquals(0, $group->count());
     // Button groups
     $button = Button::create();
     // Check default setting.
     $this->assertNull($button->getAttribute('href'));
     // Adding to the group will increment the button count.
     $group->add($button);
     $this->assertEquals(1, $group->count());
     // Try adding the other way around.
     $button2 = Button::create();
     $button2->addTo($group);
     $this->assertEquals(2, $group->count());
     // Check if the button attributes are assigned correctly.
     $button->parent($page)->link('view');
     $this->assertEquals("View Pages", $button->getLabel());
     $this->assertEquals($page::getIcon(), $button->getIcon());
     $this->assertEquals(cms_url($page::plural()), $button->getAttribute('href'));
 }
Beispiel #3
0
 /**
  * RelatedMedia constructor.
  * @param Model $model
  */
 public function __construct(Model $model, $args = null)
 {
     parent::__construct();
     // The RelatedMedia contract is required by the model.
     if (!$model instanceof \Birdmin\Contracts\RelatedMedia) {
         return $this->canRender = false;
     }
     $this->parent($model);
     $this->dropzone = Dropzone::create()->handler('relate', cms_url('media/upload'))->relate($model);
 }
Beispiel #4
0
 /**
  * Returns a link to edit this object in the CMS.
  * @return string
  */
 public function editUrl()
 {
     return cms_url(static::getLabel('slug') . "/edit/" . $this->id);
 }
Beispiel #5
0
 /**
  * Use an action handle to quickly set up this button with common properties.
  * @param $name string action name
  * @return $this|null
  */
 protected function setupAction($name)
 {
     if (!$name || !array_key_exists($name, $this->actions)) {
         return null;
     }
     list($label, $url, $icon) = $this->actions[$name];
     $this->label = stringf($label, $this->parentAttributes);
     $this->attribute('href', cms_url(stringf($url, $this->parentAttributes)));
     $this->icon = stringf($icon, $this->parentAttributes);
     // Check if the specific action has a CSS class it normally uses.
     if (isset($this->actionClass[$name])) {
         $this->classes($this->actionClass[$name]);
     }
     // If the parent doesn't adhere to the contract, don't render it.
     if (isset($this->contracts[$name])) {
         $this->canRender = has_contract($this->parent, $this->contracts[$name]);
     }
     return $this;
 }
 /**
  * Display the media upload form.
  * @param Request $request
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     $this->setActions([Button::create()->parent($this->class)->link('home'), Button::create()->parent($this->class)->link('view'), Button::create()->parent($this->class)->link('upload')->active()]);
     $this->setData('dropzone', Dropzone::create()->handler('default', cms_url('media/upload')));
     return $this->birdmin('cms::media.upload');
 }
 /**
  * GET logout
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function logout()
 {
     Auth::logout();
     return redirect(cms_url('login?landed=true'));
 }