diff --git a/.travis.yml b/.travis.yml index 092f4ee..03ea342 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ php: before_script: - travis_retry composer self-update - - travis_retry composer install --prefer-source --no-interaction --dev + - travis_retry composer install --prefer-source --no-interaction - cp .env.example .env - php artisan key:generate diff --git a/README.id.md b/README.id.md index db32af7..da7394b 100644 --- a/README.id.md +++ b/README.id.md @@ -2,7 +2,7 @@ > *Tell our clients that we are managing our projects professionally.* [![Build Status](https://travis-ci.org/nafiesl/free-pmo.svg?branch=master)](https://travis-ci.org/nafiesl/free-pmo) -[![StyleCI](https://styleci.io/repos/111558421/shield?branch=develop)](https://styleci.io/repos/111558421) +[![StyleCI](https://styleci.io/repos/111558421/shield?branch=master)](https://styleci.io/repos/111558421) Free PMO (Project Management Office), software management project untuk *freelancer* dan agensi, dibangun dengan Framework **Laravel 5**. @@ -41,7 +41,7 @@ Tujuan utama Free PMO adalah membantu pengelolaan data project dengan mudah dan Aplikasi ini dapat dipasang dalam server lokal (PC/Laptop) dan server online, dengan spesifikasi berikut : #### Spesifikasi minimum server -1. PHP 7.1.3 (dan memenuhi [server requirement Laravel 5.7](https://laravel.com/docs/5.7#server-requirements)), +1. PHP 7.1.3 (dan memenuhi [server requirement Laravel 5.8](https://laravel.com/docs/5.8#server-requirements)), 2. MySQL atau MariaDB, 3. SQlite (untuk automated testing). @@ -72,7 +72,7 @@ Project ini dikembangkan oleh [Nafies Luthfi](https://github.com/nafiesl) dan pa Free PMO dibangun menggunakan [metode TDD](https://blog.nafies.id/laravel/testing-laravel-tentang-automated-testing) dengan bahan dan dukungan dari paket-paket berikut ini : ##### Dependencies -* [Framework Laravel](https://laravel.com/docs/5.7) (versi 5.2 s/d 5.7). +* [Framework Laravel](https://laravel.com/docs/5.8) (versi 5.2 s/d 5.8). * [luthfi/formfield](https://github.com/nafiesl/FormField), Wrapper Form dari [laravelcollective/html](https://github.com/laravelcollective/html) dengan Bootstrap 3. * [riskihajar/terbilang](https://github.com/riskihajar/terbilang), membuat angka terbilang (pada fitur cetak kuitansi) dan romawi. diff --git a/README.md b/README.md index c4a8795..3d0d1e9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > *Tell our clients that we are managing our projects professionally.* [![Build Status](https://travis-ci.org/nafiesl/free-pmo.svg?branch=master)](https://travis-ci.org/nafiesl/free-pmo) -[![StyleCI](https://styleci.io/repos/111558421/shield?branch=develop)](https://styleci.io/repos/111558421) +[![StyleCI](https://styleci.io/repos/111558421/shield?branch=master)](https://styleci.io/repos/111558421) Free PMO (Project Management Office), management project software for *freelancer* and agency, built with **Laravel 5** Framework. @@ -43,7 +43,7 @@ Free PMO was built for easy and professional project management. This application can be installed on local server and online server with these specifications : #### Server Requirements -1. PHP 7.1.3 (and meet [Laravel 5.7 server requirements](https://laravel.com/docs/5.7#server-requirements)), +1. PHP 7.1.3 (and meet [Laravel 5.8 server requirements](https://laravel.com/docs/5.8#server-requirements)), 2. MySQL or MariaDB database, 3. SQlite (for automated testing). @@ -74,7 +74,7 @@ This project maintained by [Nafies Luthfi](https://github.com/nafiesl) and devel Free PMO built with [TDD metode](https://blog.nafies.id/laravel/testing-laravel-tentang-automated-testing) with these ingredients support : ##### Dependencies -* [Framework Laravel](https://laravel.com/docs/5.7) (version 5.2 to 5.7). +* [Framework Laravel](https://laravel.com/docs/5.8) (version 5.2 to 5.8). * [luthfi/formfield](https://github.com/nafiesl/FormField), Bootstrap 3 Form Wrapper for [laravelcollective/html](https://github.com/laravelcollective/html). * [riskihajar/terbilang](https://github.com/riskihajar/terbilang), create indonesian in-word number (for payment receipt) and roman numeral. diff --git a/app/Entities/Partners/Vendor.php b/app/Entities/Partners/Vendor.php index b0ad461..b58937e 100644 --- a/app/Entities/Partners/Vendor.php +++ b/app/Entities/Partners/Vendor.php @@ -20,7 +20,7 @@ class Vendor extends Model */ public function payments() { - return $this->morphMany('App\Entities\Payments\Payment', 'partner'); + return $this->morphMany('App\Entities\Payments\Payment', 'partner')->orderBy('date'); } /** diff --git a/app/Entities/Users/User.php b/app/Entities/Users/User.php index 44e81ed..59eb7f0 100644 --- a/app/Entities/Users/User.php +++ b/app/Entities/Users/User.php @@ -24,16 +24,6 @@ class User extends Authenticatable protected $hidden = ['password', 'remember_token', 'api_token']; /** - * Set user password attribute on save. - * - * @param void - */ - public function setPasswordAttribute($value) - { - $this->attributes['password'] = bcrypt($value); - } - - /** * Show user name with link to user detail. * * @return Illuminate\Support\HtmlString diff --git a/app/Http/Controllers/Auth/ChangePasswordController.php b/app/Http/Controllers/Auth/ChangePasswordController.php index 34f698e..3106b5f 100644 --- a/app/Http/Controllers/Auth/ChangePasswordController.php +++ b/app/Http/Controllers/Auth/ChangePasswordController.php @@ -43,7 +43,7 @@ class ChangePasswordController extends Controller if (app('hash')->check($input['old_password'], auth()->user()->password)) { $user = auth()->user(); - $user->password = $input['password']; + $user->password = bcrypt($input['password']); $user->save(); flash(trans('auth.password_changed'), 'success'); diff --git a/app/Http/Controllers/InstallationController.php b/app/Http/Controllers/InstallationController.php index 5fd8976..21531fe 100755 --- a/app/Http/Controllers/InstallationController.php +++ b/app/Http/Controllers/InstallationController.php @@ -48,6 +48,7 @@ class InstallationController extends Controller $adminData = $request->only('name', 'email', 'password'); $adminData['api_token'] = str_random(32); + $adminData['password'] = bcrypt($adminData['password']); $admin = User::create($adminData); $admin->assignRole('admin'); diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 2b987b3..085f191 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -37,8 +37,10 @@ class UsersController extends Controller 'role' => 'required|array', ]); - if (!$userData['password']) { - $userData['password'] = \Option::get('password_default', 'member'); + if ($userData['password']) { + $userData['password'] = bcrypt($userData['password']); + } else { + $userData['password'] = bcrypt(\Option::get('password_default', 'member')); } $userData['api_token'] = str_random(32); @@ -90,6 +92,9 @@ class UsersController extends Controller 'lang' => 'required|string|in:en,id', ]); + if ($userData['password']) { + $userData['password'] = bcrypt($userData['password']); + } $user->update($userData); \DB::table('user_roles')->where(['user_id' => $user->id])->delete(); diff --git a/app/Queries/AdminDashboardQuery.php b/app/Queries/AdminDashboardQuery.php index 0b5458f..166f4ed 100644 --- a/app/Queries/AdminDashboardQuery.php +++ b/app/Queries/AdminDashboardQuery.php @@ -26,7 +26,7 @@ class AdminDashboardQuery public function totalEarnings($year) { $totalEarnings = 0; - $payments = Payment::where('date', 'like', $year.'%')->get(); + $payments = Payment::whereYear('date', $year)->get(); foreach ($payments as $payment) { if ($payment->in_out == 1) { $totalEarnings += $payment->amount; @@ -47,7 +47,7 @@ class AdminDashboardQuery */ public function totalFinishedProjects($year) { - return Project::where('status_id', 4)->where('start_date', 'like', $year.'%')->count(); + return Project::where('status_id', 4)->whereYear('start_date', $year)->count(); } /** @@ -61,7 +61,7 @@ class AdminDashboardQuery { // On Progress, Done, On Hold $projects = Project::whereIn('status_id', [2, 3, 6]) - ->where('start_date', 'like', $year.'%') + ->whereYear('start_date', $year) ->with('payments') ->get(); diff --git a/composer.json b/composer.json index 3589659..0169ba2 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "barryvdh/laravel-debugbar": "^3.1", "fzaninotto/faker": "^1.4", "johnkary/phpunit-speedtrap": "^3.0", - "luthfi/simple-crud-generator": "^1.2", + "luthfi/simple-crud-generator": "1.2.*", "mockery/mockery": "^1.0", "phpunit/phpunit": "^7.0" }, diff --git a/composer.lock b/composer.lock index fa6755a..34543d9 100644 --- a/composer.lock +++ b/composer.lock @@ -1365,16 +1365,16 @@ }, { "name": "nesbot/carbon", - "version": "1.36.2", + "version": "1.37.1", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "cd324b98bc30290f233dd0e75e6ce49f7ab2a6c9" + "reference": "5be4fdf97076a685b23efdedfc2b73ad0c5eab70" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/cd324b98bc30290f233dd0e75e6ce49f7ab2a6c9", - "reference": "cd324b98bc30290f233dd0e75e6ce49f7ab2a6c9", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/5be4fdf97076a685b23efdedfc2b73ad0c5eab70", + "reference": "5be4fdf97076a685b23efdedfc2b73ad0c5eab70", "shasum": "" }, "require": { @@ -1419,7 +1419,7 @@ "datetime", "time" ], - "time": "2018-12-28T10:07:33+00:00" + "time": "2019-04-19T10:27:42+00:00" }, { "name": "nexmo/client", @@ -2437,7 +2437,7 @@ }, { "name": "symfony/css-selector", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -2490,7 +2490,7 @@ }, { "name": "symfony/debug", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", @@ -2546,7 +2546,7 @@ }, { "name": "symfony/event-dispatcher", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -2610,7 +2610,7 @@ }, { "name": "symfony/finder", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -2659,16 +2659,16 @@ }, { "name": "symfony/http-foundation", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "5b7ab6beaa5b053b8d3c9b13367ada9b292e12e1" + "reference": "1ea878bd3af18f934dedb8c0de60656a9a31a718" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/5b7ab6beaa5b053b8d3c9b13367ada9b292e12e1", - "reference": "5b7ab6beaa5b053b8d3c9b13367ada9b292e12e1", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/1ea878bd3af18f934dedb8c0de60656a9a31a718", + "reference": "1ea878bd3af18f934dedb8c0de60656a9a31a718", "shasum": "" }, "require": { @@ -2709,20 +2709,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-03-30T15:58:42+00:00" + "time": "2019-05-01T08:36:31+00:00" }, { "name": "symfony/http-kernel", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "72f5f8f9dd6e6fbda0220ded537610ad20fa2ce8" + "reference": "a7713bc522f1a1cdf0b39f809fa4542523fc3114" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/72f5f8f9dd6e6fbda0220ded537610ad20fa2ce8", - "reference": "72f5f8f9dd6e6fbda0220ded537610ad20fa2ce8", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/a7713bc522f1a1cdf0b39f809fa4542523fc3114", + "reference": "a7713bc522f1a1cdf0b39f809fa4542523fc3114", "shasum": "" }, "require": { @@ -2798,7 +2798,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2019-04-16T07:20:25+00:00" + "time": "2019-05-01T13:31:08+00:00" }, { "name": "symfony/polyfill-ctype", @@ -3095,7 +3095,7 @@ }, { "name": "symfony/process", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -3144,16 +3144,16 @@ }, { "name": "symfony/routing", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "b9f16550d76897ab0a86c198f8008c6578a5068f" + "reference": "f4e43bb0dff56f0f62fa056c82d7eadcdb391bab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/b9f16550d76897ab0a86c198f8008c6578a5068f", - "reference": "b9f16550d76897ab0a86c198f8008c6578a5068f", + "url": "https://api.github.com/repos/symfony/routing/zipball/f4e43bb0dff56f0f62fa056c82d7eadcdb391bab", + "reference": "f4e43bb0dff56f0f62fa056c82d7eadcdb391bab", "shasum": "" }, "require": { @@ -3216,20 +3216,20 @@ "uri", "url" ], - "time": "2019-04-03T13:26:22+00:00" + "time": "2019-04-27T09:38:08+00:00" }, { "name": "symfony/translation", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "46c0dede1f925383d13dc783857be2c41efd0b24" + "reference": "181a426dd129cb496f12d7e7555f6d0b37a7615b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/46c0dede1f925383d13dc783857be2c41efd0b24", - "reference": "46c0dede1f925383d13dc783857be2c41efd0b24", + "url": "https://api.github.com/repos/symfony/translation/zipball/181a426dd129cb496f12d7e7555f6d0b37a7615b", + "reference": "181a426dd129cb496f12d7e7555f6d0b37a7615b", "shasum": "" }, "require": { @@ -3291,20 +3291,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2019-04-10T16:20:36+00:00" + "time": "2019-05-01T12:55:36+00:00" }, { "name": "symfony/var-dumper", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "f42850fa32b8d7a35a75510810f6ef597674be74" + "reference": "3c4084cb1537c0e2ad41aad622bbf55a44a5c9ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/f42850fa32b8d7a35a75510810f6ef597674be74", - "reference": "f42850fa32b8d7a35a75510810f6ef597674be74", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/3c4084cb1537c0e2ad41aad622bbf55a44a5c9ce", + "reference": "3c4084cb1537c0e2ad41aad622bbf55a44a5c9ce", "shasum": "" }, "require": { @@ -3367,7 +3367,7 @@ "debug", "dump" ], - "time": "2019-04-11T11:27:41+00:00" + "time": "2019-05-01T12:55:36+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -4251,16 +4251,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.0", + "version": "4.3.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", "shasum": "" }, "require": { @@ -4298,7 +4298,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-30T07:14:17+00:00" + "time": "2019-04-30T17:48:53+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -4664,16 +4664,16 @@ }, { "name": "phpunit/phpunit", - "version": "7.5.8", + "version": "7.5.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c29c0525cf4572c11efe1db49a8b8aee9dfac58a" + "reference": "134669cf0eeac3f79bc7f0c793efbc158bffc160" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c29c0525cf4572c11efe1db49a8b8aee9dfac58a", - "reference": "c29c0525cf4572c11efe1db49a8b8aee9dfac58a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/134669cf0eeac3f79bc7f0c793efbc158bffc160", + "reference": "134669cf0eeac3f79bc7f0c793efbc158bffc160", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "testing", "xunit" ], - "time": "2019-03-26T13:23:54+00:00" + "time": "2019-04-19T15:50:46+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -4913,16 +4913,16 @@ }, { "name": "sebastian/environment", - "version": "4.1.0", + "version": "4.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6fda8ce1974b62b14935adc02a9ed38252eca656" + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6fda8ce1974b62b14935adc02a9ed38252eca656", - "reference": "6fda8ce1974b62b14935adc02a9ed38252eca656", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404", "shasum": "" }, "require": { @@ -4937,7 +4937,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -4962,7 +4962,7 @@ "environment", "hhvm" ], - "time": "2019-02-01T05:27:49+00:00" + "time": "2019-05-05T09:05:15+00:00" }, { "name": "sebastian/exporter", @@ -5314,7 +5314,7 @@ }, { "name": "symfony/dom-crawler", - "version": "v4.2.6", + "version": "v4.2.8", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 9b7deed..dcedcca 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -10,7 +10,7 @@ $factory->define(User::class, function (Faker\Generator $faker) { return [ 'name' => $faker->name, 'email' => $faker->unique()->email, - 'password' => 'member', + 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret 'remember_token' => str_random(10), 'api_token' => str_random(32), 'lang' => 'en', diff --git a/phpunit.xml b/phpunit.xml index c32237e..075c186 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -20,23 +20,14 @@ + + - + - - - - - - 15 - - - - - diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index 23d8a66..00af94d 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -23,7 +23,6 @@ trait CreatesApplication $app = require __DIR__.'/../bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); - \Hash::setRounds(5); return $app; } diff --git a/tests/Feature/Auth/ChangePasswordTest.php b/tests/Feature/Auth/ChangePasswordTest.php index 8cee67f..90aa3d2 100644 --- a/tests/Feature/Auth/ChangePasswordTest.php +++ b/tests/Feature/Auth/ChangePasswordTest.php @@ -24,12 +24,12 @@ class ChangePasswordTest extends TestCase ]); $this->see(trans('auth.old_password_failed')); $this->assertTrue( - app('hash')->check('member', $user->password), + app('hash')->check('secret', $user->password), 'The password shouldn\'t changed!' ); $this->submitForm(trans('auth.change_password'), [ - 'old_password' => 'member', + 'old_password' => 'secret', 'password' => 'rahasia', 'password_confirmation' => 'rahasia', ]); diff --git a/tests/Feature/Auth/LoginTest.php b/tests/Feature/Auth/LoginTest.php index a96c141..2e525b1 100644 --- a/tests/Feature/Auth/LoginTest.php +++ b/tests/Feature/Auth/LoginTest.php @@ -19,7 +19,7 @@ class LoginTest extends TestCase $this->submitForm(trans('auth.login'), [ 'email' => 'email@mail.com', - 'password' => 'member', + 'password' => 'secret', ]); $this->see(trans('auth.welcome', ['name' => $user->name])); diff --git a/tests/Feature/Users/ManageUsersTest.php b/tests/Feature/Users/ManageUsersTest.php index e54dd13..02e857c 100644 --- a/tests/Feature/Users/ManageUsersTest.php +++ b/tests/Feature/Users/ManageUsersTest.php @@ -113,6 +113,11 @@ class ManageUsersTest extends TestCase 'user_id' => $user2->id, 'role_id' => 2, ]); + + $this->assertTrue( + app('hash')->check('password', $user2->fresh()->password), + 'The password should changed!' + ); } /** @test */