Skip to content

Conversation

neellii
Copy link

@neellii neellii commented Sep 12, 2025

No description provided.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 17669561026

Details

  • 27 of 27 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 98.966%

Totals Coverage Status
Change from base Build 17647802486: 0.1%
Covered Lines: 287
Relevant Lines: 290

💛 - Coveralls

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for generating additional admin migrations when setting up Laravel projects with Telescope and Nova admin panels. It handles different authentication types (none vs Clerk) and creates appropriate migration files for additional admin users.

  • Adds logic to track and create admin migrations based on authentication type
  • Implements separate handling for users table vs admins table depending on auth configuration
  • Updates test fixtures to validate the new admin migration functionality

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Commands/InitCommand.php Adds core logic for publishing additional admin migrations with auth type handling
resources/views/users_add_additional_admin.blade.php Template for adding admin users to users table
resources/views/admins_create_or_add_additional_admin.blade.php Template for creating/adding to admins table
tests/InitCommandTest.php Updates tests to validate new admin migration behavior
tests/fixtures/InitCommandTest/*.php Test fixture files for various admin migration scenarios
Comments suppressed due to low confidence (1)

resources/views/admins_create_or_add_additional_admin.blade.php:1

  • The down() method attempts to delete a specific admin record after dropping the entire admins table. This will fail because the table no longer exists. The deletion should happen before dropping the table, or the table drop should be conditional on whether this migration created it.
use Illuminate\Database\Migrations\Migration;

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

$defaultPassword = substr(md5(uniqid()), 0, 8);

$email = $this->ask("Please enter a {$title}'s admin email", "admin@{$kebabName}.com");
$email = $this->ask("Please enter a {$title}'s admin email", "{$key}_admin@{$kebabName}.com");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$email = $this->ask("Please enter a {$title}'s admin email", "{$key}_admin@{$kebabName}.com");
$email = $this->ask("Please enter a {$title}'s admin email", "admin.{$key}@{$kebabName}.com");

$email = $this->ask("Please enter a {$title}'s admin email", "{$key}_admin@{$kebabName}.com");
$password = $this->ask("Please enter a {$title}'s admin password", $defaultPassword);

$this->publishAdditionalAdminMigration($title, $key, $email, $password);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we use createAdminUser method instead of all else block? It looks it make the same but need to add more arguments to it

'email' => $adminEmail,
'password' => $adminPassword,
'credentialName' => $credentialName,
'isAdminsCreated' => $this->isAdminsTableCreated,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may we just check that the $adminCredentials property is not empty instead of storing isAdminsTableCreated field?

use Illuminate\Database\Schema\Blueprint;
@endif

class Add{{ ucfirst($credentialName) }}Admin extends Migration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class Add{{ ucfirst($credentialName) }}Admin extends Migration
class Add{{ ucfirst($serviceName) }}Admin extends Migration


public function up(): void
{
@if (!$isAdminsCreated)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@if (!$isAdminsCreated)
@if (!$needToCreateTable)

public function up(): void
{
@if (!$isAdminsCreated)
Schema::create('admins', function (Blueprint $table) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that we need to publish already exists migration admins_create_table.blade.php in the base command before publish this migration

@DenTray DenTray assigned neellii and unassigned DenTray Sep 18, 2025
@neellii neellii assigned DenTray and unassigned neellii Sep 26, 2025
}

protected function createAdminUser(string $kebabName): void
protected function createAdminUser(string $kebabName, string $serviceName = '', string $adminPrefix = 'an'): array
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected function createAdminUser(string $kebabName, string $serviceName = '', string $adminPrefix = 'an'): array
protected function createAdminUser(string $kebabName, string $serviceKey = '', string $serviceName = ''): array

protected function createAdminUser(string $kebabName): void
protected function createAdminUser(string $kebabName, string $serviceName = '', string $adminPrefix = 'an'): array
{
$adminEmail = $serviceName ? "admin.{$serviceName}@{$kebabName}.com" : "admin@{$kebabName}.com";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$adminEmail = $serviceName ? "admin.{$serviceName}@{$kebabName}.com" : "admin@{$kebabName}.com";
$adminEmail = when($serviceName, "admin.{$serviceName}@{$kebabName}.com", "admin@{$kebabName}.com");

'email' => $this->ask('Please enter an admin email', "admin@{$kebabName}.com"),
'password' => $this->ask('Please enter an admin password', $defaultPassword),
$adminCredentials = [
'email' => $this->ask("Please enter {$adminPrefix} admin email", $adminEmail),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'email' => $this->ask("Please enter {$adminPrefix} admin email", $adminEmail),
'email' => $this->ask("Please enter admin email for {$serviceName}", $adminEmail),

if (!empty($this->adminCredentials) && $this->confirm("Is {$title}'s admin the same as default one?", true)) {
$email = $this->adminCredentials['email'];
$password = $this->adminCredentials['password'];
if (isset($this->adminCredentials['email']) && $this->confirm("Is {$title}'s admin the same as default one?", true)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (isset($this->adminCredentials['email']) && $this->confirm("Is {$title}'s admin the same as default one?", true)) {
if (!empty($this->adminCredentials) && $this->confirm("Is {$title}'s admin the same as default one?", true)) {

Comment on lines +398 to +399
$adminCredentials['email'] = $this->adminCredentials['email'];
$adminCredentials['password'] = $this->adminCredentials['password'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$adminCredentials['email'] = $this->adminCredentials['email'];
$adminCredentials['password'] = $this->adminCredentials['password'];
$adminCredentials = $this->adminCredentials;


$adminCredentials['migrationName'] = Str::studly($migrationName);
} else {
$viewName = $migrationName = 'admins_create_table';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure that such view is exists. Anyway, let's pusblish migration for the admins table creation outside of this method just after we decided that need to create user with the cleark auth

@DenTray DenTray assigned neellii and unassigned DenTray Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants