Guest User

Untitled

a guest
May 7th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.68 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppHttpControllersAuth;
  4.  
  5. use AppModelsUser;
  6. use AppModelsBand;
  7. use AppHttpControllersController;
  8. use IlluminateHttpRequest;
  9. use IlluminateSupportFacadesValidator;
  10. use IlluminateFoundationAuthRegistersUsers;
  11. use Session;
  12. use File;
  13.  
  14. class RegisterController extends Controller
  15. {
  16. /*
  17. |--------------------------------------------------------------------------
  18. | Register Controller
  19. |--------------------------------------------------------------------------
  20. |
  21. | This controller handles the registration of new users as well as their
  22. | validation and creation. By default this controller uses a trait to
  23. | provide this functionality without requiring any additional code.
  24. |
  25. */
  26.  
  27. use RegistersUsers;
  28.  
  29. /**
  30. * Where to redirect users after registration.
  31. *
  32. * @var string
  33. */
  34. protected $redirectTo = '/home';
  35.  
  36. /**
  37. * Create a new controller instance.
  38. *
  39. * @return void
  40. */
  41. public function __construct()
  42. {
  43. $this->middleware('guest');
  44. }
  45.  
  46. /**
  47. * Get a validator for an incoming registration request.
  48. *
  49. * @param array $data
  50. * @return IlluminateContractsValidationValidator
  51. */
  52. protected function validator(array $data)
  53. {
  54. return Validator::make($data, [
  55. 'name' => 'required|string|max:255',
  56. 'email' => 'required|string|email|max:255|unique:users',
  57. 'password' => 'required|string|min:6|confirmed',
  58. ]);
  59. }
  60.  
  61. /**
  62. * Create a new user instance after a valid registration.
  63. *
  64. * @param array $data
  65. * @return AppUser
  66. */
  67. protected function create(array $data, Request $request)
  68. {
  69.  
  70. }
  71. protected function show(){
  72. return view('auth.register');
  73. }
  74.  
  75. protected function savesession(Request $request){
  76. Session::put('SimpanNamaBand',$request->input('senderName'));
  77. Session::put('SimpanEmailBand',$request->input('senderEmail'));
  78. Session::put('SimpanUserBand',$request->input('senderUsername'));
  79. Session::put('SimpanPasswordBand',$request->input('senderPassword'));
  80.  
  81.  
  82. }
  83. protected function savesessiondua(Request $request){
  84. Session::put('SimpanKotaBand',$request->input('senderCity'));
  85. Session::put('SimpanTanggalBand',$request->input('senderFormedDate'));
  86. Session::put('SimpanGenreBand',$request->input('senderGenre'));
  87. Session::put('SimpanWebsiteBand',$request->input('senderWebsite'));
  88. Session::put('SimpanContactBand',$request->input('senderContact'));
  89.  
  90.  
  91. }
  92.  
  93. protected function lastsession(Request $request)
  94. {
  95. Session::put('SimpanTypeBand', $request->input('soundsLike'));
  96. }
  97.  
  98. protected function showform(){
  99.  
  100. return view('auth.registertwo');
  101. //return view('auth.registerv');
  102. }
  103. protected function showformfinal(){
  104. //$print = Session::get('SaveRegister');
  105. return view('auth.final');
  106. //return view('auth.registerv');
  107. }
  108.  
  109. protected function showformverification(){
  110. return view('auth.verify');
  111. }
  112.  
  113. protected function test(){
  114. if(Session::has('SimpanNamaBand')){
  115. $value = Session::get('SimpanNamaBand');
  116. var_dump($value);
  117. }
  118. }
  119. protected function store(Request $request){
  120. $user = new User;
  121. $user->username = Session::get('SimpanUserBand');
  122. $user->password = bcrypt(Session::get('SimpanPasswordBand'));
  123. $user->email = Session::get('SimpanEmailBand');
  124. $user->name = Session::get('SimpanNamaBand');
  125. $user->user_type = 'band';
  126.  
  127. $user->save();
  128.  
  129. $band = new Band;
  130. $band->city = Session::get('SimpanCityBand');
  131. $band->formed_date = Session::get('SimpanTanggalBand');
  132. $band->genre = Session::get('SimpanGenreBand');
  133. $band->website = Session::get('SimpanWebsiteBand');
  134. $band->contact = Session::get('SimpanContactBand');
  135. $band->sounds_like = Session::get('SimpanTypeBand');
  136.  
  137. if(!$request->hasFile('verify_file') && !$request->file('verify_file')->isValid()) {
  138. return abort(404, 'File not uploaded!');
  139. }
  140.  
  141. $filename = $request->session()->get('SimpanNamaBand');
  142. $request->image->move(base_path('public/' .$request->session()->get("SimpanNamaBan"). '/document'), $filename);
  143.  
  144.  
  145. $band->verification_file = $filename;
  146. $band->save();
  147. return response()->json(['Data berhasil di simpan']);
  148.  
  149. }
  150. }
  151.  
  152. <?php
  153.  
  154. use IlluminateSupportFacadesSchema;
  155. use IlluminateDatabaseSchemaBlueprint;
  156. use IlluminateDatabaseMigrationsMigration;
  157.  
  158. class CreateUsersTable extends Migration
  159. {
  160. /**
  161. * Run the migrations.
  162. *
  163. * @return void
  164. */
  165. public function up()
  166. {
  167. Schema::create('users', function (Blueprint $table) {
  168. $table->increments('id');
  169. $table->string('username');
  170. $table->string('password');
  171. $table->string('email')->unique();
  172. $table->string('name');
  173. $table->enum('user_type', ['customer', 'band', 'admin'])->default('customer');
  174. $table->string('profile_picture')->nullable();
  175. $table->datetime('last_login')->nullable();
  176. $table->rememberToken();
  177. $table->timestamps();
  178. });
  179. }
  180.  
  181. /**
  182. * Reverse the migrations.
  183. *
  184. * @return void
  185. */
  186. public function down()
  187. {
  188. Schema::dropIfExists('users');
  189. }
  190. }
  191.  
  192. <?php
  193.  
  194. namespace AppModels;
  195.  
  196. use IlluminateNotificationsNotifiable;
  197. use IlluminateFoundationAuthUser as Authenticatable;
  198.  
  199. class User extends Authenticatable
  200. {
  201. use Notifiable;
  202.  
  203. /**
  204. * The attributes that are mass assignable.
  205. *
  206. * @var array
  207. */
  208. protected $fillable = [
  209. 'name', 'email', 'password','username'
  210. ];
  211.  
  212. /**
  213. * The attributes that should be hidden for arrays.
  214. *
  215. * @var array
  216. */
  217. protected $hidden = [
  218. 'password', 'remember_token',
  219. ];
  220.  
  221. protected $table = "users";
  222.  
  223. // Ambil data dari field yang bersangkutan
  224. public function detail() {
  225. return $this->hasOne('AppModels\'.ucfirst($this->user_type));
  226. }
  227. }
  228.  
  229. <?php
  230.  
  231. namespace AppModels;
  232.  
  233. use IlluminateDatabaseEloquentModel;
  234.  
  235. class Band extends Model
  236. {
  237. protected $primaryKey = 'user_id';
  238. public $incrementing = false;
  239.  
  240. public function user() {
  241. return $this->belongsTo(User::class);
  242. }
  243. }
Add Comment
Please, Sign In to add comment