glastree_on_gitea
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasAssets
|
||||
{
|
||||
public bool $hasAssets = false;
|
||||
|
||||
public function hasAssets(): static
|
||||
{
|
||||
$this->hasAssets = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasBladeComponents
|
||||
{
|
||||
public array $viewComponents = [];
|
||||
|
||||
public function hasViewComponent(string $prefix, string $viewComponentName): static
|
||||
{
|
||||
$this->viewComponents[$viewComponentName] = $prefix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasViewComponents(string $prefix, ...$viewComponentNames): static
|
||||
{
|
||||
foreach ($viewComponentNames as $componentName) {
|
||||
$this->viewComponents[$componentName] = $prefix;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasCommands
|
||||
{
|
||||
public array $commands = [];
|
||||
public array $consoleCommands = [];
|
||||
|
||||
public function hasCommand(string $commandClassName): static
|
||||
{
|
||||
$this->commands[] = $commandClassName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasCommands(...$commandClassNames): static
|
||||
{
|
||||
$this->commands = array_merge(
|
||||
$this->commands,
|
||||
collect($commandClassNames)->flatten()->toArray()
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasConsoleCommand(string $commandClassName): static
|
||||
{
|
||||
$this->consoleCommands[] = $commandClassName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasConsoleCommands(...$commandClassNames): static
|
||||
{
|
||||
$this->consoleCommands = array_merge(
|
||||
$this->consoleCommands,
|
||||
collect($commandClassNames)->flatten()->toArray()
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasConfigs
|
||||
{
|
||||
public array $configFileNames = [];
|
||||
|
||||
public function hasConfigFile($configFileName = null): static
|
||||
{
|
||||
$configFileName ??= $this->shortName();
|
||||
|
||||
if (! is_array($configFileName)) {
|
||||
$configFileName = [$configFileName];
|
||||
}
|
||||
|
||||
$this->configFileNames = $configFileName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasInertia
|
||||
{
|
||||
public bool $hasInertiaComponents = false;
|
||||
|
||||
public function hasInertiaComponents(?string $namespace = null): static
|
||||
{
|
||||
$this->hasInertiaComponents = true;
|
||||
|
||||
$this->viewNamespace = $namespace;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
use Spatie\LaravelPackageTools\Commands\InstallCommand;
|
||||
|
||||
trait HasInstallCommand
|
||||
{
|
||||
public function hasInstallCommand($callable): static
|
||||
{
|
||||
$installCommand = new InstallCommand($this);
|
||||
|
||||
$callable($installCommand);
|
||||
|
||||
$this->consoleCommands[] = $installCommand;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasMigrations
|
||||
{
|
||||
public bool $runsMigrations = false;
|
||||
|
||||
public bool $discoversMigrations = false;
|
||||
|
||||
public ?string $migrationsPath = null;
|
||||
|
||||
public array $migrationFileNames = [];
|
||||
|
||||
public function runsMigrations(bool $runsMigrations = true): static
|
||||
{
|
||||
$this->runsMigrations = $runsMigrations;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasMigration(string $migrationFileName): static
|
||||
{
|
||||
$this->migrationFileNames[] = $migrationFileName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasMigrations(...$migrationFileNames): static
|
||||
{
|
||||
$this->migrationFileNames = array_merge(
|
||||
$this->migrationFileNames,
|
||||
collect($migrationFileNames)->flatten()->toArray()
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function discoversMigrations(bool $discoversMigrations = true, string $path = '/database/migrations'): static
|
||||
{
|
||||
$this->discoversMigrations = $discoversMigrations;
|
||||
$this->migrationsPath = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasRoutes
|
||||
{
|
||||
public array $routeFileNames = [];
|
||||
|
||||
public function hasRoute(string $routeFileName): static
|
||||
{
|
||||
$this->routeFileNames[] = $routeFileName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasRoutes(...$routeFileNames): static
|
||||
{
|
||||
$this->routeFileNames = array_merge(
|
||||
$this->routeFileNames,
|
||||
collect($routeFileNames)->flatten()->toArray()
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasServiceProviders
|
||||
{
|
||||
public ?string $publishableProviderName = null;
|
||||
|
||||
public function publishesServiceProvider(string $providerName): static
|
||||
{
|
||||
$this->publishableProviderName = $providerName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasTranslations
|
||||
{
|
||||
public bool $hasTranslations = false;
|
||||
|
||||
public function hasTranslations(): static
|
||||
{
|
||||
$this->hasTranslations = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasViewComposers
|
||||
{
|
||||
public array $viewComposers = [];
|
||||
|
||||
public function hasViewComposer($view, $viewComposer): static
|
||||
{
|
||||
if (! is_array($view)) {
|
||||
$view = [$view];
|
||||
}
|
||||
|
||||
foreach ($view as $viewName) {
|
||||
$this->viewComposers[$viewName] = $viewComposer;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasViewSharedData
|
||||
{
|
||||
public array $sharedViewData = [];
|
||||
|
||||
public function sharesDataWithAllViews(string $name, $value): static
|
||||
{
|
||||
$this->sharedViewData[$name] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\Package;
|
||||
|
||||
trait HasViews
|
||||
{
|
||||
public bool $hasViews = false;
|
||||
|
||||
public ?string $viewNamespace = null;
|
||||
|
||||
public function hasViews(?string $namespace = null): static
|
||||
{
|
||||
$this->hasViews = true;
|
||||
|
||||
$this->viewNamespace = $namespace;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function viewNamespace(): string
|
||||
{
|
||||
return $this->viewNamespace ?? $this->shortName();
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
trait ProcessAssets
|
||||
{
|
||||
protected function bootPackageAssets(): static
|
||||
{
|
||||
if (! $this->package->hasAssets || ! $this->app->runningInConsole()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$vendorAssets = $this->package->basePath('/../resources/dist');
|
||||
$appAssets = public_path("vendor/{$this->package->shortName()}");
|
||||
|
||||
$this->publishes([$vendorAssets => $appAssets], "{$this->package->shortName()}-assets");
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
trait ProcessBladeComponents
|
||||
{
|
||||
protected function bootPackageBladeComponents(): self
|
||||
{
|
||||
if (empty($this->package->viewComponents)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
foreach ($this->package->viewComponents as $componentClass => $prefix) {
|
||||
$this->loadViewComponentsAs($prefix, [$componentClass]);
|
||||
}
|
||||
|
||||
if ($this->app->runningInConsole()) {
|
||||
$vendorComponents = $this->package->basePath('/Components');
|
||||
$appComponents = base_path("app/View/Components/vendor/{$this->package->shortName()}");
|
||||
|
||||
$this->publishes([$vendorComponents => $appComponents], "{$this->package->name}-components");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
trait ProcessCommands
|
||||
{
|
||||
protected function bootPackageCommands(): self
|
||||
{
|
||||
if (empty($this->package->commands)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->commands($this->package->commands);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function bootPackageConsoleCommands(): self
|
||||
{
|
||||
if (empty($this->package->consoleCommands) || ! $this->app->runningInConsole()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->commands($this->package->consoleCommands);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
trait ProcessConfigs
|
||||
{
|
||||
public function registerPackageConfigs(): self
|
||||
{
|
||||
if (empty($this->package->configFileNames)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
foreach ($this->package->configFileNames as $configFileName) {
|
||||
$configFilePath = $this->normalizeConfigPath($configFileName);
|
||||
$vendorConfig = $this->package->basePath("/../config/{$configFilePath}.php");
|
||||
|
||||
// Only mergeConfigFile if a .php file and not if a stub file
|
||||
if (! is_file($vendorConfig)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$normalizedConfigKey = $this->normalizeConfigKey($configFileName);
|
||||
$this->mergeConfigFrom($vendorConfig, $normalizedConfigKey);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function bootPackageConfigs(): self
|
||||
{
|
||||
if (empty($this->package->configFileNames) || ! $this->app->runningInConsole()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
foreach ($this->package->configFileNames as $configFileName) {
|
||||
$configFilePath = $this->normalizeConfigPath($configFileName);
|
||||
|
||||
$vendorConfig ;
|
||||
if (
|
||||
! is_file($vendorConfig = $this->package->basePath("/../config/{$configFilePath}.php"))
|
||||
&&
|
||||
! is_file($vendorConfig = $this->package->basePath("/../config/{$configFilePath}.php.stub"))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->publishes(
|
||||
[$vendorConfig => config_path("{$configFilePath}.php")],
|
||||
"{$this->package->shortName()}-config"
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function normalizeConfigKey(string $configFileName): string
|
||||
{
|
||||
return str_replace(['/', '\\'], '.', $configFileName);
|
||||
}
|
||||
|
||||
protected function normalizeConfigPath(string $configFileName): string
|
||||
{
|
||||
return str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $configFileName);
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait ProcessInertia
|
||||
{
|
||||
protected function bootPackageInertia(): self
|
||||
{
|
||||
if (! $this->package->hasInertiaComponents) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$namespace = $this->package->viewNamespace;
|
||||
$directoryName = Str::of($this->packageView($namespace))->studly()->remove('-')->value();
|
||||
$vendorComponents = $this->package->basePath('/../resources/js/Pages');
|
||||
$appComponents = base_path("resources/js/Pages/{$directoryName}");
|
||||
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->publishes(
|
||||
[$vendorComponents => $appComponents],
|
||||
"{$this->packageView($namespace)}-inertia-components"
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Vendored
+108
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait ProcessMigrations
|
||||
{
|
||||
protected function bootPackageMigrations(): self
|
||||
{
|
||||
if ($this->package->discoversMigrations) {
|
||||
$this->discoverPackageMigrations();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$now = Carbon::now();
|
||||
|
||||
foreach ($this->package->migrationFileNames as $migrationFileName) {
|
||||
$vendorMigration = $this->package->basePath("/../database/migrations/{$migrationFileName}.php");
|
||||
|
||||
// Support for the .stub file extension
|
||||
if (! file_exists($vendorMigration)) {
|
||||
$vendorMigration .= '.stub';
|
||||
}
|
||||
|
||||
if ($this->app->runningInConsole()) {
|
||||
$appMigration = $this->generateMigrationName($migrationFileName, $now->addSecond());
|
||||
|
||||
$this->publishes(
|
||||
[$vendorMigration => $appMigration],
|
||||
"{$this->package->shortName()}-migrations"
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->package->runsMigrations) {
|
||||
$this->loadMigrationsFrom($vendorMigration);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function discoverPackageMigrations(): void
|
||||
{
|
||||
$now = Carbon::now();
|
||||
$migrationsPath = trim($this->package->migrationsPath, '/');
|
||||
|
||||
$files = (new Filesystem())->files($this->package->basePath("/../{$migrationsPath}"));
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filePath = $file->getPathname();
|
||||
$migrationFileName = Str::replace(['.stub', '.php'], '', $file->getFilename());
|
||||
|
||||
// Publish but do not add timestamp to non migration files
|
||||
if (Str::endsWith($filePath, [".php", ".php.stub"])) {
|
||||
$appMigration = $this->generateMigrationName($migrationFileName, $now->addSecond());
|
||||
} else {
|
||||
$appMigration = database_path("migrations/{$file->getFilename()}");
|
||||
}
|
||||
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->publishes(
|
||||
[$filePath => $appMigration],
|
||||
"{$this->package->shortName()}-migrations"
|
||||
);
|
||||
}
|
||||
|
||||
// Do not load non migration files
|
||||
if ($this->package->runsMigrations && Str::endsWith($filePath, [".php", ".php.stub"])) {
|
||||
$this->loadMigrationsFrom($filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function generateMigrationName(string $migrationFileName, Carbon|CarbonImmutable $now): string
|
||||
{
|
||||
$migrationsPath = 'migrations/' . dirname($migrationFileName) . '/';
|
||||
$migrationFileName = basename($migrationFileName);
|
||||
|
||||
$len = strlen($migrationFileName) + 4;
|
||||
|
||||
if (Str::contains($migrationFileName, '/')) {
|
||||
$migrationsPath .= Str::of($migrationFileName)->beforeLast('/')->finish('/');
|
||||
$migrationFileName = Str::of($migrationFileName)->afterLast('/');
|
||||
}
|
||||
|
||||
foreach (glob(database_path("{$migrationsPath}*.php")) as $filename) {
|
||||
if ((substr($filename, -$len) === $migrationFileName . '.php')) {
|
||||
return $filename;
|
||||
}
|
||||
}
|
||||
|
||||
$migrationFileName = self::stripTimestampPrefix($migrationFileName);
|
||||
$timestamp = $now->format('Y_m_d_His');
|
||||
$formattedFileName = Str::of($migrationFileName)->snake()->finish('.php');
|
||||
|
||||
return database_path("{$migrationsPath}{$timestamp}_{$formattedFileName}");
|
||||
}
|
||||
|
||||
private static function stripTimestampPrefix(string $filename): string
|
||||
{
|
||||
return preg_replace('/^\d{4}_\d{2}_\d{2}_\d{6}_/', '', $filename);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
trait ProcessRoutes
|
||||
{
|
||||
protected function bootPackageRoutes(): self
|
||||
{
|
||||
if (empty($this->package->routeFileNames)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
foreach ($this->package->routeFileNames as $routeFileName) {
|
||||
$this->loadRoutesFrom("{$this->package->basePath('/../routes/')}{$routeFileName}.php");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
trait ProcessServiceProviders
|
||||
{
|
||||
protected function bootPackageServiceProviders(): self
|
||||
{
|
||||
if (! $this->package->publishableProviderName || ! $this->app->runningInConsole()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$providerName = $this->package->publishableProviderName;
|
||||
$vendorProvider = $this->package->basePath("/../resources/stubs/{$providerName}.php.stub");
|
||||
$appProvider = base_path("app/Providers/{$providerName}.php");
|
||||
|
||||
$this->publishes([$vendorProvider => $appProvider], "{$this->package->shortName()}-provider");
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
trait ProcessTranslations
|
||||
{
|
||||
protected function bootPackageTranslations(): self
|
||||
{
|
||||
if (! $this->package->hasTranslations) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$vendorTranslations = $this->package->basePath('/../resources/lang');
|
||||
$appTranslations = (function_exists('lang_path'))
|
||||
? lang_path("vendor/{$this->package->shortName()}")
|
||||
: resource_path("lang/vendor/{$this->package->shortName()}");
|
||||
|
||||
$this->loadTranslationsFrom($vendorTranslations, $this->package->shortName());
|
||||
|
||||
$this->loadJsonTranslationsFrom($vendorTranslations);
|
||||
$this->loadJsonTranslationsFrom($appTranslations);
|
||||
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->publishes(
|
||||
[$vendorTranslations => $appTranslations],
|
||||
"{$this->package->shortName()}-translations"
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
trait ProcessViewComposers
|
||||
{
|
||||
protected function bootPackageViewComposers(): self
|
||||
{
|
||||
if (empty($this->package->viewComposers)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
foreach ($this->package->viewComposers as $viewName => $viewComposer) {
|
||||
View::composer($viewName, $viewComposer);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
trait ProcessViewSharedData
|
||||
{
|
||||
protected function bootPackageViewSharedData(): self
|
||||
{
|
||||
if (empty($this->package->sharedViewData)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
foreach ($this->package->sharedViewData as $name => $value) {
|
||||
View::share($name, $value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelPackageTools\Concerns\PackageServiceProvider;
|
||||
|
||||
trait ProcessViews
|
||||
{
|
||||
protected function bootPackageViews(): self
|
||||
{
|
||||
if (! $this->package->hasViews) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$namespace = $this->package->viewNamespace;
|
||||
$viewsPath = $this->package->basePath('/../resources/views');
|
||||
$vendorViews = realpath($viewsPath) ?: $viewsPath;
|
||||
$appViews = base_path("resources/views/vendor/{$this->packageView($namespace)}");
|
||||
|
||||
$this->loadViewsFrom($vendorViews, $this->package->viewNamespace());
|
||||
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->publishes([$vendorViews => $appViews], "{$this->packageView($namespace)}-views");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user