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

feat: add shield:model command for make custom UserModel #491

Closed
wants to merge 16 commits into from

Conversation

datamweb
Copy link
Collaborator

@datamweb datamweb commented Oct 31, 2022

This command helps to create custom user model.

  • php spark shield:model MyCustomUser
  • php spark shield:model MyCustomUser --force
  • php spark shield:model MyCustomUser --suffix
  • php spark shield:model MyCustomUser --namespace CodeIgniter\Shield

output

<?php

declare(strict_types=1);

namespace App\Models;

use CodeIgniter\Shield\Models\UserModel;

class MyCustomUser extends UserModel
{
    protected function initialize(): void
    {
        // Merge properties with parent
        $this->allowedFields = array_merge($this->allowedFields, [
            // Add here your custom fields
            // 'first_name',

        ]);
    }
} 

see: ##489 (comment)

@datamweb datamweb added enhancement New feature or request tests needed Pull requests that need tests docs needed Pull requests needing documentation write-ups and/or revisions. labels Oct 31, 2022
@datamweb datamweb marked this pull request as draft October 31, 2022 05:20
@datamweb
Copy link
Collaborator Author

The name php spark shield:make doesn't seem right,
php spark shield:make name are received as class names, do you have any ideas?

Where to add documents? Do we need a new CLI file?

@paulbalandan
Copy link
Member

php spark shield:model?

@datamweb
Copy link
Collaborator Author

php spark shield:model?

I think this is reasonable and good. do you all agree?

@datamweb datamweb removed the tests needed Pull requests that need tests label Nov 2, 2022
@datamweb datamweb force-pushed the CLI-custom-user-model branch from 6e8fa2c to 92ba9d4 Compare November 2, 2022 07:03
@datamweb datamweb removed the docs needed Pull requests needing documentation write-ups and/or revisions. label Nov 2, 2022
@datamweb datamweb marked this pull request as ready for review November 2, 2022 07:40
@datamweb datamweb changed the title feat: add new CLI command For make custom UserModel feat: add shield:model command for make custom UserModel Nov 2, 2022
docs/concepts.md Outdated Show resolved Hide resolved
docs/concepts.md Outdated Show resolved Hide resolved
src/Commands/Generators/UserModelGenerator.php Outdated Show resolved Hide resolved
src/Commands/Generators/Views/usermodel.tpl.php Outdated Show resolved Hide resolved
tests/Commands/UserModelGeneratorTest.php Outdated Show resolved Hide resolved
src/Commands/Generators/UserModelGenerator.php Outdated Show resolved Hide resolved
src/Commands/Generators/UserModelGenerator.php Outdated Show resolved Hide resolved
datamweb and others added 7 commits November 2, 2022 11:42
Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
Copy link
Member

@paulbalandan paulbalandan left a comment

Choose a reason for hiding this comment

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

Also, please git rebase -i so that all commits will be under your name and marked Verified.

docs/concepts.md Outdated Show resolved Hide resolved
Comment on lines +74 to +77

if (is_file($filepath)) {
unlink($filepath);
}
Copy link
Member

Choose a reason for hiding this comment

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

Change this to a $this->assertFileExist test. Deleting the file will be made in tearDown.

tests/Commands/UserModelGeneratorTest.php Outdated Show resolved Hide resolved
tests/Commands/UserModelGeneratorTest.php Outdated Show resolved Hide resolved
src/Commands/Generators/Views/usermodel.tpl.php Outdated Show resolved Hide resolved
datamweb and others added 3 commits November 10, 2022 10:41
Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
@datamweb datamweb marked this pull request as draft November 10, 2022 07:41
@datamweb datamweb force-pushed the CLI-custom-user-model branch from 3047309 to ee29840 Compare November 10, 2022 18:59
@lonnieezell
Copy link
Member

@datamweb @paulbalandan Where does this PR stand? Other than resolving the conflicts is there anything left?

@paulbalandan
Copy link
Member

I'm not sure with @datamweb on the status.

@datamweb datamweb added the stale Pull requests with conflicts label Dec 12, 2022
@datamweb
Copy link
Collaborator Author

Other than resolving the conflicts is there anything left?

Change this to a $this->assertFileExist test. Deleting the file will be made in tearDown.
There is a small problem in the test. I will try to deal with this PR after the 2022-12-17.

It will be great if someone takes over before me.

@lonnieezell
Copy link
Member

Closing this one since another is in its place.

@lonnieezell lonnieezell closed this Jan 2, 2023
@datamweb datamweb deleted the CLI-custom-user-model branch January 5, 2023 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Pull requests with conflicts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants