Skip to content

Commit 65568c1

Browse files
author
Ivan
committed
media controller finished
1 parent 8cd1301 commit 65568c1

File tree

5 files changed

+60
-27
lines changed

5 files changed

+60
-27
lines changed

app/Http/Controllers/MediaController.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,26 @@ public function profile(Request $request, $name, $id)
1919
{
2020
try {
2121
$user = User::findOrFail($id);
22-
if (!is_null($user->info) && !is_null($user->info->profile_pic)) {
23-
$imageStr = base64_decode($user->info->profile_pic);
24-
return response($imageStr)
25-
->header('Content-Type', "image/jpeg")
26-
->header('Content-Disposition', 'inline; filename=profile')
27-
->header('Content-Length', strlen($imageStr));
28-
}else{
29-
22+
if ($user->name == $name) {
23+
if (!is_null($user->info) && !is_null($user->info->profile_pic)) {
24+
$imageStr = base64_decode($user->info->profile_pic);
25+
return response($imageStr)
26+
->header('Content-Type', "image/jpeg")
27+
->header('Content-Disposition', 'inline; filename=profile')
28+
->header('Content-Length', strlen($imageStr));
29+
}
3030
}
31+
$imageStr = file_get_contents(asset('assets/internal/img/blue-user-icon.png'));
32+
return response($imageStr)
33+
->header('Content-Type', "image/jpeg")
34+
->header('Content-Disposition', 'inline; filename=profile')
35+
->header('Content-Length', strlen($imageStr));
3136
} catch (ModelNotFoundException $e) {
32-
37+
$imageStr = file_get_contents(asset('assets/internal/img/blue-user-icon.png'));
38+
return response($imageStr)
39+
->header('Content-Type', "image/jpeg")
40+
->header('Content-Disposition', 'inline; filename=profile')
41+
->header('Content-Length', strlen($imageStr));
3342
}
3443
}
3544
}

resources/views/admin/user/edit.blade.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
@extends('layouts.neat')
1111
@section('title')
12-
ICL KB - User
12+
ICL KB - Edit User
1313
@stop
1414
@section('link')
1515
@stop
@@ -21,13 +21,6 @@
2121
<div class="tile">
2222
<h2 class="tile-title">Edit User</h2>
2323

24-
<div class="tile-config dropdown">
25-
<a class="tile-menu" href="#" data-toggle="dropdown"></a>
26-
<ul class="dropdown-menu animated pull-right text-right">
27-
<li><a href="#">Refresh</a></li>
28-
<li><a href="#">Settings</a></li>
29-
</ul>
30-
</div>
3124
<div class="p-15">
3225
<div class="error-msgs">
3326
<ul></ul>

resources/views/layouts/neat.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
<!-- Profile Menu -->
9898
<div class="text-center s-widget m-b-25 dropdown" id="profile-menu">
9999
<a href="#" data-toggle="dropdown">
100-
<img class="profile-pic animated" src="{{asset('assets/internal/img/blue-user-icon.png')}}" alt="">
100+
<img class="profile-pic animated" src="{{url('media/profile/' . rawurlencode(Auth::user()->name) . '/' . Auth::user()->id)}}" alt="">
101101
</a>
102102
<ul class="dropdown-menu profile-menu">
103103
<li><a href="{{url('user/profile')}}">My Profile</a>

resources/views/user/profile/edit.blade.php

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,45 @@
1515
@stop
1616
@section('content')
1717
<h4 class="page-title">Edit Profile</h4>
18-
Edit Profile
19-
<br>
20-
{{$user}}
18+
<div class="block-area">
19+
<div class="row">
20+
<div class="col-sm-12">
21+
<div class="tile">
22+
<h2 class="tile-title">Edit Profile</h2>
23+
24+
<div class="tile-config dropdown">
25+
<a class="tile-menu" href="#" data-toggle="dropdown"></a>
26+
<ul class="dropdown-menu animated pull-right text-right">
27+
<li><a href="#">Reset</a></li>
28+
</ul>
29+
</div>
30+
<div class="p-15">
31+
<div class="error-msgs">
32+
<ul></ul>
33+
</div>
34+
{!! Form::model($user, array('route' => array('admin.user.update', $user->id), 'method' => 'patch', 'files' => true, 'onsubmit' => 'return false;', "id" => "frm-update-user")) !!}
35+
36+
<div class="form-group">
37+
{!! Form::label('name', 'Full name') !!}
38+
{!! Form::text('name', old('name'), ['class' => 'form-control input-sm', 'placeholder' => 'full name']) !!}
39+
</div>
40+
<div class="form-group">
41+
{!! Form::label('email', 'Email') !!}
42+
{!! Form::text('email', old('email'), ['class' => 'form-control input-sm', 'placeholder' => 'email', 'disabled' => 'disabled']) !!}
43+
</div>
44+
45+
<div class="form-group">
46+
{!! Form::label('status', 'Status') !!} &nbsp;
47+
{!! Form::select('status', array('active' => 'active', 'inactive' => 'inactive', 'locked' => 'locked', 'deleted' => 'deleted'), old('status'), ['class' => 'control-inline form-control input-sm m-b-5']) !!}
48+
</div>
49+
{!! Form::submit('Save', ["class"=>"btn btn-default btn-sm", "href"=>"#", "onclick" => "updateUserOnClick()"]) !!}
50+
{!! Form::close() !!}
51+
</div>
52+
</div>
53+
</div>
54+
</div>
55+
</div>
56+
2157
@stop
2258
@section('script')
2359
@stop

resources/views/user/profile/index.blade.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@
2828
<div class="tile-light p-10 m-b-15">
2929
<div class="cover p-relative">
3030
<img alt="" class="w-100" src="{{asset('assets/internal/img/default-profile-cover.jpg')}}">
31-
@if(!is_null($user->info) && !is_null($user->info))
32-
<img alt="" src="{{asset('assets/internal/img/blue-user-icon.png')}}" class="profile-pic">
33-
@else
34-
{{-- create a profile picture route and controller to access profile image --}}
35-
<img alt="" src="{{asset('assets/internal/img/blue-user-icon.png')}}" class="profile-pic">
36-
@endif
31+
<img alt="" src="{{url('media/profile/' . rawurlencode($user->name) . '/' . $user->id)}}" class="profile-pic">
3732

3833
<div class="profile-btn">
3934
<a class="btn btn-alt btn-sm" href="{{url('user/profile/edit')}}"><i class="icon-bubble"></i>

0 commit comments

Comments
 (0)