This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f43ee5
commit e545530
Showing
7 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,8 @@ | |
// new UserDashboard, | ||
], | ||
|
||
'pages' => [ | ||
// new CustomPage, | ||
], | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<x-nebula::layouts.shell :title="$page->singularName()"> | ||
|
||
<div class="mb-8 space-y-4"> | ||
{{ $page->display() }} | ||
</div> | ||
|
||
</x-nebula::layouts.shell> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace Larsklopstra\Nebula\Contracts; | ||
|
||
use Exception; | ||
use Illuminate\Support\Str; | ||
use Illuminate\Support\Stringable; | ||
|
||
abstract class NebulaPage | ||
{ | ||
/** | ||
* Specifies which icon should be used. | ||
* | ||
* @return string | ||
*/ | ||
public function icon() | ||
{ | ||
return 'tag'; | ||
} | ||
|
||
/** | ||
* Returns the name of the page. | ||
* | ||
* @return Stringable | ||
*/ | ||
public function name() | ||
{ | ||
return Str::of(class_basename($this)) | ||
->replaceLast('Page', '') | ||
->kebab() | ||
->lower() | ||
->plural(); | ||
} | ||
|
||
/** | ||
* Returns the page singular name. | ||
* | ||
* @return Stringable | ||
*/ | ||
public function singularName() | ||
{ | ||
return Str::of($this->name()) | ||
->replace('-', '') | ||
->singular(); | ||
} | ||
|
||
/** | ||
* Returns the page its plural name. | ||
* | ||
* @return string | ||
*/ | ||
public function pluralName() | ||
{ | ||
return Str::plural($this->singularName()); | ||
} | ||
|
||
/** | ||
* Outputs the page. | ||
* | ||
* @return | ||
*/ | ||
public function display() | ||
{ | ||
if (! method_exists($this, 'render')) { | ||
throw new Exception('No `render` method defined on '.get_class($this)); | ||
} | ||
|
||
return app()->call([$this, 'render']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Larsklopstra\Nebula\Http\Controllers; | ||
|
||
use Larsklopstra\Nebula\Contracts\NebulaPage; | ||
|
||
class PageController | ||
{ | ||
public function index(NebulaPage $page) | ||
{ | ||
return view('nebula::pages.index', [ | ||
'page' => $page, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters