From ddb885b4e20820490a93ff469ea3c4a2abe8fa3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 22 Jul 2018 20:49:22 +0200 Subject: [PATCH] basic profile edit page, not working yet --- app/Http/Controllers/UserController.php | 19 +++++++- app/Models/User.php | 1 + app/View/Widget.php | 2 +- app/View/WidgetFactory.php | 14 ++++++ ...83900_create_email_confirmations_table.php | 1 + resources/views/auth/register.blade.php | 3 +- resources/views/layouts/main-nav.blade.php | 7 ++- resources/views/table/create.blade.php | 16 ++----- resources/views/table/view.blade.php | 2 +- resources/views/user/edit.blade.php | 48 +++++++++++++++++++ routes/web.php | 1 + 11 files changed, 96 insertions(+), 18 deletions(-) create mode 100644 resources/views/user/edit.blade.php diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index c4a7e6e..0fa0d3d 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; - use App\Models\User; class UserController extends Controller @@ -11,7 +10,7 @@ class UserController extends Controller /** * Show the application dashboard. * - * @return \Illuminate\Http\Response + * @return \Illuminate\View\View */ public function view(User $user) { @@ -21,4 +20,20 @@ class UserController extends Controller return view('user.view')->with(compact('tables', 'user')); } + + /** + * Edit user profile + * + * @param User $user + * @return \Illuminate\View\View + */ + public function edit() + { + return view('user.edit')->with('user', \Auth::user()); + } + + public function store() + { + echo "Not impl"; + } } diff --git a/app/Models/User.php b/app/Models/User.php index bc5e622..67c85b7 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -20,6 +20,7 @@ use MightyPork\Exceptions\NotExistException; * @property \Carbon\Carbon $updated_at * @property string $name - unique, for vanity URL * @property string $title - for display + * @property string $bio - user bio * @property string $email - unique, for login and social auth chaining * @property string $password - hashed pw * @property bool $confirmed - user e-mail is confirmed diff --git a/app/View/Widget.php b/app/View/Widget.php index 4041400..67b2406 100644 --- a/app/View/Widget.php +++ b/app/View/Widget.php @@ -119,7 +119,7 @@ class Widget // add a compiled list of styles if (!empty($this->styleArray)) { - $attribs_s .= 'style="'.trim(e(array_reduce(array_keys($this->styleArray), function ($carry, $key) { + $attribs_s .= ' style="'.trim(e(array_reduce(array_keys($this->styleArray), function ($carry, $key) { return $carry . $key . ': ' . $this->styleArray[$key] . '; '; }, ''))).'"'; } diff --git a/app/View/WidgetFactory.php b/app/View/WidgetFactory.php index 77a244f..c2e8c84 100644 --- a/app/View/WidgetFactory.php +++ b/app/View/WidgetFactory.php @@ -14,6 +14,20 @@ class WidgetFactory $this->fieldCols = $fieldCols; } + public function header($hx, $text) + { + return "
". + "fieldCols offset-md-$this->labelCols\">".e($text)."". + "
"; + } + + public function par($text) + { + return "
". + "

fieldCols offset-md-$this->labelCols\">".e($text)."". + "

"; + } + private function baseWidget($view, $name, $label) { return (new Widget($view, $name, $label))->layout($this->labelCols, $this->fieldCols); diff --git a/database/migrations/2018_07_22_083900_create_email_confirmations_table.php b/database/migrations/2018_07_22_083900_create_email_confirmations_table.php index 5f64e76..76d1c5b 100644 --- a/database/migrations/2018_07_22_083900_create_email_confirmations_table.php +++ b/database/migrations/2018_07_22_083900_create_email_confirmations_table.php @@ -16,6 +16,7 @@ class CreateEmailConfirmationsTable extends Migration Schema::create('email_confirmations', function (Blueprint $table) { $table->unsignedInteger('user_id')->index(); $table->timestamp('created_at')->nullable(); + $table->string('email'); $table->string('token'); }); } diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 6a39af7..d82772b 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -18,7 +18,8 @@ some symbols are allowed. You can always change this later.') !!} {!! Widget::email('email', 'E-Mail Address')->required()->autofocus() - ->help('Used to login and for password reset e-mails') !!} + ->help('Used to login and for password resets') !!} + {!! Widget::password('password', 'Password')->required() !!} {!! Widget::password('password_confirmation', 'Confirm Password')->required() !!} diff --git a/resources/views/layouts/main-nav.blade.php b/resources/views/layouts/main-nav.blade.php index af29aa3..13724a8 100644 --- a/resources/views/layouts/main-nav.blade.php +++ b/resources/views/layouts/main-nav.blade.php @@ -44,8 +44,11 @@