-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1d653d
commit fb27707
Showing
49 changed files
with
935 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,57 @@ | ||
<?php | ||
/** | ||
* Playground | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Configuration and Environment Variables | ||
*/ | ||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| About Information | ||
|-------------------------------------------------------------------------- | ||
| | ||
| By default, information will be displayed about this package when using: | ||
| | ||
| `artisan about` | ||
| | ||
*/ | ||
|
||
'about' => (bool) env('PLAYGROUND_MATRIX_ABOUT', true), | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Loading | ||
|-------------------------------------------------------------------------- | ||
| | ||
| By default, migrations are disabled. | ||
| | ||
*/ | ||
|
||
'load' => [ | ||
'migrations' => (bool) env('PLAYGROUND_MATRIX_LOAD_MIGRATIONS', false), | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Projects and tickets | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The default key to use for tickets. | ||
| This is not case-sensitive, queries use LIKE. | ||
| | ||
| Examples: GH, TICKET, SomeThing, Dashes-are-OK | ||
| - emojis technically should work, but it may be a bad UX in the UI. | ||
*/ | ||
|
||
'keys' => [ | ||
'default' => env('PLAYGROUND_MATRIX_KEYS_DEFAULT', ''), | ||
|
||
'allow_empty' => (bool) env('PLAYGROUND_MATRIX_KEYS_ALLOW_EMPTY', true), | ||
], | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* Playground | ||
*/ | ||
|
||
declare(strict_types=1); | ||
namespace Playground\Matrix\Concerns; | ||
|
||
use Playground\Matrix\Models\Ticket; | ||
|
||
/** | ||
* \Playground\Matrix\Concerns\Creating | ||
*/ | ||
trait Creating | ||
{ | ||
protected function getProjectKey(Ticket $ticket): string | ||
{ | ||
$key = config('playground-matrix.keys.default'); | ||
$key = is_string($key) ? $key : ''; | ||
|
||
$project = $ticket->project_id ? $ticket->project()->first() : null; | ||
|
||
if ($project) { | ||
if (! $project->key) { | ||
if (config('playground-matrix.keys.allow_empty')) { | ||
$key = ''; | ||
} | ||
} else { | ||
$key = $project->key; | ||
} | ||
} | ||
|
||
return $key; | ||
} | ||
|
||
protected function handleTicketCode(Ticket $ticket): void | ||
{ | ||
if (empty($ticket->project_id)) { | ||
return; | ||
} | ||
|
||
$ticket->key = $this->getProjectKey($ticket); | ||
|
||
if (! $ticket->key && ! config('playground-matrix.keys.allow_empty')) { | ||
return; | ||
} | ||
|
||
$code = Ticket::where('key', 'LIKE', $ticket->key)->max('code'); | ||
$next = $code > 0 ? ++$code : 1; | ||
$slug = sprintf( | ||
'%1$s%2$s%3$d', | ||
$ticket->key, | ||
$ticket->key ? '-' : '', | ||
$next | ||
); | ||
|
||
$ticket->code = $next; | ||
$ticket->slug = $slug; | ||
$ticket->key_code_hash = md5($slug); | ||
} | ||
} |
Oops, something went wrong.