Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make jetstream extendable for other stacks by the community #26

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
make jetstream extendable for other stacks by the community
  • Loading branch information
Naoray committed Sep 2, 2020
commit 2eacf33aab8862dae101f266e0f5d459bc0502b7
10 changes: 10 additions & 0 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use InvalidArgumentException;
use Symfony\Component\Process\Process;

class InstallCommand extends Command
Expand Down Expand Up @@ -61,6 +62,15 @@ public function handle()
app_path('Http/Kernel.php')
);

// Install custom Stack
if (static::hasMacro($this->argument('stack'))) {
return static::{$this->argument('stack')}();
}

if (!in_array($this->argument('stack'), ['livewire', 'inertia'])) {
throw new InvalidArgumentException('Invalid stack.');
}

// Install Stack...
if ($this->argument('stack') === 'livewire') {
$this->installLivewireStack();
Expand Down
14 changes: 14 additions & 0 deletions src/JetstreamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ protected function configurePublishing()
*/
protected function configureRoutes()
{
if ($this->stackIsNotSupported()) {
return;
}

Route::group([
'namespace' => 'Laravel\Jetstream\Http\Controllers',
'domain' => config('jetstream.domain', null),
Expand Down Expand Up @@ -198,4 +202,14 @@ protected function bootInertia()
$kernel->appendMiddlewareToGroup('web', ShareInertiaData::class);
$kernel->appendToMiddlewarePriority(ShareInertiaData::class);
}

/**
* Determines if the current stack is supported.
*
* @return bool
*/
protected function stackIsNotSupported()
{
return !in_array(config('jetstream.stack'), ['livewire', 'inertia']);
}
}