0
Hello, I’m starting a test project of my knowledge, I’m having problem in the variable line $response = $validate->$data;
before I created the Rules was working normal, I tried help on the internet but it was unsuccessful, that’s why I’m here.
public function createClientStore(Request $request, CreateClientFormRequest $validate){
$data = $request->except('_token');
$nameClient = $data['nome'];
$rand1 = rand(100000, 999999);
$response = $validate->$data;
if ($response['success'])
return redirect()
->route('admin')
->with('success', 'Sucesso ao cadastrar!');
else
return redirect()
->back()
->with('error', 'Precisa prencher os campos!');
$dados = DB::table('clients')->insert($data);
if ($request->hasFile('image') && $request->file('image')->isValid())
$name = $rand1.kebab_case($nameClient);
$extenstion = $request->image->extension();
$nameFile = "{$nameClient}.{$extenstion}";
$data["image"] = $nameFile;
$upload = $request->image->storeAs('users', $nameFile);
if (!$upload)
return redirect()
->back()
->with('error', 'Falha ao carregar a imagem');
if ($dados)
return redirect()
->route('admin')
->with('success', 'Sucesso ao cadastrar');
else
return redirect()
->back()
->with('error', 'Erro ao cadastrar');
}
is giving error cited above, I will post also the rules()
public function rules()
{
return [
'nome' => 'required|string|max:255',
'nasc' => 'required',
'rg' => 'required|max:255',
'cpf' => 'required',
'genero' => 'required',
'logradouro'=> 'required',
'endereco' => 'required|max:255',
'bairro' => 'required|max:255',
'cep' => 'required',
'email' => 'required|max:255',
'image' => 'required',
];
}
Any help or tip I appreciate.
Thanks for the help!
– Wesley Martins