Beispiel #1
0
 /**
  * @param $instance
  * @param int $totalCount
  * @return string
  * @throws \SleepingOwl\Admin\Exceptions\ModelNotFoundException
  */
 public function render($instance, $totalCount)
 {
     $filterValue = $this->valueFromInstance($instance, $this->value);
     $modelItem = Admin::instance()->models->modelWithClassname($this->model);
     $url = $this->router->routeToModel($modelItem->getAlias(), [$this->name => $filterValue]);
     if ($this->model === $this->modelItem->getModelClass()) {
         $class = 'fa-filter';
         $title = Lang::get('admin::lang.table.filter');
     } else {
         $class = 'fa-arrow-circle-o-right';
         $title = Lang::get('admin::lang.table.filter-goto');
     }
     $content = $this->htmlBuilder->tag('i', ['class' => ['fa', $class], 'data-toggle' => 'tooltip', 'title' => $title]);
     return $this->htmlBuilder->tag('a', ['href' => $url], $content);
 }
Beispiel #2
0
 /** @test */
 public function it_generates_url_to_model_table()
 {
     $this->shouldReceiveAnyOther();
     $this->instance->registerRoutes();
     $this->urlGenerator->shouldReceive('route')->with('test-prefix.table.table', ['TestModel'])->once()->andReturn('some-route');
     $this->urlGenerator->shouldReceive('route')->with('test-prefix.table.table', ['TestModel', 'test_parameter' => 2, 'parameter_without_value'])->once()->andReturn('some-route');
     $route = $this->instance->routeToModel('TestModel');
     $this->assertEquals('some-route', $route);
     $route = $this->instance->routeToModel('TestModel', ['test_parameter' => 2, 'parameter_without_value']);
     $this->assertEquals('some-route', $route);
 }
Beispiel #3
0
 /**
  * @return string
  */
 public function getUrl()
 {
     if (!is_null($this->url)) {
         if (strpos($this->url, '://') !== false) {
             return $this->url;
         }
         return $this->router->routeToWildcard($this->url);
     }
     if (!is_null($this->modelClass)) {
         return $this->router->routeToModel($this->getModelItem()->getAlias());
     }
     return '#';
 }
Beispiel #4
0
 /**
  * 
  *
  * @param string $model
  * @param array $parameters
  * @return string 
  * @static 
  */
 public static function routeToModel($model, $parameters = array())
 {
     return \SleepingOwl\Admin\Router::routeToModel($model, $parameters);
 }