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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with
11 additions and
9 deletions
-
app/Http/Controllers/Users/AgencyController.php
-
app/helpers.php
-
storage/app/.gitignore
-
storage/app/public/.gitignore
-
BIN
storage/app/public/assets/imgs/icon_user_1.png
-
tests/Feature/AgencyProfileTest.php
-
tests/Unit/Helpers/AppLogoImageTest.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'); |
|
|
|
|
|
|
|
|
|
|
|
@ -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); |
|
|
|
|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
* |
|
|
|
# * |
|
|
|
!public/ |
|
|
|
!.gitignore |
|
|
|
!sample-image.png |
|
|
|
@ -1,2 +1,4 @@ |
|
|
|
* |
|
|
|
# * |
|
|
|
assets/imgs/* |
|
|
|
!assets/imgs/icon_user_1.png |
|
|
|
!.gitignore |
Width: 280
|
Height: 280
|
Size: 10 KiB
|
|
|
|
@ -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')); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -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()); |
|
|
|
|