Invoice logo and Customer profile picture
This commit is contained in:
parent
43619d1db4
commit
3ffdb98a4b
@ -5,9 +5,11 @@ namespace App\Http\Controllers\Customers;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\Customer\Profile as Request;
|
use App\Http\Requests\Customer\Profile as Request;
|
||||||
use App\Models\Auth\User;
|
use App\Models\Auth\User;
|
||||||
|
use App\Traits\Uploads;
|
||||||
|
|
||||||
class Profile extends Controller
|
class Profile extends Controller
|
||||||
{
|
{
|
||||||
|
use Uploads;
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
@ -42,12 +44,6 @@ class Profile extends Controller
|
|||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
// Upload picture
|
|
||||||
$picture = $request->file('picture');
|
|
||||||
if ($picture && $picture->isValid()) {
|
|
||||||
$request['picture'] = $picture->store('users');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do not reset password if not entered/changed
|
// Do not reset password if not entered/changed
|
||||||
if (empty($request['password'])) {
|
if (empty($request['password'])) {
|
||||||
unset($request['password']);
|
unset($request['password']);
|
||||||
@ -57,6 +53,13 @@ class Profile extends Controller
|
|||||||
// Update user
|
// Update user
|
||||||
$user->update($request->input());
|
$user->update($request->input());
|
||||||
|
|
||||||
|
// Upload picture
|
||||||
|
if ($request->file('picture')) {
|
||||||
|
$media = $this->getMedia($request->file('picture'), 'users');
|
||||||
|
|
||||||
|
$user->attachMedia($media, 'picture');
|
||||||
|
}
|
||||||
|
|
||||||
// Update customer
|
// Update customer
|
||||||
$user->customer->update($request->input());
|
$user->customer->update($request->input());
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ use App\Models\Item\Item;
|
|||||||
use App\Models\Setting\Category;
|
use App\Models\Setting\Category;
|
||||||
use App\Models\Setting\Currency;
|
use App\Models\Setting\Currency;
|
||||||
use App\Models\Setting\Tax;
|
use App\Models\Setting\Tax;
|
||||||
|
use App\Models\Common\Media;
|
||||||
use App\Notifications\Income\Invoice as Notification;
|
use App\Notifications\Income\Invoice as Notification;
|
||||||
use App\Notifications\Item\Item as ItemNotification;
|
use App\Notifications\Item\Item as ItemNotification;
|
||||||
use App\Traits\Currencies;
|
use App\Traits\Currencies;
|
||||||
@ -784,18 +785,26 @@ class Invoices extends Controller
|
|||||||
{
|
{
|
||||||
$logo = '';
|
$logo = '';
|
||||||
|
|
||||||
|
$media_id = setting('general.company_logo');
|
||||||
|
|
||||||
if (setting('general.invoice_logo')) {
|
if (setting('general.invoice_logo')) {
|
||||||
$file = session('company_id') . '/' . setting('general.invoice_logo');
|
$media_id = setting('general.invoice_logo');
|
||||||
} else {
|
|
||||||
$file = session('company_id') . '/' . setting('general.company_logo');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = Storage::path($file);
|
$media = Media::find($media_id);
|
||||||
|
|
||||||
|
if (empty($media)) {
|
||||||
|
return $logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = Storage::path($media->getDiskPath());
|
||||||
|
|
||||||
if (!is_file($path)) {
|
if (!is_file($path)) {
|
||||||
return $logo;
|
return $logo;
|
||||||
}
|
}
|
||||||
|
|
||||||
$image = Image::make($path)->encode()->getEncoded();
|
$image = Image::make($path)->encode()->getEncoded();
|
||||||
|
|
||||||
if (empty($image)) {
|
if (empty($image)) {
|
||||||
return $logo;
|
return $logo;
|
||||||
}
|
}
|
||||||
|
@ -63,11 +63,32 @@
|
|||||||
text : '{{ trans('general.form.select.file') }}',
|
text : '{{ trans('general.form.select.file') }}',
|
||||||
style : 'btn-default',
|
style : 'btn-default',
|
||||||
@if($user->picture)
|
@if($user->picture)
|
||||||
placeholder : '<?php echo $user->picture; ?>'
|
placeholder : '<?php echo $user->picture->basename; ?>'
|
||||||
@else
|
@else
|
||||||
placeholder : '{{ trans('general.form.no_file_selected') }}'
|
placeholder : '{{ trans('general.form.no_file_selected') }}'
|
||||||
@endif
|
@endif
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@if($user->picture)
|
||||||
|
picture_html = '<span class="picture">';
|
||||||
|
picture_html += ' <a href="{{ url('uploads/' . $user->picture->id . '/download') }}">';
|
||||||
|
picture_html += ' <span id="download-picture" class="text-primary">';
|
||||||
|
picture_html += ' <i class="fa fa-file-{{ $user->picture->aggregate_type }}-o"></i> {{ $user->picture->basename }}';
|
||||||
|
picture_html += ' </span>';
|
||||||
|
picture_html += ' </a>';
|
||||||
|
picture_html += ' {!! Form::open(['id' => 'picture-' . $user->picture->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $user->picture->id)], 'style' => 'display:inline']) !!}';
|
||||||
|
picture_html += ' <a id="remove-picture" href="javascript:void();">';
|
||||||
|
picture_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>';
|
||||||
|
picture_html += ' </a>';
|
||||||
|
picture_html += ' {!! Form::close() !!}';
|
||||||
|
picture_html += '</span>';
|
||||||
|
|
||||||
|
$('.fancy-file .fake-file').append(picture_html);
|
||||||
|
|
||||||
|
$(document).on('click', '#remove-picture', function (e) {
|
||||||
|
confirmDelete("#picture-{!! $user->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $user->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
|
||||||
|
});
|
||||||
|
@endif
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
Loading…
x
Reference in New Issue
Block a user