Skip to content

Commit 3354ac9

Browse files
authored
Merge pull request #5 from AuroraWebSoftware/development
Development
2 parents 824a298 + 2a036ae commit 3354ac9

File tree

7 files changed

+306
-50
lines changed

7 files changed

+306
-50
lines changed

README.md

Lines changed: 84 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
# AIssue for Laravel
22

3+
Basic and Lean Issue Management Package for Laravel
4+
35
[![Latest Version on Packagist](https://img.shields.io/packagist/v/aurorawebsoftware/aissue.svg?style=flat-square)](https://packagist.org/packages/aurorawebsoftware/aissue)
46
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/aurorawebsoftware/aissue/run-tests?label=tests)](https://github.com/aurorawebsoftware/aissue/actions?query=workflow%3Arun-tests+branch%3Amain)
57
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/aurorawebsoftware/aissue/Check%20&%20fix%20styling?label=code%20style)](https://github.com/aurorawebsoftware/aissue/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain)
68
[![Total Downloads](https://img.shields.io/packagist/dt/aurorawebsoftware/aissue.svg?style=flat-square)](https://packagist.org/packages/aurora/aissue)
79

8-
Todo ....
910

1011
# Features
1112

12-
- Todo ...
13-
13+
- Basic Workflow and Issue Management
14+
- Limitless Issue Types
15+
- Limitless Statuses for Issue Types
16+
- Authenticatable Issue Status Transitions
17+
- Easy to Use and Lean
1418
---
1519

1620

@@ -24,15 +28,15 @@ You can install the package via composer:
2428
composer require aurorawebsoftware/aissue
2529
```
2630

27-
Todo
31+
You must add AIssueModelTrait Trait to the **Issueable** Model and The model must implement **AIssueModelContract**
2832

2933
```php
30-
use Illuminate\Foundation\Auth\User as Authenticatable;
31-
use AuroraWebSoftware\aissue\Traits\aissueUser;
34+
use AuroraWebSoftware\AIssue\Contracts\AIssueModelContract;
35+
use AuroraWebSoftware\AIssue\Traits\AIssueModelTrait;
3236

33-
class User extends Authenticatable
37+
class Issueable extends Model implements AIssueModelContract
3438
{
35-
use ;
39+
use AIssueModelTrait;;
3640

3741
// ...
3842
}
@@ -44,56 +48,103 @@ You can publish and run the migrations with:
4448
php artisan migrate
4549
```
4650

47-
You can publish the sample data seeder with:
48-
49-
```bash
50-
php artisan vendor:publish --tag="aissue-seeders"
51-
php artisan db:seed --class=SampleDataSeeder
52-
```
53-
54-
Optionally, You can seed the sample data with:
55-
56-
```bash
57-
php artisan db:seed --class=SampleDataSeeder
58-
```
59-
6051
You can publish the config file with:
6152

6253
```bash
6354
php artisan vendor:publish --tag="aissue-config"
6455
```
6556

6657
This is the example contents of the published config file:
58+
```bash
6759

68-
```php
69-
return [
70-
];
60+
return [
61+
'policyMethod' => fn ($permission): bool => true,
62+
'issueTypes' => [
63+
'task' => [
64+
'todo' => ['sort' => 1, 'permission' => 'todo_perm'],
65+
'in_progress' => ['sort' => 2, 'permission' => 'in_progress_perm'],
66+
'done' => ['sort' => 3, 'permission' => 'done_perm'],
67+
],
68+
],
69+
];
7170
```
7271

73-
# Main Philosophy
74-
Todo
72+
**Permission Config File**
73+
74+
Permissions are stored `config/aissue.php` is published after installing
7575

76-
---
77-
> If you don't need organizational roles, **aissue** may not be suitable for your work.
78-
---
7976

8077
# Aissue Terminology
8178

82-
Before using aissue its worth to understand the main terminology of aissue.
83-
aissue differs from other Auth Packages due to its organizational structure.
79+
Before using AIssue its worth to understand the main terminology of AIssue.
80+
The difference of Issue from other packages is that it perform simple-level workflows with its simplified structure.
8481

8582

8683
# Usage
8784

8885
Before using this, please make sure that you published the config files.
8986

9087

91-
## aissue Service and Facade Methods
88+
## AIssue Services, Service Provider and Facade
9289

93-
### todo
90+
// todo
9491

92+
### Creating an Issuable
9593
```php
9694

95+
$createdModel = Issueable::create(
96+
['name' => 'example isuable model']
97+
);
98+
```
99+
100+
### Making a transition for todo, in_progres and done
101+
```php
102+
103+
$createdModel = Issueable::create(
104+
['name' => 'example isuable model']
105+
);
106+
107+
/** @var AIssue $createdIssueModel */
108+
$createdIssueModel = $createdModel->createIssue(1, 1, 'example', 'example isssue', 'example', 1, \Illuminate\Support\Carbon::now());
109+
//todo,in_progress,done
110+
$createdIssueModel->canMakeTransition('todo')
111+
112+
```
113+
114+
### Getting transitionable statuses
115+
```php
116+
117+
$createdModel = Issueable::create(
118+
['name' => 'example isuable model 4']
119+
);
120+
121+
/** @var AIssue $createdIssueModel */
122+
$createdIssueModel = $createdModel->createIssue(1, 1, 'example', 'example isssue', 'example', 1, \Illuminate\Support\Carbon::now());
123+
$transitionable = $createdIssueModel->getTransitionableStatuses($createdIssueModel);
124+
125+
$this->assertTrue($transitionable == ["todo","in_progress"]);
126+
127+
```
128+
129+
### Using AIssue Interface and Trait with Eloquent Models
130+
To turn an Eloquent Model into an AIssue ;
131+
Model must implement AIssueModelContract and use AIssueModelTrait Trait.
132+
After adding AIssueModelContract trait, you will be able to use AIssue methods within the model
133+
```php
134+
135+
namespace App\Models\ExampleModel;
136+
137+
use AuroraWebSoftware\AIssue\Contracts\AIssueModelContract;
138+
use AuroraWebSoftware\AIssue\Traits\AIssueModelTrait;
139+
use Illuminate\Database\Eloquent\Model;
140+
141+
class ExampleModel extends Model implements AIssueModelContract
142+
{
143+
use AIssueModelTrait;
144+
145+
// implementation
146+
}
147+
97148
```
98149

99150

@@ -107,7 +158,6 @@ Please see [CONTRIBUTING](README-contr.md) for details.
107158

108159
## Security Vulnerabilities
109160

110-
// todo ?
111161
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
112162

113163

src/AIssue.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ public function makeTransition(Models\AIssue $issue, string $status): Models\AIs
4242
if ($this->canMakeTransition($issue, $status)) {
4343
$issue->status = $status;
4444
$issue->save();
45-
}
4645

46+
return $issue;
47+
}
4748
throw new TransitionPermissionException();
4849
}
4950

src/AIssueServiceProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public function boot(): void
2828
parent::boot();
2929
// load packages migrations
3030
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
31-
3231
$this->publishes([
3332
__DIR__.'/../config' => config_path(),
3433
], 'aissue-config');
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace AuroraWebSoftware\AIssue\Exceptions;
4+
5+
use Illuminate\Auth\AuthenticationException;
6+
7+
class IssueTypeNotFoundException extends AuthenticationException
8+
{
9+
}

src/Traits/AIssueModelTrait.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace AuroraWebSoftware\AIssue\Traits;
44

5+
use AuroraWebSoftware\AIssue\Exceptions\IssueTypeNotFoundException;
56
use AuroraWebSoftware\AIssue\Facades\AIssue;
67
use Illuminate\Support\Carbon;
78

@@ -16,6 +17,8 @@ trait AIssueModelTrait
1617
* @param int $priority
1718
* @param Carbon $duedate
1819
* @return \AuroraWebSoftware\AIssue\Models\AIssue
20+
*
21+
* @throws IssueTypeNotFoundException
1922
*/
2023
public function createIssue(
2124
int $assigneeId,
@@ -26,7 +29,11 @@ public function createIssue(
2629
int $priority,
2730
Carbon $duedate,
2831
): \AuroraWebSoftware\AIssue\Models\AIssue {
29-
// todo issueType Kontrolü
32+
$configIssueTypes = config('aissue')['issueTypes'];
33+
if (! array_key_exists($issueType, $configIssueTypes)) {
34+
throw new IssueTypeNotFoundException("$issueType Not Found, Please check Your Config File.");
35+
}
36+
3037
// todo status yetki kontrolü
3138

3239
$data = [

tests/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ protected function getPackageProviders($app)
2626

2727
public function getEnvironmentSetUp($app)
2828
{
29-
//config()->set('database.default', 'testing');
30-
config()->set('database.default', 'mysql');
29+
config()->set('database.default', 'testing');
30+
// config()->set('database.default', 'mysql');
3131

3232
/*
3333
$migration = include __DIR__.'/../database/migrations/create_aissue_table.php.stub';

0 commit comments

Comments
 (0)