Merge pull request #8359 from snipe/fixes/misc_flysystem_fixes

Misc flysystem fixes
This commit is contained in:
snipe 2020-08-24 19:28:40 -07:00 committed by GitHub
commit 3cba174dfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 41 additions and 43 deletions

View file

@ -76,8 +76,7 @@ class CategoriesController extends Controller
$category->checkin_email = $request->input('checkin_email', '0');
$category->user_id = Auth::id();
$category = $request->handleImages($category,600, public_path().'/uploads/categories');
$category = $request->handleImages($category);
if ($category->save()) {
return redirect()->route('categories.index')->with('success', trans('admin/categories/message.create.success'));
}
@ -136,7 +135,7 @@ class CategoriesController extends Controller
$category->checkin_email = $request->input('checkin_email', '0');
$category = $request->handleImages($category,600, public_path().'/uploads/categories');
$category = $request->handleImages($category);
if ($category->save()) {
// Redirect to the new category page

View file

@ -62,7 +62,7 @@ final class CompaniesController extends Controller
$company = new Company;
$company->name = $request->input('name');
$company = $request->handleImages($company,600, public_path().'/uploads/companies');
$company = $request->handleImages($company);
if ($company->save()) {
return redirect()->route('companies.index')
@ -114,7 +114,7 @@ final class CompaniesController extends Controller
$company->name = $request->input('name');
$company = $request->handleImages($company,600, public_path().'/uploads/companies');
$company = $request->handleImages($company);
if ($company->save()) {

View file

@ -55,7 +55,7 @@ class DepartmentsController extends Controller
$department->user_id = Auth::user()->id;
$department->manager_id = ($request->filled('manager_id' ) ? $request->input('manager_id') : null);
$department = $request->handleImages($department,600, public_path().'/uploads/departments');
$department = $request->handleImages($department);
if ($department->save()) {
return redirect()->route("departments.index")->with('success', trans('admin/departments/message.create.success'));
@ -169,8 +169,8 @@ class DepartmentsController extends Controller
$department->fill($request->all());
$department->manager_id = ($request->filled('manager_id' ) ? $request->input('manager_id') : null);
$department = $request->handleImages($department,600, public_path().'/uploads/departments');
$department = $request->handleImages($department);
if ($department->save()) {
return redirect()->route("departments.index")->with('success', trans('admin/departments/message.update.success'));
}

View file

@ -81,7 +81,7 @@ class LocationsController extends Controller
$location->manager_id = $request->input('manager_id');
$location->user_id = Auth::id();
$location = $request->handleImages($location,600, public_path().'/uploads/locations');
$location = $request->handleImages($location);
if ($location->save()) {
return redirect()->route("locations.index")->with('success', trans('admin/locations/message.create.success'));
@ -146,7 +146,7 @@ class LocationsController extends Controller
$location->ldap_ou = $request->input('ldap_ou');
$location->manager_id = $request->input('manager_id');
$location = $request->handleImages($location,600, public_path().'/uploads/locations');
$location = $request->handleImages($location);
if ($location->save()) {

View file

@ -69,7 +69,7 @@ class SuppliersController extends Controller
$supplier->notes = request('notes');
$supplier->url = $supplier->addhttp(request('url'));
$supplier->user_id = Auth::id();
$supplier = $request->handleImages($supplier,600, public_path().'/uploads/suppliers');
$supplier = $request->handleImages($supplier);
if ($supplier->save()) {
@ -129,7 +129,7 @@ class SuppliersController extends Controller
$supplier->email = request('email');
$supplier->url = $supplier->addhttp(request('url'));
$supplier->notes = request('notes');
$supplier = $request->handleImages($supplier,600, public_path().'/uploads/suppliers');
$supplier = $request->handleImages($supplier);
if ($supplier->save()) {
return redirect()->route('suppliers.index')->with('success', trans('admin/suppliers/message.update.success'));

View file

@ -126,7 +126,9 @@ class UsersController extends Controller
}
$user->permissions = json_encode($permissions_array);
app('App\Http\Requests\ImageUploadRequest')->handleImages($user, '', 'avatar', 'avatars');
// we have to invoke the
app('App\Http\Requests\ImageUploadRequest')->handleImages($user);
if ($user->save()) {
if ($request->filled('groups')) {
@ -288,7 +290,7 @@ class UsersController extends Controller
$user->permissions = json_encode($permissions_array);
app('App\Http\Requests\ImageUploadRequest')->handleImages($user, '', 'avatar', 'avatars');
app('App\Http\Requests\ImageUploadRequest')->handleImages($user);
// Was the user updated?

View file

@ -121,13 +121,17 @@ class ImageUploadRequest extends Request
}
// If the user isn't uploading anything new but wants to delete their old image, do so
} elseif ($this->input('image_delete')=='1') {
} else {
\Log::debug('No image was passed - not sure what to do now.');
if ($this->input('image_delete')=='1') {
try {
Storage::disk('public')->delete($path.'/'.$item->{$fieldname});
$item->{$fieldname} = null;
} catch (\Exception $e) {
\Log::debug($e);
try {
Storage::disk('public')->delete($path . '/' . $item->{$fieldname});
$item->{$fieldname} = null;
} catch (\Exception $e) {
\Log::debug($e);
}
}
}

View file

@ -48,7 +48,7 @@ class DepartmentsTransformer
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Department::class),
'delete' => (Gate::allows('delete', Department::class) && ($department->users_count==0),
'delete' => (Gate::allows('delete', Department::class) && ($department->users_count==0)),
];
$array += $permissions_array;

View file

@ -29,7 +29,7 @@
<label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
<div class="col-md-5">
{{ Form::checkbox('image_delete') }}
<img src="{{ Storage::disk('public')->url('uploads/accessories/'.e($item->image)) }}" class="img-responsive" />
<img src="{{ Storage::disk('public')->url('accessories/'.e($item->image)) }}" class="img-responsive" />
{!! $errors->first('image_delete', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>

View file

@ -44,28 +44,21 @@
@include ('partials.forms.edit.notes')
<!-- Image -->
@if ($item->image)
<div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
<div class="col-md-5">
{{ Form::checkbox('image_delete') }}
<img src="{{ url('/') }}/uploads/suppliers/{{ $item->image }}" />
{!! $errors->first('image_delete', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
@if (($item->image) && ($item->image!=''))
<div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
<div class="col-md-5">
<label for="image_delete">
{{ Form::checkbox('image_delete', '1', old('image_delete'), array('class' => 'minimal', 'aria-label'=>'required')) }}
</label>
<br>
<img src="{{ url('/') }}/uploads/models/{{ $item->image }}" alt="Image for {{ $item->name }}">
{!! $errors->first('image_delete', '<span class="alert-msg" aria-hidden="true"><br>:message</span>') !!}
</div>
</div>
</div>
@endif
<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
<div class="col-md-5">
<label class="btn btn-default">
{{ trans('button.select_file') }}
<input type="file" name="image" accept="image/gif,image/jpeg,image/png,image/svg" hidden>
</label>
<p class="help-block">Accepted filetypes are jpg, png, gif and svg</p>
{!! $errors->first('image', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
@include ('partials.forms.edit.image-upload')
@stop