Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php namespace Modules\Clients\Http\Controllers;
- use App\Client;
- use Illuminate\Http\Request;
- use Modules\Core\Http\Controllers\BasePublicController;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Redirect;
- use League\Flysystem\Exception;
- use Modules\Core\Contracts\Authentication;
- use Modules\Clients\Events\ClientHasBegunResetProcess;
- use Modules\Clients\Http\Requests\CreateClientRequest;
- use Modules\Clients\Http\Requests\UpdateClientRequest;
- use Illuminate\Support\Facades\Input;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Validator;
- class ClientAuthController extends BasePublicController
- {
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Create a client account from given form data.
- *
- * @param Request $request
- * @return Response
- */
- public function register(Request $request)
- {
- Log::info('Entered Register Function');
- $clientData = [
- 'title' => Input::get('title'),
- 'forename' => Input::get('forename'),
- 'surname' => Input::get('surname'),
- 'email' => Input::get('email'),
- 'telephone' => Input::get('telephone'),
- 'mobile' => Input::get('mobile'),
- 'company' => Input::get('company'),
- 'department' => Input::get('department'),
- 'position' => Input::get('position'),
- 'company_address' => Input::get('company_address'),
- 'company_postcode' => Input::get('company_postcode'),
- 'invoice_address' => Input::get('invoice_address'),
- 'invoice_postcode' => Input::get('invoice_postcode'),
- 'budget_code' => Input::get('budget_code'),
- 'password' => Input::get('password')
- ];
- $validator = Validator::make($clientData, [
- 'title' => 'required|max:255',
- 'forename' => 'required|max:255',
- 'surname' => 'required|max:255',
- 'email' => 'required|email|max:255|confirmed|unique:clients',
- 'telephone' => 'required|numeric|min:11|max:14',
- 'company' => 'required|max:255',
- 'company_address' => 'required',
- 'company_postcode' => 'required|max:10',
- 'invoice_address' => 'required',
- 'invoice_postcode' => 'required|max:10',
- 'password' => 'required|min:5|confirmed'
- ]);
- if($validator->fails())
- {
- return Redirect::back()->withErrors($validator)->withInput();
- }else{
- try {
- $client = Client::create([
- 'title' => $clientData['title'],
- 'forename' => $clientData['forename'],
- 'surname' => $clientData['surname'],
- 'email' => $clientData['email'],
- 'telephone' => $clientData['telephone'],
- 'mobile' => $clientData['mobile'],
- 'company' => $clientData['company'],
- 'department' => $clientData['department'],
- 'position' => $clientData['position'],
- 'company_address' => $clientData['company_address'],
- 'company_postcode' => $clientData['company_postcode'],
- 'invoice_address' => $clientData['invoice_address'],
- 'invoice_postcode' => $clientData['invoice_postcode'],
- 'budget_code' => $clientData['budget_code'],
- 'password' => bcrypt($clientData['password'])
- ]);
- return redirect('/client/register/successful')->with('success', trans('client::frontend.register.success'));
- }catch(Exception $e)
- {
- return Redirect::back()->with('error', trans('client::frontend.register.error'));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement