Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 84 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# AIssue for Laravel

Basic and Lean Issue Management Package for Laravel

[![Latest Version on Packagist](https://img.shields.io/packagist/v/aurorawebsoftware/aissue.svg?style=flat-square)](https://packagist.org/packages/aurorawebsoftware/aissue)
[![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)
[![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)
[![Total Downloads](https://img.shields.io/packagist/dt/aurorawebsoftware/aissue.svg?style=flat-square)](https://packagist.org/packages/aurora/aissue)

Todo ....

# Features

- Todo ...

- Basic Workflow and Issue Management
- Limitless Issue Types
- Limitless Statuses for Issue Types
- Authenticatable Issue Status Transitions
- Easy to Use and Lean
---


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

Todo
You must add AIssueModelTrait Trait to the **Issueable** Model and The model must implement **AIssueModelContract**

```php
use Illuminate\Foundation\Auth\User as Authenticatable;
use AuroraWebSoftware\aissue\Traits\aissueUser;
use AuroraWebSoftware\AIssue\Contracts\AIssueModelContract;
use AuroraWebSoftware\AIssue\Traits\AIssueModelTrait;

class User extends Authenticatable
class Issueable extends Model implements AIssueModelContract
{
use ;
use AIssueModelTrait;;

// ...
}
Expand All @@ -44,56 +48,103 @@ You can publish and run the migrations with:
php artisan migrate
```

You can publish the sample data seeder with:

```bash
php artisan vendor:publish --tag="aissue-seeders"
php artisan db:seed --class=SampleDataSeeder
```

Optionally, You can seed the sample data with:

```bash
php artisan db:seed --class=SampleDataSeeder
```

You can publish the config file with:

```bash
php artisan vendor:publish --tag="aissue-config"
```

This is the example contents of the published config file:
```bash

```php
return [
];
return [
'policyMethod' => fn ($permission): bool => true,
'issueTypes' => [
'task' => [
'todo' => ['sort' => 1, 'permission' => 'todo_perm'],
'in_progress' => ['sort' => 2, 'permission' => 'in_progress_perm'],
'done' => ['sort' => 3, 'permission' => 'done_perm'],
],
],
];
```

# Main Philosophy
Todo
**Permission Config File**

Permissions are stored `config/aissue.php` is published after installing

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

# Aissue Terminology

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


# Usage

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


## aissue Service and Facade Methods
## AIssue Services, Service Provider and Facade

### todo
// todo

### Creating an Issuable
```php

$createdModel = Issueable::create(
['name' => 'example isuable model']
);
```

### Making a transition for todo, in_progres and done
```php

$createdModel = Issueable::create(
['name' => 'example isuable model']
);

/** @var AIssue $createdIssueModel */
$createdIssueModel = $createdModel->createIssue(1, 1, 'example', 'example isssue', 'example', 1, \Illuminate\Support\Carbon::now());
//todo,in_progress,done
$createdIssueModel->canMakeTransition('todo')

```

### Getting transitionable statuses
```php

$createdModel = Issueable::create(
['name' => 'example isuable model 4']
);

/** @var AIssue $createdIssueModel */
$createdIssueModel = $createdModel->createIssue(1, 1, 'example', 'example isssue', 'example', 1, \Illuminate\Support\Carbon::now());
$transitionable = $createdIssueModel->getTransitionableStatuses($createdIssueModel);

$this->assertTrue($transitionable == ["todo","in_progress"]);

```

### Using AIssue Interface and Trait with Eloquent Models
To turn an Eloquent Model into an AIssue ;
Model must implement AIssueModelContract and use AIssueModelTrait Trait.
After adding AIssueModelContract trait, you will be able to use AIssue methods within the model
```php

namespace App\Models\ExampleModel;

use AuroraWebSoftware\AIssue\Contracts\AIssueModelContract;
use AuroraWebSoftware\AIssue\Traits\AIssueModelTrait;
use Illuminate\Database\Eloquent\Model;

class ExampleModel extends Model implements AIssueModelContract
{
use AIssueModelTrait;

// implementation
}

```


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

## Security Vulnerabilities

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


Expand Down
3 changes: 2 additions & 1 deletion src/AIssue.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public function makeTransition(Models\AIssue $issue, string $status): Models\AIs
if ($this->canMakeTransition($issue, $status)) {
$issue->status = $status;
$issue->save();
}

return $issue;
}
throw new TransitionPermissionException();
}

Expand Down
1 change: 0 additions & 1 deletion src/AIssueServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function boot(): void
parent::boot();
// load packages migrations
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');

$this->publishes([
__DIR__.'/../config' => config_path(),
], 'aissue-config');
Expand Down
9 changes: 9 additions & 0 deletions src/Exceptions/IssueTypeNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AuroraWebSoftware\AIssue\Exceptions;

use Illuminate\Auth\AuthenticationException;

class IssueTypeNotFoundException extends AuthenticationException
{
}
9 changes: 8 additions & 1 deletion src/Traits/AIssueModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace AuroraWebSoftware\AIssue\Traits;

use AuroraWebSoftware\AIssue\Exceptions\IssueTypeNotFoundException;
use AuroraWebSoftware\AIssue\Facades\AIssue;
use Illuminate\Support\Carbon;

Expand All @@ -16,6 +17,8 @@ trait AIssueModelTrait
* @param int $priority
* @param Carbon $duedate
* @return \AuroraWebSoftware\AIssue\Models\AIssue
*
* @throws IssueTypeNotFoundException
*/
public function createIssue(
int $assigneeId,
Expand All @@ -26,7 +29,11 @@ public function createIssue(
int $priority,
Carbon $duedate,
): \AuroraWebSoftware\AIssue\Models\AIssue {
// todo issueType Kontrolü
$configIssueTypes = config('aissue')['issueTypes'];
if (! array_key_exists($issueType, $configIssueTypes)) {
throw new IssueTypeNotFoundException("$issueType Not Found, Please check Your Config File.");
}

// todo status yetki kontrolü

$data = [
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ protected function getPackageProviders($app)

public function getEnvironmentSetUp($app)
{
//config()->set('database.default', 'testing');
config()->set('database.default', 'mysql');
config()->set('database.default', 'testing');
// config()->set('database.default', 'mysql');

/*
$migration = include __DIR__.'/../database/migrations/create_aissue_table.php.stub';
Expand Down
Loading