Browse Source

Merge pull request #53 from agasigp/upload-picture

Refactor agency upload logo/picture
pull/54/head
Nafies Luthfi 6 years ago
committed by GitHub
parent
commit
8901c1bbe9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/Http/Controllers/Users/AgencyController.php
  2. 4
      app/helpers.php
  3. 2
      storage/app/.gitignore
  4. 4
      storage/app/public/.gitignore
  5. BIN
      storage/app/public/assets/imgs/icon_user_1.png
  6. 2
      tests/Feature/AgencyProfileTest.php
  7. 4
      tests/Unit/Helpers/AppLogoImageTest.php

4
app/Http/Controllers/Users/AgencyController.php

@ -77,10 +77,10 @@ class AgencyController extends Controller
'logo.file_extension' => __('validation.agency.logo.file_extension'),
]);
\File::delete(public_path('assets/imgs/'.Option::get('agency_logo_path')));
\File::delete(storage_path('app/public/assets/imgs/'.Option::get('agency_logo_path')));
$filename = $file['logo']->getClientOriginalName();
$file['logo']->move(public_path('assets/imgs'), $filename);
$file['logo']->move(storage_path('app/public/assets/imgs'), $filename);
Option::set('agency_logo_path', $filename);
flash(__('agency.updated'), 'success');

4
app/helpers.php

@ -230,8 +230,8 @@ function app_logo_path()
$defaultLogoImagePath = 'default-logo.png';
$optionLogoImagePath = Option::get('agency_logo_path');
if (is_file(public_path('assets/imgs/'.$optionLogoImagePath))) {
return asset('assets/imgs/'.$optionLogoImagePath);
if (is_file(storage_path('app/public/assets/imgs/'.$optionLogoImagePath))) {
return asset('storage/assets/imgs/'.$optionLogoImagePath);
}
return asset('assets/imgs/'.$defaultLogoImagePath);

2
storage/app/.gitignore

@ -1,4 +1,4 @@
*
# *
!public/
!.gitignore
!sample-image.png

4
storage/app/public/.gitignore

@ -1,2 +1,4 @@
*
# *
assets/imgs/*
!assets/imgs/icon_user_1.png
!.gitignore

BIN
storage/app/public/assets/imgs/icon_user_1.png

After

Width: 280  |  Height: 280  |  Size: 10 KiB

2
tests/Feature/AgencyProfileTest.php

@ -93,6 +93,6 @@ class AgencyProfileTest extends TestCase
'value' => 'sample-image.png',
]);
$this->assertFileExistsThenDelete(public_path('assets/imgs/sample-image.png'));
$this->assertFileExistsThenDelete(storage_path('app/public/assets/imgs/sample-image.png'));
}
}

4
tests/Unit/Helpers/AppLogoImageTest.php

@ -17,7 +17,7 @@ class AppLogoImageTest extends TestCase
'value' => 'icon_user_1.png',
]);
$this->assertEquals(asset('assets/imgs/icon_user_1.png'), app_logo_path());
$this->assertEquals(asset('storage/assets/imgs/icon_user_1.png'), app_logo_path());
}
/** @test */
@ -45,7 +45,7 @@ class AppLogoImageTest extends TestCase
]);
$logoString = '<img';
$logoString .= ' src="'.asset('assets/imgs/icon_user_1.png').'"';
$logoString .= ' src="'.asset('storage/assets/imgs/icon_user_1.png').'"';
$logoString .= ' alt="Logo Laravel">';
$this->assertEquals($logoString, app_logo_image());

Loading…
Cancel
Save