@extends('layout')
@section('cabecalho')
Adicionar Cliente
@endsection
@section('conteudo')
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form method="post">
@csrf
<label for="nome">Nome <font color="red">*</font></label>
<input type="text" class="form-control" name="nome" id="nome">
<div class="input-group-prepend">
<label for="consumidorfina">Cons. Final</label>
</div>
<select class="custom-select" name="consumidorfina" id="consumidorfina">
<option selected>Escolha...</option>
<option value="1">Sim</option>
<option value="2">Não</option>
</select>
<label for="vendedor">Vendedor<font color="red">*</font></label>
<select class="custom-select" name="vendedor" id="vendedor">
<option value="0" selected>Selecione...</option>
@<?php foreach ($representantes as $representante): ?>
<option value="{{ $representante->id }}" > {{ $representante->nome }} </option>
<?php endforeach ?>
</select>
<label for="cep" title="Busca CEP no site do Correio">CEP</label>
<input type="text" class="form-control" name="cep" id="cep" maxlength="10" title="Busca CEP no site do Correio">
<label for="endereco">Endereço <font color="red">*</font></label>
<input type="text" class="form-control" name="endereco" id="endereco" maxlength="40">
<label for="numero">Número</label>
<input type="text" class="form-control" name="numero" id="numero" maxlength="5">
<label for="bairro">Bairro<font color="red">*</font></label>
<input type="text" class="form-control" name="bairro" id="bairro" maxlength="40">
<label for="cidade">Cidade<font color="red">*</font></label>
<input type="text" class="form-control" name="cidade" id="cidade">
<label for="uf">UF<font color="red">*</font></label>
<input type="text" class="form-control" name="uf" id="uf" maxlength="2">
<label for="email">E-mail</label>
<input type="email" class="form-control" name="email" id="email" maxlength="50">
<label for="emailnfe">E-mail NF-e</label>
<input type="email" class="form-control" name="emailnfe" id="emailnfe" maxlength="50">
<div class="input-group-prepend">
<label for="fiscaljuridico">Física/Juríd.</label>
</div>
<select class="custom-select" name="fiscaljuridico" id="fiscaljuridico">
<option selected>Escolha...</option>
<option value="1">Física</option>
<option value="2">Jurídica</option>
</select>
<label for="cnpjcpf">CNPJ</label>
<input type="text" class="form-control" name="cnpjcpf" id="cnpjcpf" maxlength="20">
<button class="btn btn-primary mt-2">Adicionar</button>
</form>
@endsection
O erro ocorre nesse momento : Se eu tratar com "if(campo==null) { campo = ' ' }" fica ok
Há outra forma de resolver, sem verificar campo a campo ?
public function store(
ClientesFormRequest $request,
CriadorDeCliente $criadorDeCliente
) {
$cliente = $criadorDeCliente->criarCliente(
$request->nome,
$request->endereco,
$request->bairro,
$request->cidade,
$request->uf,
$request->numero,
$request->cep,
$request->emailnfe,
$request->email,
$request->consumidorfina,
$request->fiscaljuridico,
$request->cnpjcpf,
$request->vendedor,
$request->vendedor
);
Esse é o erro:
Argument 5 passed to App\Services\CriadorDeCliente::criarCliente() must be of the type string, null given, called in F:\workspace\PHP\maxi\app\Http\Controllers\ClientesController.php on line 100