User Bild Upload
This commit is contained in:
parent
71ddd2f1c6
commit
baff3f3fa8
4 changed files with 43 additions and 6 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,6 +2,8 @@
|
|||
/public/storage
|
||||
/storage/*.key
|
||||
/vendor
|
||||
/public/img/*.jpg
|
||||
/public/img/user
|
||||
Homestead.yaml
|
||||
Homestead.json
|
||||
.env
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Intervention\Image\Facades\Image;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
|
|
@ -87,10 +88,32 @@ class UserController extends Controller
|
|||
$request->validate(
|
||||
[
|
||||
'name'=>'required|min:3',
|
||||
'email'=>'required|email'
|
||||
'email'=>'required|email',
|
||||
'bild'=>'mimes:jpg,jpeg,bmp,png,gif'
|
||||
]
|
||||
);
|
||||
|
||||
if ($request->bild){
|
||||
$bild = Image::make($request->bild);
|
||||
$breite = $bild->width();
|
||||
$hoehe = $bild->height();
|
||||
if ($breite>$hoehe) {
|
||||
Image::make($request->bild)
|
||||
->widen(1200)
|
||||
->save(public_path().'/img/user/'.$user->id.'_gross.jpg');
|
||||
Image::make($request->bild)
|
||||
->widen(64)
|
||||
->save(public_path().'/img/user/'.$user->id.'.jpg');
|
||||
}else {
|
||||
Image::make($request->bild)
|
||||
->heighten(900)
|
||||
->save(public_path().'/img/user/'.$user->id.'_gross.jpg');
|
||||
Image::make($request->bild)
|
||||
->widen(96)
|
||||
->save(public_path().'/img/user/'.$user->id.'.jpg');
|
||||
}
|
||||
}
|
||||
|
||||
$user->name=$request->input('name');
|
||||
$user->email=$request->input('email');
|
||||
$user->save();
|
||||
|
|
|
|||
BIN
motorradig/public/img/placeholder/user64x96.jpg
Normal file
BIN
motorradig/public/img/placeholder/user64x96.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
|
|
@ -4,7 +4,7 @@
|
|||
<div class="container text-center text-light mt-5">
|
||||
<h1 class="text-center">{{$user->name}}</h1>
|
||||
|
||||
<form style="background-color: #fff;" class="text-dark" method="post" action="/member/{{$user->name}}">
|
||||
<form style="background-color: #fff;" class="text-dark" method="post" action="/member/{{$user->name}}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<input type="hidden" name="id" value="{{ $user->id }}">
|
||||
|
|
@ -19,14 +19,26 @@
|
|||
<input type="text" class="mt-3 mr-2 form-control" id="lastname" style="font-size:20px;" name="email" value="{{ old('email') ?? $user->email }}" required >
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="bild" ><h4>Bild:</h4></label>
|
||||
|
||||
@if(file_exists (public_path ('img/user/'.$user->id.'.jpg')))
|
||||
<!--File exists -->
|
||||
<img src="/img/user/{{$user->id}}.jpg" class="mt-3 ml-3" >
|
||||
@else
|
||||
<img src="/img/placeholder/user64x96.jpg" class="mt-3 ml-3" >
|
||||
@endif
|
||||
|
||||
<input type="file" class="mt-3 mr-2 form-control" id="bild" style="font-size:20px;" name="bild" value="" required >
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:130px; text-align:left;" for="name" ><h4>Rolle:</h4></label>
|
||||
|
||||
<select name="example" class="dropdown-item ml-3 border form-control mt-3 mr-2" style="font-size:18px;">
|
||||
<option value="GUEST" style="font-size:18px;" class="dropdown-item bg-light form-control">A</option>
|
||||
<option value="MEMBER" style="font-size:18px;" class="dropdown-item bg-light">B</option>
|
||||
<option value="ADMIN" style="font-size:18px;" class="dropdown-item bg-light">Other</option>
|
||||
<select name="role" class="dropdown-item ml-3 border form-control mt-3 mr-2" style="font-size:18px;" selected="{{ old('role') ?? $user->role }}">
|
||||
<option value="GUEST" style="font-size:18px;" class="dropdown-item bg-light form-control" {{ $user->role=="GUEST" ? "selected" : "" }} >GUEST</option>
|
||||
<option value="MEMBER" style="font-size:18px;" class="dropdown-item bg-light" {{ $user->role=="MEMBER" ? "selected" : "" }} >MEMBER</option>
|
||||
<option value="ADMIN" style="font-size:18px;" class="dropdown-item bg-light" {{ $user->role=="ADMIN" ? "selected" : "" }} >ADMIN</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue