diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php new file mode 100644 index 0000000000000000000000000000000000000000..f125d07214543a3dcb57eec5b7e9a6952ad6fe31 --- /dev/null +++ b/app/Http/Controllers/UsersController.php @@ -0,0 +1,102 @@ +<?php + +namespace App\Http\Controllers; + +use Illuminate\Http\Request; +use App\User; + +class UsersController extends Controller +{ + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + // + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + $user = User::find($id); + return view('users.profile')->with('user', $user); + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + $user = User::find($id); + return view('users.editprofile')->with('user', $user); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + $this->validate($request, [ + 'email' => 'required', + 'phone_number' => 'required', + 'company' => 'required', + 'interest' => 'required' + ]); + + $user = User::find($id); + $user->email = $request->input('email'); + $user->phone_number = $request->input('phone_number'); + $user->company = $request->input('company'); + $user->interest = $request->input('interest'); + $user->address = $request->input('address'); + $user->save(); + + return redirect('/profile/' . $id)->with('success', 'Profile Updated'); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + // + } +} diff --git a/composer.json b/composer.json index 27695dce07b321d8f67aaad71c0da20a655ec620..46733f1557278ffc67f0fc960f69deb6562a94ea 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,8 @@ "php": ">=7.1.3", "fideloper/proxy": "~4.0", "laravel/framework": "5.6.*", - "laravel/tinker": "~1.0" + "laravel/tinker": "~1.0", + "laravelcollective/html": "^5.4.0" }, "require-dev": { "filp/whoops": "~2.0", diff --git a/composer.lock b/composer.lock index 5edf055123d3422001960076cdfe1dce8556b796..efc97048b35133059803567ed2f1aa4331db4ef6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "bf3c948f982e4ea5ec2fcaef27270719", + "content-hash": "eee47e5816da11290628da12a27d841e", "packages": [ { "name": "dnoegel/php-xdg-base-dir", @@ -651,6 +651,74 @@ ], "time": "2017-12-18T16:25:11+00:00" }, + { + "name": "laravelcollective/html", + "version": "v5.6.3", + "source": { + "type": "git", + "url": "https://github.com/LaravelCollective/html.git", + "reference": "41cd9291a69bd24f2184e504be041348a87308a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/LaravelCollective/html/zipball/41cd9291a69bd24f2184e504be041348a87308a8", + "reference": "41cd9291a69bd24f2184e504be041348a87308a8", + "shasum": "" + }, + "require": { + "illuminate/http": "5.6.*", + "illuminate/routing": "5.6.*", + "illuminate/session": "5.6.*", + "illuminate/support": "5.6.*", + "illuminate/view": "5.6.*", + "php": ">=7.1.3" + }, + "require-dev": { + "illuminate/database": "5.6.*", + "mockery/mockery": "~1.0", + "phpunit/phpunit": "~5.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.6-dev" + }, + "laravel": { + "providers": [ + "Collective\\Html\\HtmlServiceProvider" + ], + "aliases": { + "Form": "Collective\\Html\\FormFacade", + "Html": "Collective\\Html\\HtmlFacade" + } + } + }, + "autoload": { + "psr-4": { + "Collective\\Html\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + }, + { + "name": "Adam Engebretson", + "email": "adam@laravelcollective.com" + } + ], + "description": "HTML and Form Builders for the Laravel Framework", + "homepage": "https://laravelcollective.com", + "time": "2018-02-12T14:19:42+00:00" + }, { "name": "league/flysystem", "version": "1.0.42", diff --git a/config/app.php b/config/app.php index b16e7f77ee590bda99e052bf966f52441b8dcd81..6644e8ceafffa40b91ee26831f368cc327f62d3f 100644 --- a/config/app.php +++ b/config/app.php @@ -146,6 +146,7 @@ return [ Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, + Collective\Html\HtmlServiceProvider::class, /* * Package Service Providers... @@ -208,6 +209,8 @@ return [ 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, + 'Form' => Collective\Html\FormFacade::class, + 'Html' => Collective\Html\HtmlFacade::class, ], diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 689cbeea471775040d4391b08a0de0548189b005..6d36712b97dc383a3ced799bde4be80227ae0b05 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -16,8 +16,12 @@ class CreateUsersTable extends Migration Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); - $table->string('email')->unique(); + $table->string('email', 191)->unique(); + $table->string('phone_number'); $table->string('password'); + $table->string('company'); + $table->string('interest'); + $table->string('address')->nullable(); $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php index 0d5cb84502cc3288b4091bc8adc335e9ae74d43a..f23cd6b040819f351b612a900a22f8fa9c24baab 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -14,7 +14,7 @@ class CreatePasswordResetsTable extends Migration public function up() { Schema::create('password_resets', function (Blueprint $table) { - $table->string('email')->index(); + $table->string('email', 191)->index(); $table->string('token'); $table->timestamp('created_at')->nullable(); }); diff --git a/resources/views/inc/messages.blade.php b/resources/views/inc/messages.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..0e8f5277a8e1009899c215a3f8524f8f9be29946 --- /dev/null +++ b/resources/views/inc/messages.blade.php @@ -0,0 +1,13 @@ +@if(count($errors) > 0) + @foreach($errors->all() as $error) + <div class="alert alert-danger">{{$error}}</div> + @endforeach +@endif + +@if(session('success')) + <div class="alert alert-success">{{session('success')}}</div> +@endif + +@if(session('error')) + <div class="alert alert-danger">{{session('error')}}</div> +@endif diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..ad9ac62c38089b5e6cd6bfe91fbb688f7f4a2338 --- /dev/null +++ b/resources/views/layouts/app.blade.php @@ -0,0 +1,16 @@ +<!doctype html> +<html lang="{{ app()->getLocale() }}"> + <head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="{{asset('css/app.css')}}"> + <title>@yield('title')</title> + </head> + <body> + <div class="container"> + @include('inc.messages') + @yield('content') + </div> + </body> +</html> diff --git a/resources/views/users/editprofile.blade.php b/resources/views/users/editprofile.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..40815e03231f65675e65a85bac0bd68c64b35422 --- /dev/null +++ b/resources/views/users/editprofile.blade.php @@ -0,0 +1,27 @@ +@extends('layouts.app') + +@section('title', $user->name . ' | Update Profile') + +@section('content') + <h1>Edit Profile</h1> + {!! Form::open(['action' => ['UsersController@update',$user->id], 'method' => 'POST']) !!} + <div class="form-group"> + {{Form::label('email','Email')}} + {{Form::text('email', $user->email , ['class' => 'form-control'])}} + + {{Form::label('phone_number','Nomor HP')}} + {{Form::text('phone_number', $user->phone_number, ['class' => 'form-control'])}} + + {{Form::label('company','Perusahaan')}} + {{Form::text('company', $user->company, ['class' => 'form-control'])}} + + {{Form::label('interest','Interest')}} + {{Form::text('interest', $user->interest, ['class' => 'form-control'])}} + + {{Form::label('address','Alamat')}} + {{Form::text('address', $user->address, ['class' => 'form-control'])}} + </div> + {{Form::hidden('_method', 'PUT')}} + {{Form::submit('Submit', ['class' => 'btn btn-dark'])}} + {!! Form::close() !!} +@endsection \ No newline at end of file diff --git a/resources/views/users/profile.blade.php b/resources/views/users/profile.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..165bcb67a6795152feec4ec6c0d5514c8d83ceb5 --- /dev/null +++ b/resources/views/users/profile.blade.php @@ -0,0 +1,13 @@ +@extends('layouts.app') + +@section('title', $user->name . ' | Profile') + +@section('content') + <h1>{{$user->name}}</h1> + <div>Email: {{$user->email}}</div> + <div>Nomor HP: {{$user->phone_number}}</div> + <div>Perusahaan: {{$user->company}}</div> + <div>Interest: {{$user->interest}}</div> + <div>Alamat: {{$user->address == null ? '-' : $user->address}}</div> + <a href="/profile/{{$user->id}}/edit" class="btn btn-dark">Edit Profile</a> +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 810aa34949b08f9fae9892d008272d72c22c56d0..e58039552214df605c10cf975e1fb5357c8786c8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -12,5 +12,7 @@ */ Route::get('/', function () { - return view('welcome'); + return '<h1>Under Construction</h1>'; }); + +Route::resource('profile', 'UsersController'); \ No newline at end of file