Browse Source
Update Job Description & fix Bug checkingCI
Update Job Description & fix Bug checkingCI
1. Save Image 2 Mb Maximal. 2. Add folder "Foto_Profile" in Public_path. 3. Add Job Trans in app.php & user.php (en & id). 4. Add Job Information in User Search. 5. Add Input Job & Job Desription in Edit User Page. 6. Add Job & Job Desription Info in User Profile. 7. Add Job Description in Migrate Database.pull/8/head
18 changed files with 284 additions and 82 deletions
-
1.travis.yml
-
41app/Helpers/functions.php
-
32app/Http/Controllers/UsersController.php
-
4app/Providers/AppServiceProvider.php
-
2config/database.php
-
4config/filesystems.php
-
1database/migrations/2014_10_12_000000_create_users_table.php
-
BINpublic/app/public/foto_profile/foto_profile/j79aI14c23A4daF1YEOXLH3lqoWWWghdVri4PXuY.jpeg
-
BINpublic/foto_profile/images/rzy1dxWSFLXiPO68KdUEvEMLfKBxOk711Bd7tEVt.jpeg
-
1resources/lang/en/app.php
-
1resources/lang/en/user.php
-
1resources/lang/id/app.php
-
1resources/lang/id/user.php
-
78resources/views/users/edit.blade.php
-
14resources/views/users/partials/profile.blade.php
-
10resources/views/users/search.blade.php
-
3routes/web.php
-
118tests/Unit/Helpers/UserPhotoHelperTest.php
@ -1,31 +1,40 @@ |
|||
<?php |
|||
|
|||
use App\User; |
|||
|
|||
function formatSizeUnits($bytes) |
|||
{ |
|||
if ($bytes >= 1073741824) |
|||
{ |
|||
if ($bytes >= 1073741824) { |
|||
$bytes = number_format($bytes / 1073741824, 2).' GB'; |
|||
} |
|||
elseif ($bytes >= 1048576) |
|||
{ |
|||
} elseif ($bytes >= 1048576) { |
|||
$bytes = number_format($bytes / 1048576, 2).' MB'; |
|||
} |
|||
elseif ($bytes >= 1024) |
|||
{ |
|||
} elseif ($bytes >= 1024) { |
|||
$bytes = number_format($bytes / 1024, 2).' KB'; |
|||
} |
|||
elseif ($bytes > 1) |
|||
{ |
|||
} elseif ($bytes > 1) { |
|||
$bytes = $bytes.' bytes'; |
|||
} elseif ($bytes == 1) { |
|||
$bytes = $bytes.' byte'; |
|||
} else { |
|||
$bytes = '0 bytes'; |
|||
} |
|||
elseif ($bytes == 1) |
|||
|
|||
return $bytes; |
|||
} |
|||
|
|||
function userPhoto(User $user, $attributes = []) |
|||
{ |
|||
$bytes = $bytes . ' byte'; |
|||
return Html::image( |
|||
userPhotoPath($user->photo_path, $user->gender_id), |
|||
null, |
|||
$attributes |
|||
); |
|||
} |
|||
else |
|||
|
|||
function userPhotoPath($photoPath, $genderId) |
|||
{ |
|||
$bytes = '0 bytes'; |
|||
if (is_file(public_path('foto_profile/'.$photoPath))) { |
|||
return asset('foto_profile/'.$photoPath); |
|||
} |
|||
|
|||
return $bytes; |
|||
return asset('images/icon_user_'.$genderId.'.png'); |
|||
} |
|||
|
After Width: 1000 | Height: 1533 | Size: 679 KiB |
|
After Width: 1000 | Height: 1533 | Size: 679 KiB |
@ -0,0 +1,118 @@ |
|||
<?php |
|||
|
|||
namespace Tests\Unit\Helpers; |
|||
|
|||
use App\User; |
|||
use Tests\TestCase; |
|||
use Illuminate\Foundation\Testing\DatabaseMigrations; |
|||
|
|||
class UserPhotoHelperTest extends TestCase |
|||
{ |
|||
use DatabaseMigrations; |
|||
|
|||
/** @test */ |
|||
public function user_photo_path_function_exists() |
|||
{ |
|||
$this->assertTrue(function_exists('userPhotoPath')); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function user_photo_path_function_returns_default_photo_path_based_on_gender_if_photo_path_is_null() |
|||
{ |
|||
$genderId = 1; // Male
|
|||
$this->assertEquals( |
|||
asset('images/icon_user_1.png'), userPhotoPath(null, $genderId) |
|||
); |
|||
|
|||
$genderId = 2; // Female
|
|||
$this->assertEquals( |
|||
asset('images/icon_user_2.png'), userPhotoPath(null, $genderId) |
|||
); |
|||
} |
|||
/** @test */ |
|||
public function user_photo_function_exists() |
|||
{ |
|||
$this->assertTrue(function_exists('userPhoto')); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function user_photo_function_returns_default_image_photo_element_if_no_agency_image_path_setting() |
|||
{ |
|||
$user = factory(User::class)->create(['gender_id' => 1]); |
|||
|
|||
$photoFile = 'images/icon_user_1.png'; |
|||
|
|||
$imageString = '<img'; |
|||
$imageString .= ' src="'.asset($photoFile).'"'; |
|||
$imageString .= '>'; |
|||
|
|||
$this->assertEquals($imageString, userPhoto($user)); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function user_photo_function_returns_correct_photo_element_based_on_user_photo_path() |
|||
{ |
|||
$photoPath = 'images/user_photo_path.jpg'; |
|||
|
|||
if (!is_dir(storage_path('app/public/images'))) { |
|||
mkdir(storage_path('app/public/images'), 0700); |
|||
} |
|||
copy(public_path('images/icon_user_1.png'), storage_path('app/public/images/user_photo_path.jpg')); |
|||
|
|||
$this->assertFileExists(storage_path('app/public/images/user_photo_path.jpg')); |
|||
|
|||
$user = factory(User::class)->create([ |
|||
'gender_id' => 2, |
|||
'photo_path' => $photoPath, |
|||
]); |
|||
|
|||
$imageString = '<img'; |
|||
$imageString .= ' src="'.asset('storage/'.$photoPath).'"'; |
|||
$imageString .= '>'; |
|||
|
|||
$this->assertEquals($imageString, userPhoto($user)); |
|||
|
|||
$this->assertFileExists(storage_path('app/public/images/user_photo_path.jpg')); |
|||
unlink(storage_path('app/public/images/user_photo_path.jpg')); |
|||
$this->assertFileNotExists(storage_path('app/public/images/user_photo_path.jpg')); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function user_photo_function_has_overrideable_attributes() |
|||
{ |
|||
$user = factory(User::class)->create([ |
|||
'gender_id' => 1, |
|||
]); |
|||
|
|||
$photoFile = 'images/icon_user_1.png'; |
|||
|
|||
$imageString = '<img'; |
|||
$imageString .= ' src="'.asset($photoFile).'"'; |
|||
$imageString .= ' class="123"'; |
|||
$imageString .= ' style="display: inline"'; |
|||
$imageString .= '>'; |
|||
|
|||
$overrides = [ |
|||
'class' => '123', |
|||
'style' => 'display: inline', |
|||
]; |
|||
$this->assertEquals($imageString, userPhoto($user, $overrides)); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function user_photo_function_returns_default_gender_logo_image_if_user_photo_file_doesnt_exists() |
|||
{ |
|||
$user = factory(User::class)->create([ |
|||
'gender_id' => 2, |
|||
'photo_path' => 'images/non_exists_photo_path.jpg', |
|||
]); |
|||
|
|||
$photoFile = 'images/icon_user_2.png'; |
|||
|
|||
$imageString = '<img'; |
|||
$imageString .= ' src="'.asset($photoFile).'"'; |
|||
$imageString .= '>'; |
|||
|
|||
$this->assertEquals($imageString, userPhoto($user)); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue