-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
51 changed files
with
2,468 additions
and
756 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"overrides": [ | ||
{ | ||
"files": ["*.yml", "*.yaml"], | ||
"options": { | ||
"tabWidth": 2 | ||
} | ||
} | ||
] | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events; | ||
|
||
use App\Models\Ticket; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class TicketCreated | ||
{ | ||
use Dispatchable; | ||
use InteractsWithSockets; | ||
use SerializesModels; | ||
|
||
public Ticket $ticket; | ||
|
||
/** | ||
* Create a new event instance. | ||
*/ | ||
public function __construct(Ticket $ticket) | ||
{ | ||
$this->ticket = $ticket; | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events; | ||
|
||
use App\Models\TicketMessage; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class TicketReplyReceived | ||
{ | ||
use Dispatchable; | ||
use InteractsWithSockets; | ||
use SerializesModels; | ||
|
||
public TicketMessage $message; | ||
|
||
/** | ||
* Create a new event instance. | ||
*/ | ||
public function __construct(TicketMessage $message) | ||
{ | ||
$this->message = $message; | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events; | ||
|
||
use App\Models\Ticket; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class TicketUpdated | ||
{ | ||
use Dispatchable; | ||
use InteractsWithSockets; | ||
use SerializesModels; | ||
|
||
public Ticket $ticket; | ||
|
||
/** | ||
* Create a new event instance. | ||
*/ | ||
public function __construct(Ticket $ticket) | ||
{ | ||
$this->ticket = $ticket; | ||
} | ||
} |
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,155 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Forms\Components; | ||
|
||
use BackedEnum; | ||
use Carbon\Carbon; | ||
use Closure; | ||
use Filament\Forms\Components\Component; | ||
use Filament\Forms\Components\Concerns; | ||
use Illuminate\Contracts\Support\Htmlable; | ||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\HtmlString; | ||
use Illuminate\Support\Str; | ||
use Illuminate\Support\Stringable; | ||
|
||
class Value extends Component | ||
{ | ||
use Concerns\HasHelperText; | ||
use Concerns\HasHint; | ||
use Concerns\HasName; | ||
|
||
protected string $view = 'components.forms.value'; | ||
|
||
protected bool $empty = false; | ||
|
||
protected string | Htmlable | Closure | null $content = null; | ||
|
||
protected string | Htmlable | Closure | null $fallback = null; | ||
|
||
protected $withTime = false; | ||
|
||
protected array $boolean = []; | ||
|
||
final public function __construct(string $name) | ||
{ | ||
$this->name($name); | ||
$this->statePath($name); | ||
} | ||
|
||
public static function make(string $name): static | ||
{ | ||
$static = app(static::class, ['name' => $name]); | ||
$static->configure(); | ||
|
||
return $static; | ||
} | ||
|
||
public function empty(): static | ||
{ | ||
$this->empty = true; | ||
|
||
return $this; | ||
} | ||
|
||
public function boolean(string | Htmlable | null $trueLabel = null, string | Htmlable | null $falseLabel = null): static | ||
{ | ||
$this->boolean = [ | ||
1 => $trueLabel ?? __('forms::components.select.boolean.true'), | ||
0 => $falseLabel ?? __('forms::components.select.boolean.false'), | ||
]; | ||
|
||
return $this; | ||
} | ||
|
||
public function fallback(string | Htmlable | Closure | null $fallback): static | ||
{ | ||
$this->fallback = $fallback; | ||
|
||
return $this; | ||
} | ||
|
||
public function getFallback(): string | Htmlable | null | ||
{ | ||
return $this->evaluate($this->fallback); | ||
} | ||
|
||
public function content(string | Htmlable | Closure | null $content): static | ||
{ | ||
$this->content = $content; | ||
|
||
return $this; | ||
} | ||
|
||
public function getContent(): string | Htmlable | null | ||
{ | ||
if ($this->empty) { | ||
return null; | ||
} | ||
|
||
$content = $this->evaluate($this->content) ?? data_get($this->getRecord(), $this->getName()); | ||
|
||
if (! empty($this->boolean)) { | ||
$content = $this->boolean[\intval(\boolval($content))]; | ||
} | ||
|
||
$content = match (true) { | ||
$content instanceof BackedEnum => $this->getEnumLabel($content), | ||
$content instanceof Carbon => $this->getFormattedDate($content), | ||
$content instanceof Collection => $this->getFormattedCollection($content), | ||
default => $content, | ||
}; | ||
|
||
if (! $content instanceof HtmlString) { | ||
$content = Str::of($content) | ||
->trim() | ||
->toHtmlString(); | ||
} | ||
|
||
if (! $content->isEmpty()) { | ||
return $content; | ||
} | ||
|
||
if (null !== $fallback = $this->getFallback()) { | ||
return new HtmlString('<div class="italic">' . $fallback . '</div>'); | ||
} | ||
|
||
return new HtmlString('<span class="text-gray-500">—</span>'); | ||
} | ||
|
||
public function withTime(bool $condition = true): static | ||
{ | ||
$this->withTime = $condition; | ||
|
||
return $this; | ||
} | ||
|
||
protected function getFormattedCollection(Collection $collection, string $glue = ', '): string | ||
{ | ||
return $collection | ||
->map(fn ($item) => match (true) { | ||
$item instanceof Htmlable => $item->toHtml(), | ||
$item instanceof Stringable => $item->toString(), | ||
default => $item | ||
}) | ||
->join($glue); | ||
} | ||
|
||
protected function getFormattedDate(Carbon $date): string | ||
{ | ||
return $this->withTime | ||
? $date->toFormattedDateTime() | ||
: $date->toFormattedDate(); | ||
} | ||
|
||
protected function getEnumLabel(BackedEnum $content): ?string | ||
{ | ||
if (! \in_array(\App\Concerns\Enums\Arrayable::class, class_uses_recursive($content))) { | ||
return null; | ||
} | ||
|
||
return $content?->label(); | ||
} | ||
} |
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
Oops, something went wrong.