From 068ad3851c442b8ac9054846fcaec2737d7dd96a Mon Sep 17 00:00:00 2001 From: Ramadani Date: Wed, 3 Aug 2016 22:33:55 +0700 Subject: [PATCH] create sui_breadcrumb --- .../views/breadcrumb/semantic-ui.blade.php | 3 + src/Breadcrumb/SemanticUIBreadcrumb.php | 69 +++++++++++++++++++ src/Contracts/Breadcrumb.php | 35 ++++++++++ src/SupportServiceProvider.php | 4 ++ src/helpers.php | 11 +++ 5 files changed, 122 insertions(+) create mode 100644 resources/views/breadcrumb/semantic-ui.blade.php create mode 100644 src/Breadcrumb/SemanticUIBreadcrumb.php create mode 100644 src/Contracts/Breadcrumb.php diff --git a/resources/views/breadcrumb/semantic-ui.blade.php b/resources/views/breadcrumb/semantic-ui.blade.php new file mode 100644 index 0000000..37ae629 --- /dev/null +++ b/resources/views/breadcrumb/semantic-ui.blade.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/src/Breadcrumb/SemanticUIBreadcrumb.php b/src/Breadcrumb/SemanticUIBreadcrumb.php new file mode 100644 index 0000000..d541396 --- /dev/null +++ b/src/Breadcrumb/SemanticUIBreadcrumb.php @@ -0,0 +1,69 @@ + / ') + { + $this->divider = $divider; + + return $this; + } + + /** + * Add item for breadcrumn + * + * @param $name + * @param string $url + * @return mixed + */ + public function addItem($name, $url = '') + { + if (! empty($url)) { + $item = sprintf('%s', $url, $name); + } else { + $item = sprintf('
%s
', $name); + } + + array_push($this->items, $item); + + return $this; + } + + /** + * Render breadcrumb view + * + * @return mixed + */ + public function render() + { + return view('support::breadcrumb.semantic-ui', [ + 'divider' => $this->divider, + 'items' => $this->items + ])->render(); + } +} \ No newline at end of file diff --git a/src/Contracts/Breadcrumb.php b/src/Contracts/Breadcrumb.php new file mode 100644 index 0000000..1f940e8 --- /dev/null +++ b/src/Contracts/Breadcrumb.php @@ -0,0 +1,35 @@ +registerBladeExtensions(); $this->registerTranslations(); $this->registerConfigurations(); + $this->loadViewsFrom(realpath(__DIR__.'/../resources/views'), 'support'); } /** @@ -32,6 +33,9 @@ public function register() { // timezone $this->app->bind(Contracts\TimezoneRepository::class, Repositories\TimezoneRepositoryArray::class); + + // breadcrumb + $this->app->bind(Contracts\Breadcrumb::class, Breadcrumb\SemanticUIBreadcrumb::class); } /** diff --git a/src/helpers.php b/src/helpers.php index 37c5fd2..198a0da 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -23,6 +23,17 @@ function sui_pagination($collection) } } +if (!function_exists('sui_breadcrumb')) { + + /** + * @return \Illuminate\Foundation\Application|mixed + */ + function sui_breadcrumb() + { + return app(Laravolt\Support\Contracts\Breadcrumb::class); + } +} + if (!function_exists('render')) { /**