Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppHttpControllersAuth;
- use AppModelsUser;
- use AppModelsBand;
- use AppHttpControllersController;
- use IlluminateHttpRequest;
- use IlluminateSupportFacadesValidator;
- use IlluminateFoundationAuthRegistersUsers;
- use Session;
- use File;
- 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 IlluminateContractsValidationValidator
- */
- protected function validator(array $data)
- {
- return Validator::make($data, [
- 'name' => 'required|string|max:255',
- 'email' => 'required|string|email|max:255|unique:users',
- 'password' => 'required|string|min:6|confirmed',
- ]);
- }
- /**
- * Create a new user instance after a valid registration.
- *
- * @param array $data
- * @return AppUser
- */
- protected function create(array $data, Request $request)
- {
- }
- protected function show(){
- return view('auth.register');
- }
- protected function savesession(Request $request){
- Session::put('SimpanNamaBand',$request->input('senderName'));
- Session::put('SimpanEmailBand',$request->input('senderEmail'));
- Session::put('SimpanUserBand',$request->input('senderUsername'));
- Session::put('SimpanPasswordBand',$request->input('senderPassword'));
- }
- protected function savesessiondua(Request $request){
- Session::put('SimpanKotaBand',$request->input('senderCity'));
- Session::put('SimpanTanggalBand',$request->input('senderFormedDate'));
- Session::put('SimpanGenreBand',$request->input('senderGenre'));
- Session::put('SimpanWebsiteBand',$request->input('senderWebsite'));
- Session::put('SimpanContactBand',$request->input('senderContact'));
- }
- protected function lastsession(Request $request)
- {
- Session::put('SimpanTypeBand', $request->input('soundsLike'));
- }
- protected function showform(){
- return view('auth.registertwo');
- //return view('auth.registerv');
- }
- protected function showformfinal(){
- //$print = Session::get('SaveRegister');
- return view('auth.final');
- //return view('auth.registerv');
- }
- protected function showformverification(){
- return view('auth.verify');
- }
- protected function test(){
- if(Session::has('SimpanNamaBand')){
- $value = Session::get('SimpanNamaBand');
- var_dump($value);
- }
- }
- protected function store(Request $request){
- $user = new User;
- $user->username = Session::get('SimpanUserBand');
- $user->password = bcrypt(Session::get('SimpanPasswordBand'));
- $user->email = Session::get('SimpanEmailBand');
- $user->name = Session::get('SimpanNamaBand');
- $user->user_type = 'band';
- $user->save();
- $band = new Band;
- $band->city = Session::get('SimpanCityBand');
- $band->formed_date = Session::get('SimpanTanggalBand');
- $band->genre = Session::get('SimpanGenreBand');
- $band->website = Session::get('SimpanWebsiteBand');
- $band->contact = Session::get('SimpanContactBand');
- $band->sounds_like = Session::get('SimpanTypeBand');
- if(!$request->hasFile('verify_file') && !$request->file('verify_file')->isValid()) {
- return abort(404, 'File not uploaded!');
- }
- $filename = $request->session()->get('SimpanNamaBand');
- $request->image->move(base_path('public/' .$request->session()->get("SimpanNamaBan"). '/document'), $filename);
- $band->verification_file = $filename;
- $band->save();
- return response()->json(['Data berhasil di simpan']);
- }
- }
- <?php
- use IlluminateSupportFacadesSchema;
- use IlluminateDatabaseSchemaBlueprint;
- use IlluminateDatabaseMigrationsMigration;
- class CreateUsersTable extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('users', function (Blueprint $table) {
- $table->increments('id');
- $table->string('username');
- $table->string('password');
- $table->string('email')->unique();
- $table->string('name');
- $table->enum('user_type', ['customer', 'band', 'admin'])->default('customer');
- $table->string('profile_picture')->nullable();
- $table->datetime('last_login')->nullable();
- $table->rememberToken();
- $table->timestamps();
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('users');
- }
- }
- <?php
- namespace AppModels;
- use IlluminateNotificationsNotifiable;
- use IlluminateFoundationAuthUser as Authenticatable;
- class User extends Authenticatable
- {
- use Notifiable;
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $fillable = [
- 'name', 'email', 'password','username'
- ];
- /**
- * The attributes that should be hidden for arrays.
- *
- * @var array
- */
- protected $hidden = [
- 'password', 'remember_token',
- ];
- protected $table = "users";
- // Ambil data dari field yang bersangkutan
- public function detail() {
- return $this->hasOne('AppModels\'.ucfirst($this->user_type));
- }
- }
- <?php
- namespace AppModels;
- use IlluminateDatabaseEloquentModel;
- class Band extends Model
- {
- protected $primaryKey = 'user_id';
- public $incrementing = false;
- public function user() {
- return $this->belongsTo(User::class);
- }
- }
Add Comment
Please, Sign In to add comment