PHP code example of pi-space / laravel-typed-request
1. Go to this page and download the library: Download pi-space/laravel-typed-request library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pi-space / laravel-typed-request example snippets
namespace PiSpace\LaravelTypedRequest\Tests\Requests;
use PiSpace\LaravelTypedRequest\Rules\Date;
use PiSpace\LaravelTypedRequest\Rules\MaxLength;
use PiSpace\LaravelTypedRequest\Rules\Nullable;
use PiSpace\LaravelTypedRequest\Rules\Required;
use PiSpace\LaravelTypedRequest\Rules\RequiredIfPatch;
use PiSpace\LaravelTypedRequest\Rules\StringValue;
use PiSpace\LaravelTypedRequest\TypedFormRequest;
class ArticleRequest extends TypedFormRequest
{
#[Required, StringValue, MaxLength(255)]
public readonly string $title;
#[Required, StringValue, MaxLength(255)]
public readonly string $body;
#[Nullable, Date, RequiredIfPatch]
public readonly ?string $published_at;
}
#[Attribute]
class RequiredIfPatch extends RuleAttribute
{
public function rule(): \Illuminate\Validation\Rules\RequiredIf
{
return Rule::