PHP code example of erag / laravel-case-mapper-request
1. Go to this page and download the library: Download erag/laravel-case-mapper-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/ */
erag / laravel-case-mapper-request example snippets
use LaravelCaseMapperRequest\Attributes\MapName;
use LaravelCaseMapperRequest\Traits\HasMapNameTransformers;
use LaravelCaseMapperRequest\Mappers\SnakeCaseMapper;
#[MapName(SnakeCaseMapper::class)] // or CamelCaseMapper, UpperCaseMapper, StudlyCaseMapper etc.
class ContactRequest extends FormRequest
{
use HasMapNameTransformers;
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'first_name' => '
use App\Http\Requests\ContactRequest;
class ContactController extends Controller
{
public function store(ContactRequest $request)
{
$validated = $request->validated();
// Example:
// Contact::create($validated);
return response()->json([
'message' => 'Submitted successfully!',
'data' => $validated
]);
}
}