Someone could help me, I have a tremendous doubt, I have already researched so much and I have not found the solution. The scenario is as follows. I created a basic project with auth through php artisan make: auth, I installed and implemented the sweet alert, however in this auth controller I can not show the sweet alert on the screen and already with another controller without auth I get it good. Thank you in advance for your help.
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Animal;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use DB;
use Request;
use Alert;
use Session;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:Usuario',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
$id = DB::table('usuario')->insertGetId(
['name' => $data['name'], 'email' => $data['email']
,'sobreNome' => $data['sobreNome'], 'password' => bcrypt($data['password']), ]
);
foreach (json_decode($data['listaPet']) as $area)
{
$idEspecie = DB::table('especie')->where('nome', 'LIKE', '%'.$area->Espécie.'%')->first();
Animal::create([
'usuario_id' => $id,
'nome' => $area->NomedoAnimal,
'especie_id' => $idEspecie->id,
'raca' => $area->Raça,
'dataNascimento' => $area->DatadeNascimento,
'sexo' => $area->Sexo,
'usesr_id' => 1,
]);
}
$usuario = new User();
Alert::success('Usuário cadastro com sucesso!')->persistent("OK");
return $usuario;
}
public function getEspecie(){
$items = DB::table('especie')->get();
return View('auth/register', compact('items',$items));
}
}