-
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
681098d
commit 94e0a1b
Showing
2 changed files
with
43 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Agenciafmd\Ui\View\Components\Buttons; | ||
|
||
use Illuminate\Contracts\View\View; | ||
use Illuminate\View\Component; | ||
|
||
class Submit extends Component | ||
{ | ||
public function __construct( | ||
public string $label = '', | ||
public string $action = '', | ||
public string $method = 'POST', | ||
) | ||
{ | ||
$this->label = $label ?: __('Send'); | ||
$this->method = strtoupper($method); | ||
} | ||
|
||
public function render(): string|View | ||
{ | ||
return <<<'HTML' | ||
<form method="POST" @if($action) action="{{ $action }}" @endif> | ||
@csrf | ||
@method($method) | ||
<button type="submit" {{ $attributes }}> | ||
{{ $slot }} | ||
</button> | ||
</form> | ||
HTML; | ||
} | ||
|
||
public function fallback(): string | ||
{ | ||
return str($this->label) | ||
->stripTags() | ||
->squish() | ||
->lower() | ||
->ucfirst(); | ||
} | ||
} |