Skip to content

Instantly share code, notes, and snippets.

@brandonsueur
Created August 21, 2019 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonsueur/aadc402b9a13708df0394bdd79ac93de to your computer and use it in GitHub Desktop.
Save brandonsueur/aadc402b9a13708df0394bdd79ac93de to your computer and use it in GitHub Desktop.
<form method="POST" action="{{ route('register') }}">
{!! csrf_field() !!}
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Informations personnelles</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('first_name') ? 'has-error' : '' }}">
<span>Prénom</span>
<input type="text" name="first_name" class="form-control" placeholder="Jean Philipe">
@if ($errors->has('first_name'))
<span class="help-block">
<strong>{{ $errors->first('first_name') }}</strong>
</span>
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('last_name') ? 'has-error' : '' }}">
<span>Nom</span>
<input type="text" name="last_name" class="form-control" placeholder="Dumont">
@if ($errors->has('last_name'))
<span class="help-block">
<strong>{{ $errors->first('last_name') }}</strong>
</span>
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('phone') ? 'has-error' : '' }}">
<span>Téléphone</span>
<input type="number" name="phone" class="form-control" placeholder="0615274579">
@if ($errors->has('phone'))
<span class="help-block">
<strong>{{ $errors->first('phone') }}</strong>
</span>
@endif
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('email') ? 'has-error' : '' }}">
<span>Adresse mail</span>
<input type="email" name="email" class="form-control" placeholder="jeanphilipe@exemple.fr">
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('password') ? 'has-error' : '' }}">
<span>Mot de passe</span>
<input type="password" name="password" class="form-control" placeholder="Mon_Mot/DePasse1234_">
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('password_confirmation') ? 'has-error' : '' }}">
<span>Répéter le mot de passe</span>
<input type="password" name="password_confirmation" class="form-control" placeholder="Mon_Mot/DePasse1234_">
@if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Votre entreprise</h3>
</div>
<form role="form">
<div class="card-body">
<div class="row">
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('name') ? 'has-error' : '' }}">
<span>Nom de l'entreprise</span>
<input type="text" name="name" class="form-control" placeholder="Taxi Bruvy Transport">
@if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('siret') ? 'has-error' : '' }}">
<span>Siret</span>
<input type="text" name="siret" class="form-control" placeholder="362 521 879 00034">
@if ($errors->has('siret'))
<span class="help-block">
<strong>{{ $errors->first('siret') }}</strong>
</span>
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('address') ? 'has-error' : '' }}">
<span>Adresse postal</span>
<input type="text" name="address" class="form-control" placeholder="10 rue jean marine 70320">
@if ($errors->has('address'))
<span class="help-block">
<strong>{{ $errors->first('address') }}</strong>
</span>
@endif
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('legal_redress') ? 'has-error' : '' }}">
<span>En redressement judiciaire</span>
<select class="form-control" name="legal_redress" style="border-radius: 0;">
<option selected value="null">Faite votre choix</option>
<option value="yes">Oui</option>
<option value="no">Non</option>
</select>
@if ($errors->has('legal_redress'))
<span class="help-block">
<strong>{{ $errors->first('legal_redress') }}</strong>
</span>
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('judicial_liquidation') ? 'has-error' : '' }}">
<span>En liquidation judiciaire</span>
<select class="form-control" name="judicial_liquidation" style="border-radius: 0;">
<option selected value="null">Faite votre choix</option>
<option value="yes">Oui</option>
<option value="no">Non</option>
</select>
@if ($errors->has('judicial_liquidation'))
<span class="help-block">
<strong>{{ $errors->first('judicial_liquidation') }}</strong>
</span>
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('turnover') ? 'has-error' : '' }}">
<span>Chiffre d'affaire</span>
<input type="text" name="turnover" class="form-control" placeholder="50 000€">
@if ($errors->has('turnover'))
<span class="help-block">
<strong>{{ $errors->first('turnover') }}</strong>
</span>
@endif
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('net_profit') ? 'has-error' : '' }}">
<span>Résultat net</span>
<input type="text" name="net_profit" class="form-control" placeholder="13 000€">
@if ($errors->has('net_profit'))
<span class="help-block">
<strong>{{ $errors->first('net_profit') }}</strong>
</span>
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('employees_count') ? 'has-error' : '' }}">
<span>Nombre de salarié</span>
<input type="number" name="employees_count" class="form-control" placeholder="58">
@if ($errors->has('employees_count'))
<span class="help-block">
<strong>{{ $errors->first('employees_count') }}</strong>
</span>
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group has-feedback {{ $errors->has('insurance_document') ? 'has-error' : '' }}">
<span>Document d'assurance</span>
<input type="file" name="insurance_document" class="form-control" placeholder="58">
@if ($errors->has('insurance_document'))
<span class="help-block">
<strong>{{ $errors->first('insurance_document') }}</strong>
</span>
@endif
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<button type="submit"
class="btn btn-primary btn-block btn-flat"
>Valider</button>
</form>
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
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 = '/';
/**
* 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)
{
var_dump($data);
return Validator::make($data, [
// users
'first_name' => ['required', 'string', 'max:50'],
'last_name' => ['required', 'string', 'max:50'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'phone' => ['required', 'numeric'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
// companies
'name' => ['required', 'string', 'max:50'],
'siret' => ['required', 'numeric', 'min:14', 'max:14'],
'address' => ['required', 'string', 'max:100'],
'legal_redress' => ['required', 'boolean'],
'judicial_liquidation' => ['required', 'boolean'],
'turnover' => ['required', 'numeric'],
'net_profit' => ['required', 'numeric'],
'employees_count' => ['required', 'numeric'],
'insurance_document' => ['required', 'string'],
]);
}
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function register(Request $request)
{
dd($request);
$this->validator($request->all())->validate();
event(new Registered($user = $this->create($request->all())));
return $this->registered($request, $user)
?: redirect($this->redirectPath());
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
var_dump('kofzeokfokz');
// je deviens salarié/admin carrier
// je créé une entreprise
// return User::create([
// 'first_name' => $data['first_name'],
// 'last_name' => $data['last_name'],
// 'username' => strtolower($data['first_name'] . $data['last_name']),
// //'company' => $data['company'],
// 'verified' => false,
// 'phone' => $data['phone'],
// 'email' => $data['email'],
// 'user_type' => 'carrier',
// 'password' => Hash::make($data['password']),
// ]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment