Skip to content

Commit

Permalink
bug(#12): incompatibility with laravel helium (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
vorban authored Jan 21, 2025
2 parents a174067 + 0056327 commit 5c3d48c
Show file tree
Hide file tree
Showing 27 changed files with 147 additions and 216 deletions.
70 changes: 1 addition & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,75 +9,7 @@ Laravel Admin made with Helium UI

## Installation

You can install the package via composer:

```bash
composer require webup/helium-core
```

You should publish config and components
```bash
sail artisan vendor:publish
```

You can publish features as you go with:

```bash
php artisan helium:publish
```

Publishing a feature will copy paste every file associated with it.
This includes:
- config, controllers, models
- migrations, routes
- js, css
- x-components, livewire components, blade views

## :warning: Configuration :warning:

Make sure to configure this package to suit your preferences before starting to publish anything.

## Features

### Admin User management

This feature packs an AdminUser model along with its migration,
a default `{email: 'admin', password: 'password'}` entry,
and CRUD routes + pages.

```bash
php artisan helium:publish
> User
```

Don't forget to add the guard and provider to `config/auth.php`:
```php
<?php

return [
...
'guards' => [
...
'admin' => [
'driver' => 'session',
'provider' => 'admin_users',
],
],

'providers' => [
...
'admin_users' => [
'driver' => 'eloquent',
'model' => App\Models\Admin\AdminUser::class,
],
],
];
```

### Datatable

[doc](docs/datatable.md)

See [installation instructions](./docs/installation.md).
## Testing

```bash
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
},
"autoload": {
"psr-4": {
"Webup\\Helium\\": "src/",
"Webup\\Helium\\Database\\Factories\\": "database/factories/"
"Webup\\Helium\\": "src/"
}
},
"autoload-dev": {
Expand All @@ -57,7 +56,8 @@
"Webup\\Helium\\HeliumServiceProvider"
],
"aliases": {
"Helium": "Webup\\Helium\\Facades\\Helium"
"Helium": "Webup\\Helium\\Facades\\Helium",
"Setting": "Webup\\Helium\\Facades\\Setting"
}
}
},
Expand Down
31 changes: 22 additions & 9 deletions config/helium.php → config/helium-core.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| route-prefix
|--------------------------------------------------------------------------
|
| The URL prefix for all helium routes.
|
*/
'route' => [
/*
|--------------------------------------------------------------------------
| route.prefix
|--------------------------------------------------------------------------
|
| The URL prefix for all helium routes.
|
*/

'prefix' => 'helium',

'route-prefix' => 'helium',
/*
|--------------------------------------------------------------------------
| route.as
|--------------------------------------------------------------------------
|
| The alias for all helium routes.
|
*/

'as' => 'helium::',
],

/*
|--------------------------------------------------------------------------
Expand Down
19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
public function up()
{
Schema::create(config('helium.database.users-table'), function (Blueprint $table) {
Schema::create(config('helium-core.database.users-table'), function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->rememberToken();
Expand All @@ -21,6 +21,6 @@ public function up()

public function down()
{
Schema::dropIfExists(config('helium.database.users-table'));
Schema::dropIfExists(config('helium-core.database.users-table'));
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
public function up()
{
Schema::create(config('helium.database.settings-table'), function (Blueprint $table) {
Schema::create(config('helium-core.database.settings-table'), function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->string('value')->nullable();
Expand All @@ -18,6 +18,6 @@ public function up()

public function down()
{
Schema::dropIfExists(config('helium.database.settings-table'));
Schema::dropIfExists(config('helium-core.database.settings-table'));
}
};
38 changes: 23 additions & 15 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,27 @@ since it's the default for any new Laravel project.*
composer require webup/helium-core
# or, if you live on the edge:
composer require webup/helium-core:@dev
```

### Publishing and customizing the default configuration

`config/helium-core.php` is published along with all the other assets.

You should check to see if the default values suit your requirements.
Most likely, the `user` keyword is already used as your main authentication label.

Helium allows you to change the database table names, along with the name
of the guard and auth provider that will be automatically declared

```sh
# publish the configuration first
artisan vendor:publish --tag=helium-core-config

# /!\ now is the time to configure the package /!\
nano config/helium-core.php

# publish all needed files
artisan vendor:publish --tag=helium
artisan vendor:publish --tag=helium-core
```

### Setting up the frontend assets build
Expand All @@ -35,8 +53,8 @@ In order to unlock the full power of tailwind and helium's customizability,
the package publishes its frontend assets to your application.

The frontend assets are published to:
- `resources/js/vendor/helium/`
- `resources/css/vendor/helium/`
- `resources/js/vendor/helium-core/`
- `resources/css/vendor/helium-core/`

You can now update your `vite.config.js` to build the new js/css files:
```js
Expand All @@ -48,25 +66,15 @@ export default defineConfig({
'resources/js/app.js',

// add the helium assets to the build
'resources/css/vendor/helium/app.css',
'resources/js/vendor/helium/app.js',
'resources/css/vendor/helium-core/app.css',
'resources/js/vendor/helium-core/app.js',
],
refresh: true,
}),
],
});
```

### Checking the default configuration

`config/helium.php` is published along with all the other assets.

You should check to see if the default values suit your requirements.
Most likely, the `user` keyword is already used as your main authentication label.

Helium allows you to change the database table names, along with the name
of the guard and provider that will be automatically declared.

### Running the migrations

The default helium user has the following credentials: `[email protected]; password`.
Expand Down
7 changes: 3 additions & 4 deletions resources/views/components/layout/auth.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
<head>
<meta charset="UTF-8">
<title>{{ $title }}</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
@vite('resources/css/vendor/helium/app.css')
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@vite('resources/css/vendor/helium-core/app.css')
</head>

<body class="flex min-h-screen items-center justify-center bg-slate-200">
{{ $slot }}
@vite('resources/js/vendor/helium/app.js')
@vite('resources/js/vendor/helium-core/app.js')
</body>

</html>
20 changes: 8 additions & 12 deletions resources/views/components/layout/main.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@

<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible"
content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

@livewireStyles
@vite('resources/css/vendor/helium/app.css')
@vite('resources/css/vendor/helium-core/app.css')
{{ $css }}
{{ $cssStack }}

Expand All @@ -29,11 +27,11 @@
<main class="flex">
<div class="fixed inset-y-0 left-0 w-64 overflow-auto border-r border-[#E1E6EA] bg-white pb-4 pt-5">
<div class="flex flex-shrink-0 flex-grow flex-col px-3 pb-[70px]">
<x-helium::layout.element.icon class="mb-5 w-10" />
<x-helium::menu />
<x-helium-core::layout.element.icon class="mb-5 w-10" />
<x-helium-core::menu />
</div>
<div class="fixed bottom-0 w-64 border-r border-[#E1E6EA] bg-white">
<x-helium::layout.element.profil />
<x-helium-core::layout.element.profil />
</div>
</div>
<div class="ml-[16rem] grow">
Expand All @@ -44,14 +42,12 @@
</div>
</main>

<form id="logout-form"
action="{{ route('helium::logout') }}"
method="post">
<form id="logout-form" action="{{ Helium::route('logout') }}" method="post">
@csrf
</form>

@livewireScripts
@vite('resources/js/vendor/helium/app.js')
@vite('resources/js/vendor/helium-core/app.js')
{{ $js }}
{{ $jsStack }}
</body>
Expand Down
14 changes: 5 additions & 9 deletions resources/views/components/menu/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<div class="space-y-1">
<x-helium::menu.item icon="tabler-users-group"
:opened="Route::is('helium::user.*')">
<x-helium-core::menu.item icon="tabler-users-group" :opened="Helium::isRoute('user.*')">
Helium Users
<x-slot:sublevel>
<x-helium::menu.sub :url="route('helium::user.index')"
:current="Route::is('helium::user.*')">Users</x-helium::menu.sub>
<x-helium::menu.sub url="#">Roles</x-helium::menu.sub>
<x-helium-core::menu.sub :url="Helium::route('user.index')" :current="Helium::isRoute('user.*')">Users</x-helium-core::menu.sub>
<x-helium-core::menu.sub url="#">Roles</x-helium-core::menu.sub>
</x-slot:sublevel>
</x-helium::menu.item>
</x-helium-core::menu.item>

<x-helium::menu.item url="{{ route('helium::setting.index') }}"
icon="tabler-settings"
:current="Route::is('helium::setting.*')">Settings</x-helium::menu.item>
<x-helium-core::menu.item url="{{ Helium::route('setting.index') }}" icon="tabler-settings" :current="Helium::isRoute('setting.*')">Settings</x-helium-core::menu.item>
</div>
2 changes: 1 addition & 1 deletion resources/views/livewire/user-table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</thead>
<tbody>
@foreach ($this->users as $user)
<tr data-link="{{ route('helium::user.edit', $user->id) }}">
<tr data-link="{{ Helium::route('user.edit', $user->id) }}">
<td class="text-right">{{ $user->id }}</td>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
Expand Down
24 changes: 8 additions & 16 deletions resources/views/pages/login.blade.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
<x-helium::layout.auth title="Log in">
<form action="{{ route('helium::postLogin') }}"
method="post">
<x-helium-core::layout.auth title="Log in">
<form action="{{ Helium::route('postLogin') }}" method="post">
@csrf
<x-helium::box>
<x-helium::form.input label="Email"
type="email"
name="email"
required />
<x-helium-core::box>
<x-helium-core::form.input label="Email" type="email" name="email" required />

<x-helium::form.input label="Password"
type="password"
name="password"
required />
<x-helium::button label="Login"
class="mt-3 w-full" />
</x-helium::box>
<x-helium-core::form.input label="Password" type="password" name="password" required />
<x-helium-core::button label="Login" class="mt-3 w-full" />
</x-helium-core::box>
</form>
</x-helium::layout.auth>
</x-helium-core::layout.auth>
Loading

0 comments on commit 5c3d48c

Please sign in to comment.