basic profile edit page, not working yet

pull/26/head
Ondřej Hruška 7 years ago
parent 96efa3fa15
commit ddb885b4e2
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 19
      app/Http/Controllers/UserController.php
  2. 1
      app/Models/User.php
  3. 2
      app/View/Widget.php
  4. 14
      app/View/WidgetFactory.php
  5. 1
      database/migrations/2018_07_22_083900_create_email_confirmations_table.php
  6. 3
      resources/views/auth/register.blade.php
  7. 7
      resources/views/layouts/main-nav.blade.php
  8. 16
      resources/views/table/create.blade.php
  9. 2
      resources/views/table/view.blade.php
  10. 48
      resources/views/user/edit.blade.php
  11. 1
      routes/web.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";
}
}

@ -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

@ -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] . '; ';
}, ''))).'"';
}

@ -14,6 +14,20 @@ class WidgetFactory
$this->fieldCols = $fieldCols;
}
public function header($hx, $text)
{
return "<div class=\"row\">".
"<h$hx class=\"col-md-$this->fieldCols offset-md-$this->labelCols\">".e($text)."</h$hx>".
"</div>";
}
public function par($text)
{
return "<div class=\"row\">".
"<p class=\"col-md-$this->fieldCols offset-md-$this->labelCols\">".e($text)."</o>".
"</div>";
}
private function baseWidget($view, $name, $label)
{
return (new Widget($view, $name, $label))->layout($this->labelCols, $this->fieldCols);

@ -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');
});
}

@ -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() !!}

@ -44,8 +44,11 @@
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
<i class="fa-sign-out fa-pr"></i>{{--
--}}{{ __('Logout') }}
<i class="fa-sign-out fa-pr"></i>{{ __('Logout') }}
</a>
<a class="dropdown-item" href="{{ route('user.edit') }}">
<i class="fa-sliders fa-pr"></i>{{ __('Settings') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">

@ -4,20 +4,14 @@
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="row">
<h2 class="col-md-8 offset-md-3">New Table</h2>
</div>
</div>
</div>
<form method="POST" action="{{route('table.storeNew')}}" class="row justify-content-center"
aria-label="New Table">
@csrf
<div class="col-md-8">
@php(Widget::setLayout(3, 8))
<div class="col-md-10">
@php(Widget::setLayout(3, 7))
{!! Widget::header(1, 'New Table') !!}
{!! Widget::text('title', 'Title')->autoAlias('name', '-')
->help('Unique among your tables') !!}
@ -54,7 +48,7 @@
specification you entered above.') !!}
<div class="row form-group">
<div class="col-md-8 offset-md-3">
<div class="col-md-7 offset-md-3">
<button type="submit" class="btn btn-primary">
<i class="fa-save pr-2"></i>Create Table
</button>

@ -13,7 +13,7 @@
</div>
<div class="row justify-content-center">
<div class="col-md-8">
<div class="col-md-10">
<table class="table table-hover table-sm">
<thead>
<tr>

@ -0,0 +1,48 @@
{{-- Profile edit form --}}
@extends('layouts.app')
@section('content')
<div class="container">
<form method="POST" action="{{route('user.store')}}" class="row justify-content-center"
aria-label="Your Profile">
@csrf
<div class="col-md-10">
@php(Widget::setLayout(3, 7))
{!! Widget::header(1, 'Settings') !!}
{!! Widget::text('title', 'Display Name')->value($user->title)->required()->autofocus()
->help('Shown on your profile page, tables, comments, etc.') !!}
{!! Widget::textarea('bio', 'About Me')->value($user->bio)->required()->height('8em')
->help('This is shown in your profile box') !!}
{!! Widget::text('name', 'Username')->value($user->name)->required()
->prepend('@')
->help('Part of your vanity URL. Caution: changing this will alter URLs of your tables.') !!}
{!! Widget::email('email', 'E-Mail Address')->value($user->email)->required()
->help('Used to login and for password resets.
This field is protected; a change will be applied only after you confirm
the new e-mail address via a confirmation link we\'ll send you to it.') !!}
{!! Widget::header(3, 'Password Change') !!}
{!! Widget::par('Leave empty to keep your current password (if any).') !!}
{!! Widget::password('new_password', 'New Password') !!}
{!! Widget::password('new_password_confirmation', 'Confirm New Password') !!}
<div class="row form-group">
<div class="col-md-7 offset-md-3">
<button type="submit" class="btn btn-primary">
<i class="fa-save pr-2"></i>Apply Changes
</button>
</div>
</div>
</div>
</form>
</div>
@endsection

@ -31,6 +31,7 @@ Route::group(['middleware' => 'auth'], function () {
'prefix' => 'user',
], function () {
Route::get('edit', 'UserController@edit')->name('user.edit');
Route::post('edit', 'UserController@store')->name('user.store');
Route::post('create', 'TableController@storeNew')->name('table.storeNew');
});
});

Loading…
Cancel
Save