Ajoute la gestion du profil #15

Merged
Shikiryu merged 2 commits from user_profile into master 2020-03-18 10:46:19 +01:00
10 changed files with 745 additions and 22 deletions
Showing only changes of commit f97c6a56ec - Show all commits

View File

@ -23,10 +23,6 @@ class ImageController extends Controller
*/ */
public function display($post_id, $options = 'o:full', $image, ImageService $image_service) public function display($post_id, $options = 'o:full', $image, ImageService $image_service)
{ {
if (Auth::guest()) {
throw new UnauthorizedHttpException('Vous devez être connecté pour voir cette image.');
}
$post = Post::find($post_id); $post = Post::find($post_id);
if (Auth::user()->getAuthIdentifier() !== (int)$post->user_id) { if (Auth::user()->getAuthIdentifier() !== (int)$post->user_id) {

View File

@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\UpdateUser;
use App\User;
use Illuminate\Support\Facades\Auth;
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\DiskDoesNotExist;
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\FileDoesNotExist;
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\FileIsTooBig;
class UserController extends Controller
{
public function index()
{
return view('user.index', ['user' => Auth::user()]);
}
public function update(UpdateUser $request)
{
/** @var User $user */
$user_id = Auth::user()->getAuthIdentifier();
$user = User::find($user_id);
$validated = $request->validated();
if (!array_key_exists('encrypt_messages', $validated)) {
$validated['encrypt_messages'] = 0;
}
if (isset($validated['avatar'])) {
try {
$user->clearMediaCollection('avatars');
$user->addMediaFromRequest('avatar')->toMediaCollection('avatars');
} catch (DiskDoesNotExist $e) {
} catch (FileDoesNotExist $e) {
} catch (FileIsTooBig $e) {
}
}
$user->update($validated);
return redirect(route('user.index'))->withSuccess('Data saved!');
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class UpdateUser extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return !Auth::guest();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|min:4|max:255',
'email' => 'required|email:rfc|unique:users,email,'.Auth::user()->getAuthIdentifier(),
'encrypt_messages' => 'boolean',
'notification_hour' => 'in:0,1,2,3,4',
'avatar' => 'file|dimensions:min_width=50,min_height=50,max_width=200,max_height=200,ratio=1'
];
}
}

View File

@ -5,10 +5,14 @@ namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Spatie\Image\Exceptions\InvalidManipulation;
use Spatie\MediaLibrary\HasMedia\HasMedia;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\Models\Media;
class User extends Authenticatable class User extends Authenticatable implements HasMedia
{ {
use Notifiable; use Notifiable, HasMediaTrait;
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
@ -16,7 +20,7 @@ class User extends Authenticatable
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'name', 'email', 'password', 'name', 'email', 'password', 'notification_hour', 'encrypt_messages', 'avatar',
]; ];
/** /**
@ -28,14 +32,18 @@ class User extends Authenticatable
'password', 'remember_token', 'password', 'remember_token',
]; ];
protected $dates = [
'created_at', 'updated_at', 'email_verified_at',
];
/** /**
* The attributes that should be cast to native types. * The attributes that should be cast to native types.
* *
* @var array * @var array
*/ */
protected $casts = [ // protected $casts = [
'email_verified_at' => 'datetime', // 'email_verified_at' => 'datetime',
]; // ];
public function getFolder() public function getFolder()
{ {
@ -50,4 +58,26 @@ class User extends Authenticatable
{ {
return (bool) $this->encrypt_messages; return (bool) $this->encrypt_messages;
} }
/**
* @param Media|null $media
*/
public function registerMediaConversions(Media $media = null)
{
try {
$this->addMediaConversion('thumb')
->width(50)
->height(50);
} catch (InvalidManipulation $e) {
}
}
/**
* @param string $alias
* @return string
*/
public function getAvatar($alias = 'thumb')
{
return $this->getFirstMediaUrl('avatars');
}
} }

View File

@ -13,7 +13,8 @@
"intervention/image": "^2.5", "intervention/image": "^2.5",
"laravel/framework": "^6.0", "laravel/framework": "^6.0",
"laravel/tinker": "^1.0", "laravel/tinker": "^1.0",
"lavary/laravel-menu": "^1.7" "lavary/laravel-menu": "^1.7",
"spatie/laravel-medialibrary": "^7.0.0"
}, },
"require-dev": { "require-dev": {
"facade/ignition": "^1.4", "facade/ignition": "^1.4",

454
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "a8999b4d9f518e7a9608ff59c6ba40e9", "content-hash": "e3145fece6314548c650ce97ed16de32",
"packages": [ "packages": [
{ {
"name": "dnoegel/php-xdg-base-dir", "name": "dnoegel/php-xdg-base-dir",
@ -953,6 +953,128 @@
], ],
"time": "2019-08-24T11:17:19+00:00" "time": "2019-08-24T11:17:19+00:00"
}, },
{
"name": "league/glide",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/glide.git",
"reference": "a5477e9e822ed57b39861a17092b92553634932d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/glide/zipball/a5477e9e822ed57b39861a17092b92553634932d",
"reference": "a5477e9e822ed57b39861a17092b92553634932d",
"shasum": ""
},
"require": {
"intervention/image": "^2.4",
"league/flysystem": "^1.0",
"php": "^5.5 | ^7.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpunit/php-token-stream": "^1.4",
"phpunit/phpunit": "~4.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"autoload": {
"psr-4": {
"League\\Glide\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jonathan Reinink",
"email": "jonathan@reinink.ca",
"homepage": "http://reinink.ca"
}
],
"description": "Wonderfully easy on-demand image manipulation library with an HTTP based API.",
"homepage": "http://glide.thephpleague.com",
"keywords": [
"ImageMagick",
"editing",
"gd",
"image",
"imagick",
"league",
"manipulation",
"processing"
],
"time": "2019-04-03T23:46:42+00:00"
},
{
"name": "maennchen/zipstream-php",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
"reference": "6373eefe0b3274d7b702d81f2c99aa977ff97dc2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/6373eefe0b3274d7b702d81f2c99aa977ff97dc2",
"reference": "6373eefe0b3274d7b702d81f2c99aa977ff97dc2",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"myclabs/php-enum": "^1.5",
"php": ">= 7.1",
"psr/http-message": "^1.0"
},
"require-dev": {
"ext-zip": "*",
"guzzlehttp/guzzle": ">= 6.3",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": ">= 7.5"
},
"type": "library",
"autoload": {
"psr-4": {
"ZipStream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paul Duncan",
"email": "pabs@pablotron.org"
},
{
"name": "Jesse Donat",
"email": "donatj@gmail.com"
},
{
"name": "Jonatan Männchen",
"email": "jonatan@maennchen.ch"
},
{
"name": "András Kolesár",
"email": "kolesar@kolesar.hu"
}
],
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
"keywords": [
"stream",
"zip"
],
"time": "2019-07-17T11:01:58+00:00"
},
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
"version": "2.0.0", "version": "2.0.0",
@ -1034,6 +1156,52 @@
], ],
"time": "2019-08-30T09:56:44+00:00" "time": "2019-08-30T09:56:44+00:00"
}, },
{
"name": "myclabs/php-enum",
"version": "1.7.6",
"source": {
"type": "git",
"url": "https://github.com/myclabs/php-enum.git",
"reference": "5f36467c7a87e20fbdc51e524fd8f9d1de80187c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/5f36467c7a87e20fbdc51e524fd8f9d1de80187c",
"reference": "5f36467c7a87e20fbdc51e524fd8f9d1de80187c",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^7",
"squizlabs/php_codesniffer": "1.*",
"vimeo/psalm": "^3.8"
},
"type": "library",
"autoload": {
"psr-4": {
"MyCLabs\\Enum\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP Enum contributors",
"homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
}
],
"description": "PHP Enum implementation",
"homepage": "http://github.com/myclabs/php-enum",
"keywords": [
"enum"
],
"time": "2020-02-14T08:15:52+00:00"
},
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",
"version": "2.24.0", "version": "2.24.0",
@ -1698,6 +1866,290 @@
], ],
"time": "2018-07-19T23:38:55+00:00" "time": "2018-07-19T23:38:55+00:00"
}, },
{
"name": "spatie/image",
"version": "1.7.6",
"source": {
"type": "git",
"url": "https://github.com/spatie/image.git",
"reference": "74535b5fd67ace75840c00c408666660843e755e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/image/zipball/74535b5fd67ace75840c00c408666660843e755e",
"reference": "74535b5fd67ace75840c00c408666660843e755e",
"shasum": ""
},
"require": {
"ext-exif": "*",
"ext-mbstring": "*",
"league/glide": "^1.4",
"php": "^7.0",
"spatie/image-optimizer": "^1.0",
"spatie/temporary-directory": "^1.0.0",
"symfony/process": "^3.0|^4.0|^5.0"
},
"require-dev": {
"larapack/dd": "^1.1",
"phpunit/phpunit": "^6.0|^7.0",
"symfony/var-dumper": "^3.2|^5.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\Image\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Manipulate images with an expressive API",
"homepage": "https://github.com/spatie/image",
"keywords": [
"image",
"spatie"
],
"time": "2020-01-26T18:56:44+00:00"
},
{
"name": "spatie/image-optimizer",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/image-optimizer.git",
"reference": "9c1d470e34b28b715d25edb539dd6c899461527c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/image-optimizer/zipball/9c1d470e34b28b715d25edb539dd6c899461527c",
"reference": "9c1d470e34b28b715d25edb539dd6c899461527c",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"php": "^7.2",
"psr/log": "^1.0",
"symfony/process": "^4.2|^5.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"symfony/var-dumper": "^4.2|^5.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\ImageOptimizer\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Easily optimize images using PHP",
"homepage": "https://github.com/spatie/image-optimizer",
"keywords": [
"image-optimizer",
"spatie"
],
"time": "2019-11-25T12:29:24+00:00"
},
{
"name": "spatie/laravel-medialibrary",
"version": "7.18.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-medialibrary.git",
"reference": "6461708267ca8863b351eb70f6d5eb324a3eec0b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/6461708267ca8863b351eb70f6d5eb324a3eec0b",
"reference": "6461708267ca8863b351eb70f6d5eb324a3eec0b",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"illuminate/bus": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
"illuminate/console": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
"illuminate/database": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
"illuminate/pipeline": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
"league/flysystem": "^1.0.8",
"maennchen/zipstream-php": "^1.0",
"php": "^7.2",
"spatie/image": "^1.4.0",
"spatie/pdf-to-image": "^1.2",
"spatie/temporary-directory": "^1.1"
},
"conflict": {
"php-ffmpeg/php-ffmpeg": "<0.6.1"
},
"require-dev": {
"doctrine/dbal": "^2.5.2",
"ext-pdo_sqlite": "*",
"guzzlehttp/guzzle": "^6.3",
"league/flysystem-aws-s3-v3": "^1.0.13",
"mockery/mockery": "^1.0.0",
"orchestra/testbench": "~3.8.0|^4.0",
"phpunit/phpunit": "^8.0",
"spatie/phpunit-snapshot-assertions": "^2.0"
},
"suggest": {
"league/flysystem-aws-s3-v3": "Required to use AWS S3 file storage",
"php-ffmpeg/php-ffmpeg": "Required for generating video thumbnails"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\MediaLibrary\\MediaLibraryServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Spatie\\MediaLibrary\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://murze.be",
"role": "Developer"
}
],
"description": "Associate files with Eloquent models",
"homepage": "https://github.com/spatie/laravel-medialibrary",
"keywords": [
"cms",
"conversion",
"downloads",
"images",
"laravel",
"laravel-medialibrary",
"media",
"spatie"
],
"time": "2020-01-05T12:27:11+00:00"
},
{
"name": "spatie/pdf-to-image",
"version": "1.8.2",
"source": {
"type": "git",
"url": "https://github.com/spatie/pdf-to-image.git",
"reference": "22a580e03550c95ce810ad430e3c44d2f7a1c75a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/pdf-to-image/zipball/22a580e03550c95ce810ad430e3c44d2f7a1c75a",
"reference": "22a580e03550c95ce810ad430e3c44d2f7a1c75a",
"shasum": ""
},
"require": {
"ext-imagick": "*",
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.2"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\PdfToImage\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Convert a pdf to an image",
"homepage": "https://github.com/spatie/pdf-to-image",
"keywords": [
"convert",
"image",
"pdf",
"pdf-to-image",
"spatie"
],
"time": "2019-07-31T06:46:19+00:00"
},
{
"name": "spatie/temporary-directory",
"version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/spatie/temporary-directory.git",
"reference": "fcb127e615700751dac2aefee0ea2808ff3f5bb1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/temporary-directory/zipball/fcb127e615700751dac2aefee0ea2808ff3f5bb1",
"reference": "fcb127e615700751dac2aefee0ea2808ff3f5bb1",
"shasum": ""
},
"require": {
"php": "^7.2"
},
"require-dev": {
"phpunit/phpunit": "^8.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\TemporaryDirectory\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alex Vanderbist",
"email": "alex@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Easily create, use and destroy temporary directories",
"homepage": "https://github.com/spatie/temporary-directory",
"keywords": [
"spatie",
"temporary-directory"
],
"time": "2019-12-15T18:52:09+00:00"
},
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v6.2.1", "version": "v6.2.1",

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateMediaTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('media', function (Blueprint $table) {
$table->bigIncrements('id');
$table->morphs('model');
$table->string('collection_name');
$table->string('name');
$table->string('file_name');
$table->string('mime_type')->nullable();
$table->string('disk');
$table->unsignedBigInteger('size');
$table->json('manipulations');
$table->json('custom_properties');
$table->json('responsive_images');
$table->unsignedInteger('order_column')->nullable();
$table->nullableTimestamps();
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::dropIfExists('media');
}
}

View File

@ -55,15 +55,22 @@
</div> </div>
<div class="dropdown"> <div class="dropdown">
<a href="#" class="nav-link pr-0 leading-none" data-toggle="dropdown"> <a href="#" class="nav-link pr-0 leading-none" data-toggle="dropdown">
<span class="avatar">{{ substr(Auth::user()->name, 0, 1) }}</span> @php($avatar = Auth::user()->getAvatar())
<span class="avatar">
@if($avatar !== '')
<img src="{{ Auth::user()->getAvatar() }}"/>
@else
{{ substr(Auth::user()->name, 0, 1) }}
@endif
</span>
<span class="ml-2 d-none d-lg-block"> <span class="ml-2 d-none d-lg-block">
<span class="text-default">{{ Auth::user()->name }}</span> <span class="text-default">{{ Auth::user()->name }}</span>
<small class="text-muted d-block mt-1"></small> <small class="text-muted d-block mt-1"></small>
</span> </span>
</a> </a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow"> <div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
<a class="dropdown-item" href="#"> <a class="dropdown-item" href="{{ route('user.index') }}">
<i class="dropdown-icon fe fe-user"></i> Profile <i class="dropdown-icon fe fe-user"></i> {{ __('Profile') }}
</a> </a>
<a class="dropdown-item" href="#"> <a class="dropdown-item" href="#">
<i class="dropdown-icon fe fe-settings"></i> Settings <i class="dropdown-icon fe fe-settings"></i> Settings

View File

@ -0,0 +1,106 @@
@extends('layouts.connected')
@section('content')
<div class="container">
<div class="page-header">
<div class="row align-items-center">
<div class="col-auto">
<h1 class="page-title">
{{ __('My profile') }}
</h1>
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
@if (session('success'))
<div class="alert alert-success" role="alert">
{{ session('success') }}
</div>
@endif
@if (session('errors'))
<div class="alert alert-danger" role="alert">
{{ session('errors') }}
</div>
@endif
</div>
</div>
</div>
<div class="row flex-fill">
<div class="col-12">
<form action="{{ route('user.update') }}" method="post" class="card" enctype="multipart/form-data">
@csrf
<div class="card-body">
<div class="row">
<div class="col-md-6 col-lg-4">
<div class="form-group">
<label class="form-label">{{ __('Name') }}</label>
<input type="text" class="form-control" name="name" value="{{ $user->name }}">
</div>
<div class="form-group">
<label class="form-label">{{ __('Email') }}</label>
<input type="email" class="form-control" name="email" value="{{ $user->email }}">
</div>
<div class="form-group">
<label class="form-label">{{ __('Password') }}</label>
<div class="form-control-plaintext">*********</div>
</div>
<div class="form-group">
<label class="form-label">
<input type="checkbox" name="encrypt_messages" value="1" class="custom-switch-input" @if($user->encrypt_messages) checked @endif>
<span class="custom-switch-indicator"></span>
<span class="custom-switch-description">{{ __('Encrypt my posts') }}</span>
</label>
</div>
<div class="form-group">
<label class="form-label">{{ __('Notification hour') }}</label>
<div class="selectgroup selectgroup-pills">
<label class="selectgroup-item">
<input type="radio" name="notification_hour" value="0" class="selectgroup-input" @if($user->notification_hour === null) checked @endif>
<span class="selectgroup-button selectgroup-button-icon"><i class="fe fe-slash"></i></span>
</label>
<label class="selectgroup-item">
<input type="radio" name="notification_hour" value="1" class="selectgroup-input"@if($user->notification_hour === '1') checked @endif>
<span class="selectgroup-button selectgroup-button-icon"><i class="fe fe-moon"></i></span>
</label>
<label class="selectgroup-item">
<input type="radio" name="notification_hour" value="2" class="selectgroup-input"@if($user->notification_hour === '2') checked @endif>
<span class="selectgroup-button selectgroup-button-icon"><i class="fe fe-sunrise"></i></span>
</label>
<label class="selectgroup-item">
<input type="radio" name="notification_hour" value="3" class="selectgroup-input"@if($user->notification_hour === '3') checked @endif>
<span class="selectgroup-button selectgroup-button-icon"><i class="fe fe-sun"></i></span>
</label>
<label class="selectgroup-item">
<input type="radio" name="notification_hour" value="4" class="selectgroup-input"@if($user->notification_hour === '4') checked @endif>
<span class="selectgroup-button selectgroup-button-icon"><i class="fe fe-sunset"></i></span>
</label>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="form-group">
<div class="form-label">{{ __('Avatar') }}</div>
@php($avatar = Auth::user()->getAvatar())
@if($avatar !== '')
<img src="{{ $avatar}}">
@endif
<div class="custom-file">
<input type="file" class="custom-file-input" name="avatar">
<label class="custom-file-label">{{ __('Choose your avatar') }}</label>
</div>
</div>
</div>
</div>
</div>
<div class="card-footer text-right">
<div class="d-flex">
<a href="{{ route('dashboard') }}" class="btn btn-link">{{ __('Cancel') }}</a>
<button type="submit" class="btn btn-primary ml-auto">{{ __('Save') }}</button>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection

View File

@ -11,13 +11,30 @@
| |
*/ */
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
Auth::routes(); Auth::routes();
// not connected
Route::get('/', 'WelcomeController@index')->name('home'); Route::get('/', 'WelcomeController@index')->name('home');
// connected
Route::group(['middleware' => ['auth']], function() {
// posts
Route::get('/home', 'DashboardController@index')->name('dashboard'); Route::get('/home', 'DashboardController@index')->name('dashboard');
Route::post('store', 'DashboardController@store')->name('store'); Route::post('store', 'DashboardController@store')->name('store');
Route::post('delete', 'DashboardController@delete')->name('delete'); Route::post('delete', 'DashboardController@delete')->name('delete');
Route::post('edit', 'DashboardController@edit')->name('edit'); Route::post('edit', 'DashboardController@edit')->name('edit');
// stats
Route::post('stats', 'StatsController@tag')->name('stats'); // TODO make a group for stats Route::post('stats', 'StatsController@tag')->name('stats'); // TODO make a group for stats
// gallery
Route::get('/display/{post_id}/{options}/{image_name}', 'ImageController@display')->name('display_image'); Route::get('/display/{post_id}/{options}/{image_name}', 'ImageController@display')->name('display_image');
Route::get('/gallery', 'ImageController@gallery')->name('gallery'); Route::get('/gallery', 'ImageController@gallery')->name('gallery');
// user
Route::get('/user', 'UserController@index')->name('user.index');
Route::post('/user', 'UserController@update')->name('user.update');
});