资料修改

This commit is contained in:
fthvgb1 2017-12-31 04:23:09 +08:00
parent 151fa03b55
commit f249dd9f31
25 changed files with 714 additions and 18 deletions

View File

@ -3,7 +3,7 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\User; use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
@ -48,9 +48,13 @@ class RegisterController extends Controller
protected function validator(array $data) protected function validator(array $data)
{ {
return Validator::make($data, [ return Validator::make($data, [
'name' => 'required|string|max:255', 'name' => 'required|unique:users|string|max:255',
'email' => 'required|string|email|max:255|unique:users', 'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed', 'password' => 'required|string|min:6|confirmed',
'captcha' => 'required|captcha'
], [
'captcha.required' => '验证码不能为空',
'captcha.captcha' => '请输入正确的验证码',
]); ]);
} }
@ -58,7 +62,7 @@ class RegisterController extends Controller
* Create a new user instance after a valid registration. * Create a new user instance after a valid registration.
* *
* @param array $data * @param array $data
* @return \App\User * @return \App\Models\User
*/ */
protected function create(array $data) protected function create(array $data)
{ {

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\UserUpdate;
use App\Models\User;
class UsersController extends Controller
{
public function show(User $user)
{
return view('users.show', compact('user'));
}
public function edit(User $user)
{
return view('users.edit', compact('user'));
}
public function update(User $user, UserUpdate $request)
{
$attribute = $request->only(['name', 'email', 'introduction']);
if ($request->file('avatar')) {
$user->avatar = $request->file('avatar')->store('public/avatar');
}
$user->update($attribute);
return redirect()->route('users.show', [$user])->with('success', '更新成功!');
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class UserUpdate extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', 'min:3', 'max:20',
'regex:/^[0-9A-Za-z\-\_]+$/',
'unique:users,name,' . Auth::id()
],
'email' => ['required', 'unique:users,email,' . Auth::id()],
'introduction' => 'nullable|max:255',
'avatar' => 'image|nullable',
];
}
public function attributes()
{
return [
'introduction' => '简介',
];
}
}

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App; namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
@ -15,7 +15,7 @@ class User extends Authenticatable
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'name', 'email', 'password', 'name', 'email', 'password', 'introduction', 'avatar '
]; ];
/** /**
@ -26,4 +26,9 @@ class User extends Authenticatable
protected $hidden = [ protected $hidden = [
'password', 'remember_token', 'password', 'remember_token',
]; ];
public function getHeaderAttribute()
{
return asset($this->avatar);
}
} }

View File

@ -2,6 +2,7 @@
namespace App\Providers; namespace App\Providers;
use Carbon\Carbon;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
@ -13,7 +14,7 @@ class AppServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
// Carbon::setLocale('zh');
} }
/** /**

View File

@ -0,0 +1,55 @@
<?php
/**
* Created by PhpStorm.
* User: xing
* Date: 2017/12/31
* Time: 1:47
*/
namespace App\Tools;
use Illuminate\Http\File;
class ImageUploadTool
{
// 只允许以下后缀名的图片文件上传
protected $allowed_ext = ["png", "jpg", "gif", 'jpeg'];
/**
* @param $file File
* @param $folder
* @param $file_prefix
* @return array|bool
*/
public function save($file, $folder, $file_prefix)
{
// 构建存储的文件夹规则值如uploads/images/avatars/201709/21/
// 文件夹切割能让查找效率更高。
$folder_name = "uploads/images/$folder/" . date("Ym", time()) . '/' . date("d", time()) . '/';
// 文件具体存储的物理路径,`public_path()` 获取的是 `public` 文件夹的物理路径。
// 值如:/home/vagrant/Code/larabbs/public/uploads/images/avatars/201709/21/
$upload_path = public_path() . '/' . $folder_name;
// 获取文件的后缀名,因图片从剪贴板里黏贴时后缀名为空,所以此处确保后缀一直存在
$extension = strtolower($file->getClientOriginalExtension()) ?: 'png';
// 拼接文件名,加前缀是为了增加辨析度,前缀可以是相关数据模型的 ID
// 值如1_1493521050_7BVc9v9ujP.png
$filename = $file_prefix . '_' . time() . '_' . str_random(10) . '.' . $extension;
// 如果上传的不是图片将终止操作
if (!in_array($extension, $this->allowed_ext)) {
return false;
}
// 将图片移动到我们的目标存储路径中
$file->move($upload_path, $filename);
return [
'path' => config('app.url') . "/$folder_name/$filename"
];
}
}

View File

@ -10,8 +10,10 @@
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.0.0",
"fideloper/proxy": "~3.3", "fideloper/proxy": "~3.3",
"intervention/image": "^2.4",
"laravel/framework": "5.5.*", "laravel/framework": "5.5.*",
"laravel/tinker": "~1.0", "laravel/tinker": "~1.0",
"mews/captcha": "~2.0",
"overtrue/laravel-lang": "^3.0" "overtrue/laravel-lang": "^3.0"
}, },
"require-dev": { "require-dev": {

254
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "248c18e4b26c8ecaedb1b6564a2ae6ac", "content-hash": "30c482e9d01b8a7536eab6f658b9ce1c",
"packages": [ "packages": [
{ {
"name": "caouecs/laravel-lang", "name": "caouecs/laravel-lang",
@ -361,6 +361,141 @@
], ],
"time": "2017-06-15T17:19:42+00:00" "time": "2017-06-15T17:19:42+00:00"
}, },
{
"name": "guzzlehttp/psr7",
"version": "1.4.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"request",
"response",
"stream",
"uri",
"url"
],
"time": "2017-03-20T17:10:46+00:00"
},
{
"name": "intervention/image",
"version": "2.4.1",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "3603dbcc9a17d307533473246a6c58c31cf17919"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/3603dbcc9a17d307533473246a6c58c31cf17919",
"reference": "3603dbcc9a17d307533473246a6c58c31cf17919",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"guzzlehttp/psr7": "~1.1",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "~0.9.2",
"phpunit/phpunit": "^4.8 || ^5.7"
},
"suggest": {
"ext-gd": "to use GD library based image processing.",
"ext-imagick": "to use Imagick based image processing.",
"intervention/imagecache": "Caching extension for the Intervention Image library"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
},
"laravel": {
"providers": [
"Intervention\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Intervention\\Image\\Facades\\Image"
}
}
},
"autoload": {
"psr-4": {
"Intervention\\Image\\": "src/Intervention/Image"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@olivervogel.com",
"homepage": "http://olivervogel.com/"
}
],
"description": "Image handling and manipulation library with support for Laravel integration",
"homepage": "http://image.intervention.io/",
"keywords": [
"gd",
"image",
"imagick",
"laravel",
"thumbnail",
"watermark"
],
"time": "2017-09-21T16:29:17+00:00"
},
{ {
"name": "jakub-onderka/php-console-color", "name": "jakub-onderka/php-console-color",
"version": "0.1", "version": "0.1",
@ -728,6 +863,73 @@
], ],
"time": "2017-08-06T17:41:04+00:00" "time": "2017-08-06T17:41:04+00:00"
}, },
{
"name": "mews/captcha",
"version": "2.1.7",
"source": {
"type": "git",
"url": "https://github.com/mewebstudio/captcha.git",
"reference": "7d48d7dc5df0fb2225b086ba85cb3fef9832b235"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mewebstudio/captcha/zipball/7d48d7dc5df0fb2225b086ba85cb3fef9832b235",
"reference": "7d48d7dc5df0fb2225b086ba85cb3fef9832b235",
"shasum": ""
},
"require": {
"ext-gd": "*",
"illuminate/config": "~5.0",
"illuminate/filesystem": "~5.0",
"illuminate/hashing": "~5.0",
"illuminate/support": "~5.0",
"intervention/image": "~2.2",
"php": ">=5.4"
},
"require-dev": {
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.1"
},
"type": "package",
"extra": {
"laravel": {
"providers": [
"Mews\\Captcha\\CaptchaServiceProvider"
],
"aliases": {
"Captcha": "Mews\\Captcha\\Facades\\Captcha"
}
}
},
"autoload": {
"psr-4": {
"Mews\\Captcha\\": "src/"
},
"files": [
"src/helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Muharrem ERİN",
"email": "me@mewebstudio.com",
"homepage": "https://github.com/mewebstudio",
"role": "Developer"
}
],
"description": "Laravel 5 Captcha Package",
"homepage": "https://github.com/mewebstudio/captcha",
"keywords": [
"captcha",
"laravel5 Captcha",
"laravel5 Security"
],
"time": "2017-09-11T14:59:20+00:00"
},
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
"version": "1.23.0", "version": "1.23.0",
@ -1102,6 +1304,56 @@
], ],
"time": "2017-02-14T16:28:37+00:00" "time": "2017-02-14T16:28:37+00:00"
}, },
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06T14:39:51+00:00"
},
{ {
"name": "psr/log", "name": "psr/log",
"version": "1.0.2", "version": "1.0.2",

View File

@ -67,7 +67,7 @@ return [
'providers' => [ 'providers' => [
'users' => [ 'users' => [
'driver' => 'eloquent', 'driver' => 'eloquent',
'model' => App\User::class, 'model' => App\Models\User::class,
], ],
// 'users' => [ // 'users' => [

45
config/captcha.php Normal file
View File

@ -0,0 +1,45 @@
<?php
return [
'characters' => '2346789abcdefghjmnpqrtuxyzABCDEFGHJMNPQRTUXYZ',
'default' => [
'length' => 4,
'width' => 120,
'height' => 36,
'quality' => 90,
],
'flat' => [
'length' => 6,
'width' => 160,
'height' => 46,
'quality' => 90,
'lines' => 6,
'bgImage' => false,
'bgColor' => '#ecf2f4',
'fontColors' => ['#2c3e50', '#c0392b', '#16a085', '#c0392b', '#8e44ad', '#303f9f', '#f57c00', '#795548'],
'contrast' => -5,
],
'mini' => [
'length' => 3,
'width' => 60,
'height' => 32,
],
'inverse' => [
'length' => 5,
'width' => 120,
'height' => 36,
'quality' => 90,
'sensitive' => true,
'angle' => 12,
'sharpen' => 10,
'blur' => 2,
'invert' => true,
'contrast' => -5,
]
];

20
config/image.php Normal file
View File

@ -0,0 +1,20 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Image Driver
|--------------------------------------------------------------------------
|
| Intervention Image supports "GD Library" and "Imagick" to process images
| internally. You may choose one of them according to your PHP
| configuration. By default PHP's "GD Library" implementation is used.
|
| Supported: "gd", "imagick"
|
*/
'driver' => 'gd'
];

View File

@ -30,7 +30,7 @@ return [
], ],
'stripe' => [ 'stripe' => [
'model' => App\User::class, 'model' => App\Models\User::class,
'key' => env('STRIPE_KEY'), 'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'), 'secret' => env('STRIPE_SECRET'),
], ],

View File

@ -13,7 +13,7 @@ use Faker\Generator as Faker;
| |
*/ */
$factory->define(App\User::class, function (Faker $faker) { $factory->define(App\Models\User::class, function (Faker $faker) {
static $password; static $password;
return [ return [

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAvatarAndIntroductionToUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('avatar')->nullable();
$table->string('introduction')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('avatar');
$table->dropColumn('introduction');
});
}
}

14
public/css/app.css vendored
View File

@ -8405,3 +8405,17 @@ body {
margin-top: 0px; margin-top: 0px;
} }
/* User register page */
.register-page img.captcha {
margin-bottom: 0px;
margin-top: 10px;
cursor: pointer;
}
/* User profile page */
.users-show-page .user-info .thumbnail {
margin-bottom: 0px;
}

20
public/js/app.js vendored
View File

@ -21554,6 +21554,7 @@
var rnothtmlwhite = (/[^\x20\t\r\n\f]+/g); var rnothtmlwhite = (/[^\x20\t\r\n\f]+/g);
// Convert String-formatted options into Object-formatted ones // Convert String-formatted options into Object-formatted ones
function createOptions(options) { function createOptions(options) {
var object = {}; var object = {};
@ -22185,6 +22186,8 @@
}; };
// The deferred used on DOM ready // The deferred used on DOM ready
var readyList = jQuery.Deferred(); var readyList = jQuery.Deferred();
@ -22262,6 +22265,8 @@
} }
// Multifunctional method to get and set values of a collection // Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function // The value/s can optionally be executed if it's a function
var access = function (elems, fn, key, value, chainable, emptyGet, raw) { var access = function (elems, fn, key, value, chainable, emptyGet, raw) {
@ -22489,6 +22494,7 @@
var dataUser = new Data(); var dataUser = new Data();
// Implementation Summary // Implementation Summary
// //
// 1. Enforce API surface and semantic compatibility with 1.9.x branch // 1. Enforce API surface and semantic compatibility with 1.9.x branch
@ -23003,6 +23009,7 @@
var rscriptType = (/^$|\/(?:java|ecma)script/i); var rscriptType = (/^$|\/(?:java|ecma)script/i);
// We have to close these tags to support XHTML (#13200) // We have to close these tags to support XHTML (#13200)
var wrapMap = { var wrapMap = {
@ -26400,6 +26407,8 @@
}); });
// Return jQuery for attributes-only inclusion // Return jQuery for attributes-only inclusion
@ -26646,6 +26655,7 @@
var rquery = (/\?/); var rquery = (/\?/);
// Cross-browser xml parsing // Cross-browser xml parsing
jQuery.parseXML = function (data) { jQuery.parseXML = function (data) {
var xml; var xml;
@ -27875,6 +27885,8 @@
}); });
// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
jQuery.ajaxPrefilter(function (s) { jQuery.ajaxPrefilter(function (s) {
if (s.crossDomain) { if (s.crossDomain) {
@ -28037,6 +28049,8 @@
}); });
// Support: Safari 8 only // Support: Safari 8 only
// In Safari 8 documents created via document.implementation.createHTMLDocument // In Safari 8 documents created via document.implementation.createHTMLDocument
// collapse sibling forms: the second one becomes a child of the first one. // collapse sibling forms: the second one becomes a child of the first one.
@ -28164,6 +28178,8 @@
}; };
// Attach a bunch of functions for handling common AJAX events // Attach a bunch of functions for handling common AJAX events
jQuery.each([ jQuery.each([
"ajaxStart", "ajaxStart",
@ -28475,6 +28491,8 @@
jQuery.nodeName = nodeName; jQuery.nodeName = nodeName;
// Register as a named AMD module, since jQuery can be concatenated with other // Register as a named AMD module, since jQuery can be concatenated with other
// files that may use define, but not via a proper concatenation script that // files that may use define, but not via a proper concatenation script that
// understands anonymous AMD modules. A named AMD is safest and most robust // understands anonymous AMD modules. A named AMD is safest and most robust
@ -35918,6 +35936,8 @@
/* */ /* */
// Register the component hook to weex native render engine. // Register the component hook to weex native render engine.
// The hook will be triggered by native, not javascript. // The hook will be triggered by native, not javascript.

View File

@ -55,3 +55,21 @@ body {
margin-bottom: 40px; margin-bottom: 40px;
margin-top: 0px; margin-top: 0px;
} }
/* User register page */
.register-page {
img.captcha {
margin-bottom: 0px;
margin-top: 10px;
cursor: pointer;
}
}
/* User profile page */
.users-show-page {
.user-info {
.thumbnail {
margin-bottom: 0px;
}
}
}

View File

@ -5,14 +5,14 @@
<div class="row"> <div class="row">
<div class="col-md-8 col-md-offset-2"> <div class="col-md-8 col-md-offset-2">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">Register</div> <div class="panel-heading">注册</div>
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" method="POST" action="{{ route('register') }}"> <form class="form-horizontal" method="POST" action="{{ route('register') }}">
{{ csrf_field() }} {{ csrf_field() }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">Name</label> <label for="name" class="col-md-4 control-label">用户名</label>
<div class="col-md-6"> <div class="col-md-6">
<input id="name" type="text" class="form-control" name="name" <input id="name" type="text" class="form-control" name="name"
@ -27,7 +27,7 @@
</div> </div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label> <label for="email" class="col-md-4 control-label">邮箱</label>
<div class="col-md-6"> <div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" <input id="email" type="email" class="form-control" name="email"
@ -42,7 +42,7 @@
</div> </div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label> <label for="password" class="col-md-4 control-label">密码</label>
<div class="col-md-6"> <div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required> <input id="password" type="password" class="form-control" name="password" required>
@ -56,18 +56,33 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label> <label for="password-confirm" class="col-md-4 control-label">确认密码</label>
<div class="col-md-6"> <div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" <input id="password-confirm" type="password" class="form-control"
name="password_confirmation" required> name="password_confirmation" required>
</div> </div>
</div> </div>
<div class="form-group {{ $errors->has('captcha') ? ' has-error' : '' }}">
<label for="captcha" class="col-md-4 control-label">验证码</label>
<div class="col-md-6">
<input id="captcha" class="form-control" name="captcha">
<img class="thumbnail captcha" src="{{ captcha_src('default') }}"
onclick="this.src='/captcha/default?'+Math.random()" title="点击图片重新获取验证码">
@if ($errors->has('captcha'))
<span class="help-block">
<strong>{{ $errors->first('captcha') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="col-md-6 col-md-offset-4"> <div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">
Register 注册
</button> </button>
</div> </div>
</div> </div>

View File

@ -0,0 +1,10 @@
@if (count($errors) > 0)
<div class="alert alert-danger">
<h4>有错误发生:</h4>
<ul>
@foreach ($errors->all() as $error)
<li><i class="glyphicon glyphicon-remove"></i> {{ $error }}</li>
@endforeach
</ul>
</div>
@endif

View File

@ -33,13 +33,18 @@
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="user-avatar pull-left" style="margin-right:8px; margin-top:-5px;"> <span class="user-avatar pull-left" style="margin-right:8px; margin-top:-5px;">
<img src="https://fsdhubcdn.phphub.org/uploads/images/201709/20/1/PtDKbASVcz.png?imageView2/1/w/60/h/60" <img src="{{Auth::user()->header}}"
class="img-responsive img-circle" width="30px" height="30px"> class="img-responsive img-circle" width="30px" height="30px">
</span> </span>
{{ Auth::user()->name }} <span class="caret"></span> {{ Auth::user()->name }} <span class="caret"></span>
</a> </a>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li>
<a href="{{route('users.show',[Auth::user()])}}">个人资料</a>
<a href="{{ route('users.edit', Auth::id()) }}">编辑资料</a>
</li>
<li> <li>
<a href="{{ route('logout') }}" <a href="{{ route('logout') }}"
onclick="event.preventDefault();document.getElementById('logout-form').submit();"> onclick="event.preventDefault();document.getElementById('logout-form').submit();">

View File

@ -0,0 +1,20 @@
@if (Session::has('message'))
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ Session::get('message') }}
</div>
@endif
@if (Session::has('success'))
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ Session::get('success') }}
</div>
@endif
@if (Session::has('danger'))
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ Session::get('danger') }}
</div>
@endif

View File

@ -20,7 +20,7 @@
@include('layouts._header') @include('layouts._header')
<div class="container"> <div class="container">
@include('layouts._message')
@yield('content') @yield('content')
</div> </div>

View File

@ -0,0 +1,52 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="panel panel-default col-md-10 col-md-offset-1">
<div class="panel-heading">
<h4>
<i class="glyphicon glyphicon-edit"></i> 编辑个人资料
</h4>
</div>
<div class="panel-body">
<form action="{{ route('users.update', $user->id) }}" method="POST" enctype="multipart/form-data"
accept-charset="UTF-8">
<input type="hidden" name="_method" value="PUT">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<label for="name-field">用户名</label>
<input class="form-control" type="text" name="name" id="name-field"
value="{{ old('name', $user->name ) }}"/>
</div>
<div class="form-group">
<label for="email-field"> </label>
<input class="form-control" type="text" name="email" id="email-field"
value="{{ old('email', $user->email ) }}"/>
</div>
<div class="form-group">
<label for="introduction-field">个人简介</label>
<textarea name="introduction" id="introduction-field" class="form-control"
rows="3">{{ old('introduction', $user->introduction ) }}</textarea>
</div>
<div class="form-group">
<label for="avatar" class="avatar-label">用户头像</label>
<input type="file" id="avatar" name="avatar">
@if($user->avatar)
<br>
<img class="thumbnail img-responsive" src="{{ $user->header }}" width="200"/>
@endif
</div>
<div class="well well-sm">
<button type="submit" class="btn btn-primary">保存</button>
</div>
</form>
@include('common.errors')
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,47 @@
@extends('layouts.app')
@section('title', $user->name . ' 的个人中心')
@section('content')
<div class="row">
<div class="col-lg-3 col-md-3 hidden-sm hidden-xs user-info">
<div class="panel panel-default">
<div class="panel-body">
<div class="media">
<div align="center">
<img class="thumbnail img-responsive" src="{{$user->header}}" width="300px" height="300px">
</div>
<div class="media-body">
<hr>
<h4><strong>个人简介</strong></h4>
<p>{{ $user->introduction }}</p>
<hr>
<h4><strong>注册于</strong></h4>
<p>{{ $user->created_at->diffForHumans() }}</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-body">
<span>
<h1 class="panel-title pull-left" style="font-size:30px;">{{ $user->name }}
<small>{{ $user->email }}</small></h1>
</span>
</div>
</div>
<hr>
{{-- 用户发布的内容 --}}
<div class="panel panel-default">
<div class="panel-body">
暂无数据 ~_~
</div>
</div>
</div>
</div>
@stop

View File

@ -15,6 +15,8 @@ use Illuminate\Support\Facades\Route;
Route::get('/', 'PagesController@root')->name('home'); Route::get('/', 'PagesController@root')->name('home');
Route::resource('users', 'UsersController', ['only' => ['update', 'show', 'edit']]);
// Authentication Routes... // Authentication Routes...
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login'); Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login'); Route::post('login', 'Auth\LoginController@login');