From 4744093d4191fbd8a321388ee93778f6ff612aec Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 08:48:19 +0800 Subject: [PATCH 01/19] Remove spatie newsletter package, added Sempro PHPUnit Pretty Print --- composer.json | 6 +-- composer.lock | 137 ++++++++++++-------------------------------------- phpunit.xml | 3 +- 3 files changed, 38 insertions(+), 108 deletions(-) diff --git a/composer.json b/composer.json index 788a2b5..061e9a4 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "osinitiative/web-app-boilerplate", + "name": "cleaniquecoders/laravel-boilerplate", "description": "Web Application Boilerplate Based on Laravel Framework.", "keywords": ["framework", "laravel", "osinitiative", "web-app-boilerplate"], "license": "MIT", @@ -19,7 +19,6 @@ "spatie/laravel-html": "^2.10", "spatie/laravel-medialibrary": "^6.6", "spatie/laravel-menu": "^3.0", - "spatie/laravel-newsletter": "^4.1", "spatie/laravel-permission": "^2.7", "spatie/laravel-referer": "^1.3", "spatie/laravel-responsecache": "^4.1", @@ -30,7 +29,8 @@ "filp/whoops": "~2.0", "fzaninotto/faker": "~1.4", "mockery/mockery": "~1.0", - "phpunit/phpunit": "~6.0" + "phpunit/phpunit": "~6.0", + "sempro/phpunit-pretty-print": "^1.0" }, "autoload": { "classmap": [ diff --git a/composer.lock b/composer.lock index 184386a..7b79420 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "786ba560a7bf785bb66a7eed372321b0", + "content-hash": "a566c0e7b6ffde49b88c7ee0bda547bc", "packages": [ { "name": "anahkiasen/underscore-php", @@ -210,49 +210,6 @@ ], "time": "2014-09-09T13:34:57+00:00" }, - { - "name": "drewm/mailchimp-api", - "version": "v2.4", - "source": { - "type": "git", - "url": "https://github.com/drewm/mailchimp-api.git", - "reference": "fe480bb652f85270227bf6d639b0026a531f21fc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/drewm/mailchimp-api/zipball/fe480bb652f85270227bf6d639b0026a531f21fc", - "reference": "fe480bb652f85270227bf6d639b0026a531f21fc", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3" - }, - "require-dev": { - "phpunit/phpunit": "4.0.*", - "vlucas/phpdotenv": "^2.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "DrewM\\MailChimp\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Drew McLellan", - "email": "drew.mclellan@gmail.com", - "homepage": "http://allinthehead.com/" - } - ], - "description": "Super-simple, minimum abstraction MailChimp API v3 wrapper", - "homepage": "https://github.com/drewm/mailchimp-api", - "time": "2017-02-16T13:24:20+00:00" - }, { "name": "egulias/email-validator", "version": "2.1.3", @@ -1548,6 +1505,7 @@ } ], "description": "Laravel Artisan Makers", + "abandoned": "cleaniquecoders/artisan-makers", "time": "2017-12-24T07:56:29+00:00" }, { @@ -2827,66 +2785,6 @@ ], "time": "2017-08-30T12:16:14+00:00" }, - { - "name": "spatie/laravel-newsletter", - "version": "4.1.0", - "source": { - "type": "git", - "url": "https://github.com/spatie/laravel-newsletter.git", - "reference": "7a2b547a468babec0c0aa913052902b6e8a0f1ea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-newsletter/zipball/7a2b547a468babec0c0aa913052902b6e8a0f1ea", - "reference": "7a2b547a468babec0c0aa913052902b6e8a0f1ea", - "shasum": "" - }, - "require": { - "drewm/mailchimp-api": "^2.4", - "illuminate/support": "~5.5.0", - "php": "~7.0" - }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^6.3" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Spatie\\Newsletter\\NewsletterServiceProvider" - ], - "aliases": { - "Newsletter": "Spatie\\Newsletter\\NewsletterFacade" - } - } - }, - "autoload": { - "psr-4": { - "Spatie\\Newsletter\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "homepage": "https://murze.be", - "role": "Developer" - } - ], - "description": "Manage newsletters in Laravel", - "homepage": "https://github.com/spatie/laravel-newsletter", - "keywords": [ - "laravel", - "mailchimp", - "newsletter" - ], - "time": "2017-08-30T23:11:15+00:00" - }, { "name": "spatie/laravel-permission", "version": "2.7.6", @@ -6038,6 +5936,37 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "sempro/phpunit-pretty-print", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/Sempro/phpunit-pretty-print.git", + "reference": "214fe4e342f0402e642a8c24f04896b50aaa3700" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Sempro/phpunit-pretty-print/zipball/214fe4e342f0402e642a8c24f04896b50aaa3700", + "reference": "214fe4e342f0402e642a8c24f04896b50aaa3700", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "phpunit/phpunit": ">=6.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Sempro\\PHPUnitPrettyPrinter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Prettify PHPUnit output", + "time": "2018-01-24T20:24:39+00:00" + }, { "name": "theseer/tokenizer", "version": "1.1.0", diff --git a/phpunit.xml b/phpunit.xml index bb9c4a7..ed57912 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,7 +7,8 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false"> + stopOnFailure="false" + printerClass="Sempro\PHPUnitPrettyPrinter\PrettyPrinter"> ./tests/Feature From e18583c1a48245f13ac3b0157c61fc82214e72ac Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:25:03 +0800 Subject: [PATCH 02/19] Use Cleanique Coders Blueprint Macro Package instead --- app/Macros/Database/Schema/Blueprint.php | 79 ------ database/factories/AddressFactory.php | 14 - database/factories/EmailFactory.php | 9 - database/factories/PhoneFactory.php | 10 - ...17_12_23_000005_create_countries_table.php | 33 --- ..._12_23_000009_create_phone_types_table.php | 32 --- ...17_12_23_020225_create_addresses_table.php | 42 --- .../2017_12_23_020240_create_phones_table.php | 38 --- .../2017_12_23_022510_create_emails_table.php | 36 --- database/seeds/CountrySeeder.php | 266 ------------------ database/seeds/DatabaseSeeder.php | 2 - database/seeds/PhoneTypeSeeder.php | 28 -- 12 files changed, 589 deletions(-) delete mode 100644 app/Macros/Database/Schema/Blueprint.php delete mode 100644 database/factories/AddressFactory.php delete mode 100644 database/factories/EmailFactory.php delete mode 100644 database/factories/PhoneFactory.php delete mode 100644 database/migrations/2017_12_23_000005_create_countries_table.php delete mode 100644 database/migrations/2017_12_23_000009_create_phone_types_table.php delete mode 100644 database/migrations/2017_12_23_020225_create_addresses_table.php delete mode 100644 database/migrations/2017_12_23_020240_create_phones_table.php delete mode 100644 database/migrations/2017_12_23_022510_create_emails_table.php delete mode 100644 database/seeds/CountrySeeder.php delete mode 100644 database/seeds/PhoneTypeSeeder.php diff --git a/app/Macros/Database/Schema/Blueprint.php b/app/Macros/Database/Schema/Blueprint.php deleted file mode 100644 index 40c562f..0000000 --- a/app/Macros/Database/Schema/Blueprint.php +++ /dev/null @@ -1,79 +0,0 @@ -unsignedInteger($key) - ->index() - ->nullable(); - }); - - DefaultBlueprint::macro('referenceOn', function ($key, $table, $references = 'id') { - return $this->foreign($key) - ->references($references) - ->on($table); - }); - - DefaultBlueprint::macro('addAcceptance', function ($value) { - $this->boolean('is_' . $value)->default(false); - $this->datetime($value . '_at')->nullable(); - $this->integer($value . '_by')->nullable(); - $this->text($value . '_remarks')->nullable(); - }); - - DefaultBlueprint::macro('hashslug', function () { - $this->string('hashslug')->nullable()->unique(); - }); - - DefaultBlueprint::macro('slug', function () { - $this->string('slug')->nullable()->unique(); - }); - - DefaultBlueprint::macro('label', function () { - $this->string('label')->nullable(); - $this->string('name')->nullable(); - }); - - DefaultBlueprint::macro('expired', function () { - $this->boolean('is_expired')->default(false); - $this->datetime('expired_at')->nullable(); - }); - - DefaultBlueprint::macro('user', function () { - $this->addForeign('user_id', 'users'); - $this->referenceOn('user_id', 'users'); - }); - - DefaultBlueprint::macro('amount', function ($label = 'amount') { - $this->bigInteger($label)->nullable()->default(0); - }); - - DefaultBlueprint::macro('smallAmount', function ($label = 'amount') { - $this->integer($label)->nullable()->default(0); - }); - - DefaultBlueprint::macro('reference', function () { - $this->string('reference')->nullable()->unique()->index(); - }); - - DefaultBlueprint::macro('standardTime', function () { - $this->softDeletes(); - $this->timestamps(); - }); - } -} diff --git a/database/factories/AddressFactory.php b/database/factories/AddressFactory.php deleted file mode 100644 index 1ccd43c..0000000 --- a/database/factories/AddressFactory.php +++ /dev/null @@ -1,14 +0,0 @@ -define(\OSI\Models\Address::class, function (Faker $faker) { - return [ - 'country_id' => $faker->randomElement(range(1, 200)), - 'primary' => $faker->streetName, - 'secondary' => $faker->streetAddress, - 'postcode' => $faker->postcode, - 'city' => $faker->city, - 'state' => $faker->state, - ]; -}); diff --git a/database/factories/EmailFactory.php b/database/factories/EmailFactory.php deleted file mode 100644 index 9b951d6..0000000 --- a/database/factories/EmailFactory.php +++ /dev/null @@ -1,9 +0,0 @@ -define(\OSI\Models\Email::class, function (Faker $faker) { - return [ - 'email' => $faker->companyEmail, - ]; -}); diff --git a/database/factories/PhoneFactory.php b/database/factories/PhoneFactory.php deleted file mode 100644 index 17ff341..0000000 --- a/database/factories/PhoneFactory.php +++ /dev/null @@ -1,10 +0,0 @@ -define(\OSI\Models\Phone::class, function (Faker $faker) { - return [ - 'phone_type_id' => $faker->randomElement([1, 2, 3, 4]), - 'phone_number' => $faker->phoneNumber, - ]; -}); diff --git a/database/migrations/2017_12_23_000005_create_countries_table.php b/database/migrations/2017_12_23_000005_create_countries_table.php deleted file mode 100644 index ef36aed..0000000 --- a/database/migrations/2017_12_23_000005_create_countries_table.php +++ /dev/null @@ -1,33 +0,0 @@ -increments('id'); - $table->string('code'); - $table->label(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('countries'); - } -} diff --git a/database/migrations/2017_12_23_000009_create_phone_types_table.php b/database/migrations/2017_12_23_000009_create_phone_types_table.php deleted file mode 100644 index 83394de..0000000 --- a/database/migrations/2017_12_23_000009_create_phone_types_table.php +++ /dev/null @@ -1,32 +0,0 @@ -increments('id'); - $table->label(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('phone_types'); - } -} diff --git a/database/migrations/2017_12_23_020225_create_addresses_table.php b/database/migrations/2017_12_23_020225_create_addresses_table.php deleted file mode 100644 index 6778e2e..0000000 --- a/database/migrations/2017_12_23_020225_create_addresses_table.php +++ /dev/null @@ -1,42 +0,0 @@ -increments('id'); - $table->hashslug(); - $table->addForeign('country_id', 'countries'); - $table->unsignedInteger('addressable_id'); - $table->string('addressable_type'); - $table->text('primary'); - $table->text('secondary'); - $table->string('postcode'); - $table->string('city'); - $table->string('state'); - $table->standardTime(); - - $table->referenceOn('country_id', 'countries'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('addresses'); - } -} diff --git a/database/migrations/2017_12_23_020240_create_phones_table.php b/database/migrations/2017_12_23_020240_create_phones_table.php deleted file mode 100644 index ab1b5ee..0000000 --- a/database/migrations/2017_12_23_020240_create_phones_table.php +++ /dev/null @@ -1,38 +0,0 @@ -increments('id'); - $table->hashslug(); - $table->addForeign('phone_type_id', 'phone_types'); - $table->unsignedInteger('phoneable_id'); - $table->string('phoneable_type'); - $table->string('phone_number'); - $table->standardTime(); - - $table->referenceOn('phone_type_id', 'phone_types'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('phones'); - } -} diff --git a/database/migrations/2017_12_23_022510_create_emails_table.php b/database/migrations/2017_12_23_022510_create_emails_table.php deleted file mode 100644 index 5c281f8..0000000 --- a/database/migrations/2017_12_23_022510_create_emails_table.php +++ /dev/null @@ -1,36 +0,0 @@ -increments('id'); - $table->hashslug(); - $table->unsignedInteger('emailable_id'); - $table->string('emailable_type'); - $table->string('email'); - $table->boolean('is_default')->default(false); - $table->standardTime(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('emails'); - } -} diff --git a/database/seeds/CountrySeeder.php b/database/seeds/CountrySeeder.php deleted file mode 100644 index 4fd006a..0000000 --- a/database/seeds/CountrySeeder.php +++ /dev/null @@ -1,266 +0,0 @@ - 'Afghanistan', - 'AL' => 'Albania', - 'DZ' => 'Algeria', - 'AS' => 'American Samoa', - 'AD' => 'Andorra', - 'AO' => 'Angola', - 'AI' => 'Anguilla', - 'AQ' => 'Antarctica', - 'AG' => 'Antigua And Barbuda', - 'AR' => 'Argentina', - 'AM' => 'Armenia', - 'AW' => 'Aruba', - 'AU' => 'Australia', - 'AT' => 'Austria', - 'AZ' => 'Azerbaijan', - 'BS' => 'Bahamas', - 'BH' => 'Bahrain', - 'BD' => 'Bangladesh', - 'BB' => 'Barbados', - 'BY' => 'Belarus', - 'BE' => 'Belgium', - 'BZ' => 'Belize', - 'BJ' => 'Benin', - 'BM' => 'Bermuda', - 'BT' => 'Bhutan', - 'BO' => 'Bolivia', - 'BA' => 'Bosnia And Herzegovina', - 'BW' => 'Botswana', - 'BV' => 'Bouvet Island', - 'BR' => 'Brazil', - 'IO' => 'British Indian Ocean Territory', - 'BN' => 'Brunei Darussalam', - 'BG' => 'Bulgaria', - 'BF' => 'Burkina Faso', - 'BI' => 'Burundi', - 'KH' => 'Cambodia', - 'CM' => 'Cameroon', - 'CA' => 'Canada', - 'CV' => 'Cape Verde', - 'KY' => 'Cayman Islands', - 'CF' => 'Central African Republic', - 'TD' => 'Chad', - 'CL' => 'Chile', - 'CN' => 'China', - 'CX' => 'Christmas Island', - 'CC' => 'Cocos (keeling) Islands', - 'CO' => 'Colombia', - 'KM' => 'Comoros', - 'CG' => 'Congo', - 'CD' => 'Congo, The Democratic Republic Of The', - 'CK' => 'Cook Islands', - 'CR' => 'Costa Rica', - 'CI' => 'Cote D\'ivoire', - 'HR' => 'Croatia', - 'CU' => 'Cuba', - 'CY' => 'Cyprus', - 'CZ' => 'Czech Republic', - 'DK' => 'Denmark', - 'DJ' => 'Djibouti', - 'DM' => 'Dominica', - 'DO' => 'Dominican Republic', - 'TP' => 'East Timor', - 'EC' => 'Ecuador', - 'EG' => 'Egypt', - 'SV' => 'El Salvador', - 'GQ' => 'Equatorial Guinea', - 'ER' => 'Eritrea', - 'EE' => 'Estonia', - 'ET' => 'Ethiopia', - 'FK' => 'Falkland Islands (malvinas)', - 'FO' => 'Faroe Islands', - 'FJ' => 'Fiji', - 'FI' => 'Finland', - 'FR' => 'France', - 'GF' => 'French Guiana', - 'PF' => 'French Polynesia', - 'TF' => 'French Southern Territories', - 'GA' => 'Gabon', - 'GM' => 'Gambia', - 'GE' => 'Georgia', - 'DE' => 'Germany', - 'GH' => 'Ghana', - 'GI' => 'Gibraltar', - 'GR' => 'Greece', - 'GL' => 'Greenland', - 'GD' => 'Grenada', - 'GP' => 'Guadeloupe', - 'GU' => 'Guam', - 'GT' => 'Guatemala', - 'GN' => 'Guinea', - 'GW' => 'Guinea-bissau', - 'GY' => 'Guyana', - 'HT' => 'Haiti', - 'HM' => 'Heard Island And Mcdonald Islands', - 'VA' => 'Holy See (vatican City State)', - 'HN' => 'Honduras', - 'HK' => 'Hong Kong', - 'HU' => 'Hungary', - 'IS' => 'Iceland', - 'IN' => 'India', - 'ID' => 'Indonesia', - 'IR' => 'Iran, Islamic Republic Of', - 'IQ' => 'Iraq', - 'IE' => 'Ireland', - 'IL' => 'Israel', - 'IT' => 'Italy', - 'JM' => 'Jamaica', - 'JP' => 'Japan', - 'JO' => 'Jordan', - 'KZ' => 'Kazakstan', - 'KE' => 'Kenya', - 'KI' => 'Kiribati', - 'KP' => 'Korea, Democratic People\'s Republic Of', - 'KR' => 'Korea, Republic Of', - 'KV' => 'Kosovo', - 'KW' => 'Kuwait', - 'KG' => 'Kyrgyzstan', - 'LA' => 'Lao People\'s Democratic Republic', - 'LV' => 'Latvia', - 'LB' => 'Lebanon', - 'LS' => 'Lesotho', - 'LR' => 'Liberia', - 'LY' => 'Libyan Arab Jamahiriya', - 'LI' => 'Liechtenstein', - 'LT' => 'Lithuania', - 'LU' => 'Luxembourg', - 'MO' => 'Macau', - 'MK' => 'Macedonia, The Former Yugoslav Republic Of', - 'MG' => 'Madagascar', - 'MW' => 'Malawi', - 'MY' => 'Malaysia', - 'MV' => 'Maldives', - 'ML' => 'Mali', - 'MT' => 'Malta', - 'MH' => 'Marshall Islands', - 'MQ' => 'Martinique', - 'MR' => 'Mauritania', - 'MU' => 'Mauritius', - 'YT' => 'Mayotte', - 'MX' => 'Mexico', - 'FM' => 'Micronesia, Federated States Of', - 'MD' => 'Moldova, Republic Of', - 'MC' => 'Monaco', - 'MN' => 'Mongolia', - 'MS' => 'Montserrat', - 'ME' => 'Montenegro', - 'MA' => 'Morocco', - 'MZ' => 'Mozambique', - 'MM' => 'Myanmar', - 'NA' => 'Namibia', - 'NR' => 'Nauru', - 'NP' => 'Nepal', - 'NL' => 'Netherlands', - 'AN' => 'Netherlands Antilles', - 'NC' => 'New Caledonia', - 'NZ' => 'New Zealand', - 'NI' => 'Nicaragua', - 'NE' => 'Niger', - 'NG' => 'Nigeria', - 'NU' => 'Niue', - 'NF' => 'Norfolk Island', - 'MP' => 'Northern Mariana Islands', - 'NO' => 'Norway', - 'OM' => 'Oman', - 'PK' => 'Pakistan', - 'PW' => 'Palau', - 'PS' => 'Palestinian Territory, Occupied', - 'PA' => 'Panama', - 'PG' => 'Papua New Guinea', - 'PY' => 'Paraguay', - 'PE' => 'Peru', - 'PH' => 'Philippines', - 'PN' => 'Pitcairn', - 'PL' => 'Poland', - 'PT' => 'Portugal', - 'PR' => 'Puerto Rico', - 'QA' => 'Qatar', - 'RE' => 'Reunion', - 'RO' => 'Romania', - 'RU' => 'Russian Federation', - 'RW' => 'Rwanda', - 'SH' => 'Saint Helena', - 'KN' => 'Saint Kitts And Nevis', - 'LC' => 'Saint Lucia', - 'PM' => 'Saint Pierre And Miquelon', - 'VC' => 'Saint Vincent And The Grenadines', - 'WS' => 'Samoa', - 'SM' => 'San Marino', - 'ST' => 'Sao Tome And Principe', - 'SA' => 'Saudi Arabia', - 'SN' => 'Senegal', - 'RS' => 'Serbia', - 'SC' => 'Seychelles', - 'SL' => 'Sierra Leone', - 'SG' => 'Singapore', - 'SK' => 'Slovakia', - 'SI' => 'Slovenia', - 'SB' => 'Solomon Islands', - 'SO' => 'Somalia', - 'ZA' => 'South Africa', - 'GS' => 'South Georgia And The South Sandwich Islands', - 'ES' => 'Spain', - 'LK' => 'Sri Lanka', - 'SD' => 'Sudan', - 'SR' => 'Suriname', - 'SJ' => 'Svalbard And Jan Mayen', - 'SZ' => 'Swaziland', - 'SE' => 'Sweden', - 'CH' => 'Switzerland', - 'SY' => 'Syrian Arab Republic', - 'TW' => 'Taiwan, Province Of China', - 'TJ' => 'Tajikistan', - 'TZ' => 'Tanzania, United Republic Of', - 'TH' => 'Thailand', - 'TG' => 'Togo', - 'TK' => 'Tokelau', - 'TO' => 'Tonga', - 'TT' => 'Trinidad And Tobago', - 'TN' => 'Tunisia', - 'TR' => 'Turkey', - 'TM' => 'Turkmenistan', - 'TC' => 'Turks And Caicos Islands', - 'TV' => 'Tuvalu', - 'UG' => 'Uganda', - 'UA' => 'Ukraine', - 'AE' => 'United Arab Emirates', - 'GB' => 'United Kingdom', - 'US' => 'United States', - 'UM' => 'United States Minor Outlying Islands', - 'UY' => 'Uruguay', - 'UZ' => 'Uzbekistan', - 'VU' => 'Vanuatu', - 'VE' => 'Venezuela', - 'VN' => 'Viet Nam', - 'VG' => 'Virgin Islands, British', - 'VI' => 'Virgin Islands, U.s.', - 'WF' => 'Wallis And Futuna', - 'EH' => 'Western Sahara', - 'YE' => 'Yemen', - 'ZM' => 'Zambia', - 'ZW' => 'Zimbabwe', - ]; - - foreach ($countries as $code => $name) { - \OSI\Models\Country::create([ - 'code' => $code, - 'name' => $name, - 'label' => str_slug($name, '-'), - ]); - } - } -} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index b8e0128..cc27b8d 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -12,7 +12,5 @@ class DatabaseSeeder extends Seeder public function run() { $this->call(RolesAndPermissionsSeeder::class); - $this->call(CountrySeeder::class); - $this->call(PhoneTypeSeeder::class); } } diff --git a/database/seeds/PhoneTypeSeeder.php b/database/seeds/PhoneTypeSeeder.php deleted file mode 100644 index 24b7f6d..0000000 --- a/database/seeds/PhoneTypeSeeder.php +++ /dev/null @@ -1,28 +0,0 @@ - $datum, - 'label' => str_slug($datum, '-'), - ]); - } - } -} From 3cd1eb5c3cfc2e53becec63ca762cbc5694a7262 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:25:35 +0800 Subject: [PATCH 03/19] Refactor to be configurable --- config/acl.php | 5 +++++ database/seeds/RolesAndPermissionsSeeder.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 config/acl.php diff --git a/config/acl.php b/config/acl.php new file mode 100644 index 0000000..cbd582c --- /dev/null +++ b/config/acl.php @@ -0,0 +1,5 @@ +forget('spatie.permission.cache'); - collect(['administrator', 'user'])->each(function ($role) { + collect(config('acl.roles'))->each(function ($role) { Role::create(['name' => $role]); }); } From 6d237c46332c1f350d708cc2cb10fbadfd5b9c92 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:25:54 +0800 Subject: [PATCH 04/19] Use Blueprint Macro Package Instead --- app/Providers/MacroServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/MacroServiceProvider.php b/app/Providers/MacroServiceProvider.php index 74f62f2..dc90fe4 100644 --- a/app/Providers/MacroServiceProvider.php +++ b/app/Providers/MacroServiceProvider.php @@ -13,7 +13,7 @@ class MacroServiceProvider extends ServiceProvider */ public function boot() { - \OSI\Macros\Database\Schema\Blueprint::registerMacros(); + } /** From b3ce911f744bd0b3313224cb6f53ee5cd6054658 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:26:11 +0800 Subject: [PATCH 05/19] Refactor load dev providers --- app/Providers/AppServiceProvider.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 6ef0f60..394df67 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -6,15 +6,32 @@ class AppServiceProvider extends ServiceProvider { + /** + * List of providers for development + * @var array + */ + protected $providers_dev = []; + /** * Bootstrap any application services. * * @return void */ public function boot() + { + $this->bootDevProviders(); + } + + /** + * Boot Development Providers + * @return void + */ + private function bootDevProviders() { if ($this->app->environment() !== 'production') { - $this->app->register(\NasrulHazim\ArtisanMakers\ArtisanMakersServiceProvider::class); + foreach ($this->providers_dev as $provider) { + $this->app->register($provider); + } } } From db84ef3932a4598ce1fbed02c69f2b9a0a140338 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:26:21 +0800 Subject: [PATCH 06/19] Added travis ci --- .travis.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5fd2894 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: php + +php: + - 7.0 + - 7.1 + - 7.2 + +before_script: + - travis_retry composer self-update + - travis_retry composer update --prefer-source --no-interaction --dev + +script: + - vendor/bin/phpunit -v --coverage-text --colors=never --stderr From 865b37fd21d321019b56e9498430e650eedab8c5 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:28:39 +0800 Subject: [PATCH 07/19] Added Artisan Makers, Blueprint Macro and Profile Package --- composer.json | 4 +- composer.lock | 178 ++++++++++++++++++++++++++++++++++++++----------- config/app.php | 3 + 3 files changed, 145 insertions(+), 40 deletions(-) diff --git a/composer.json b/composer.json index 061e9a4..02fc57c 100644 --- a/composer.json +++ b/composer.json @@ -6,11 +6,13 @@ "type": "project", "require": { "php": ">=7.0.0", + "cleaniquecoders/artisan-makers": "^1.0", + "cleaniquecoders/blueprint-macro": "^1.0", + "cleaniquecoders/profile": "^1.0", "fideloper/proxy": "~3.3", "hashids/hashids": "^2.0", "laravel/framework": "5.5.*", "laravel/tinker": "~1.0", - "nasrulhazim/artisanmakers": "^1.0", "spatie/image-optimizer": "^1.0", "spatie/laravel-activitylog": "^2.3", "spatie/laravel-analytics": "^3.3", diff --git a/composer.lock b/composer.lock index 7b79420..f0a3fe3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "a566c0e7b6ffde49b88c7ee0bda547bc", + "content-hash": "68704b2d94c4aaf791c645071119669b", "packages": [ { "name": "anahkiasen/underscore-php", @@ -56,6 +56,144 @@ ], "time": "2015-05-16T19:24:58+00:00" }, + { + "name": "cleaniquecoders/artisan-makers", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/cleaniquecoders/artisan-makers.git", + "reference": "4050ecc83e61464e7fc118803bfff57167308828" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cleaniquecoders/artisan-makers/zipball/4050ecc83e61464e7fc118803bfff57167308828", + "reference": "4050ecc83e61464e7fc118803bfff57167308828", + "shasum": "" + }, + "require": { + "illuminate/support": "^5.5", + "php": ">=7.0" + }, + "require-dev": { + "codedungeon/phpunit-result-printer": "^0.4.4", + "orchestra/testbench": "~3.0", + "phpunit/phpunit": "^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "CleaniqueCoders\\ArtisanMakers\\": "src/" + }, + "files": [ + "src/Support/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nasrul Hazim", + "email": "nasrulhazim.m@gmail.com" + } + ], + "description": "Built with Laravel Standalone Package Creator", + "time": "2018-01-25T23:49:53+00:00" + }, + { + "name": "cleaniquecoders/blueprint-macro", + "version": "v1.0.4", + "source": { + "type": "git", + "url": "https://github.com/cleaniquecoders/blueprint-macro.git", + "reference": "47d3184855f6d7328985e1e43420725b9e01be0f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cleaniquecoders/blueprint-macro/zipball/47d3184855f6d7328985e1e43420725b9e01be0f", + "reference": "47d3184855f6d7328985e1e43420725b9e01be0f", + "shasum": "" + }, + "require": { + "illuminate/auth": "^5.5", + "illuminate/database": "^5.5", + "illuminate/support": "^5.5" + }, + "require-dev": { + "codedungeon/phpunit-result-printer": "^0.4.4", + "orchestra/testbench": "~3.0", + "phpunit/phpunit": "^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "CleaniqueCoders\\Blueprint\\Macro\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nasrul Hazim", + "email": "nasrulhazim.m@gmail.com" + } + ], + "description": "Laravel Blueprint Macro", + "time": "2018-01-25T04:50:19+00:00" + }, + { + "name": "cleaniquecoders/profile", + "version": "v1.0.7", + "source": { + "type": "git", + "url": "https://github.com/cleaniquecoders/profile.git", + "reference": "fbaf0d0ddb2f1b16f75a76929c76b3025d7f871c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cleaniquecoders/profile/zipball/fbaf0d0ddb2f1b16f75a76929c76b3025d7f871c", + "reference": "fbaf0d0ddb2f1b16f75a76929c76b3025d7f871c", + "shasum": "" + }, + "require": { + "cleaniquecoders/blueprint-macro": "^1.0", + "illuminate/auth": "^5.5", + "illuminate/support": "^5.5" + }, + "require-dev": { + "codedungeon/phpunit-result-printer": "^0.4.4", + "orchestra/testbench": "~3.0", + "phpunit/phpunit": "^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "CleaniqueCoders\\Profile\\": "src/" + }, + "classmap": [ + "src/database/seeds", + "src/database/factories" + ], + "files": [ + "src/Support/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nasrul Hazim", + "email": "nasrulhazim.m@gmail.com" + } + ], + "description": "Common Profile Information", + "time": "2018-01-25T05:49:48+00:00" + }, { "name": "dnoegel/php-xdg-base-dir", "version": "0.1", @@ -1470,44 +1608,6 @@ ], "time": "2017-01-23T04:29:33+00:00" }, - { - "name": "nasrulhazim/artisanmakers", - "version": "v1.0.2", - "source": { - "type": "git", - "url": "https://github.com/nasrulhazim/artisanmakers.git", - "reference": "9c5f2650a91834af3848e51376f5ff20227c7192" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nasrulhazim/artisanmakers/zipball/9c5f2650a91834af3848e51376f5ff20227c7192", - "reference": "9c5f2650a91834af3848e51376f5ff20227c7192", - "shasum": "" - }, - "require": { - "illuminate/console": "5.5.*", - "illuminate/support": "5.5.*" - }, - "type": "library", - "autoload": { - "psr-4": { - "NasrulHazim\\ArtisanMakers\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nasrul Hazim", - "email": "nasrulhazim.m@gmail.com" - } - ], - "description": "Laravel Artisan Makers", - "abandoned": "cleaniquecoders/artisan-makers", - "time": "2017-12-24T07:56:29+00:00" - }, { "name": "nesbot/carbon", "version": "1.22.1", diff --git a/config/app.php b/config/app.php index 94a313a..d561322 100644 --- a/config/app.php +++ b/config/app.php @@ -173,6 +173,9 @@ Spatie\GoogleCalendar\GoogleCalendarServiceProvider::class, Spatie\Html\HtmlServiceProvider::class, UxWeb\SweetAlert\SweetAlertServiceProvider::class, + CleaniqueCoders\Blueprint\Macro\BlueprintMacroServiceProvider::class, + CleaniqueCoders\Profile\ProfileServiceProvider::class, + CleaniqueCoders\ArtisanMakers\ArtisanMakersServiceProvider::class, /* * Application Service Providers... From e36d480292ef113564ad0da2741c82be0120645e Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:29:26 +0800 Subject: [PATCH 08/19] Update readme --- README.md | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index a549256..8df22bc 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,42 @@ -# Web Application Boilerplate +[![Build Status](https://travis-ci.org/cleaniquecoders/laravel-boilerplate.svg?branch=master)](https://travis-ci.org/cleaniquecoders/laravel-boilerplate) [![Latest Stable Version](https://poser.pugx.org/cleaniquecoders/laravel-boilerplate/v/stable)](https://packagist.org/packages/cleaniquecoders/laravel-boilerplate) [![Total Downloads](https://poser.pugx.org/cleaniquecoders/laravel-boilerplate/downloads)](https://packagist.org/packages/cleaniquecoders/laravel-boilerplate) [![License](https://poser.pugx.org/cleaniquecoders/laravel-boilerplate/license)](https://packagist.org/packages/cleaniquecoders/laravel-boilerplate) -A boilerplate to speed up development. +# Laravel Boilerplate + +A boilerplate to speed up web application development. # Installation ``` -$ composer create-project osinitiative/web-app-boilerplate your-project-name "1.0.1" +$ composer create-project cleaniquecoders/laravel-boilerplate ``` # Packages -Most of the packages from Spatie. - -1. Laravel Permission -2. Laravel Media Library -3. Laravel Activity -4. Laravel Newsletter -5. Laravel Analytics -6. Laravel Response Cache -7. Laravel Sluggable -8. Laravel Menu -9. Laravel Collection Macros -10. Laravel Google Calendar -11. Laravel Html -12. Image Optimizer - -# Google API +1. [Cleanique Coders](https://github.com/cleaniquecoders) +- Artisan Makers +- Blueprint Macro +- Profile +2. [Laravel Proxy Package](https://github.com/fideloper/TrustedProxy) +3. [Spatie](https://github.com/spatie) +- Image Optimizer +- Laravel Activitylog +- Laravel Analytics +- Laravel Collection Macros +- Laravel Google Calendar +- Laravel Html +- Laravel Medialibrary +- Laravel Menu +- Laravel Permission +- Laravel Referer +- Laravel Responsecache +- Laravel Sluggable +4. [Hashids](https://github.com/ivanakimov/hashids.php) +4. [Sweet Alert](https://github.com/uxweb/sweet-alert) +5. [Sempro PHPUnit Pretty Printer](https://github.com/Sempro/phpunit-pretty-print) + +# Setup + +## Google API Create [Google Service Account Credentials](https://console.developers.google.com/apis/dashboard?project=karnival-usahawan-desa) for: From 1e1663907719e561196b3299ff8e541bdfa395f1 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:31:23 +0800 Subject: [PATCH 09/19] Fixed indentation --- README.md | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 8df22bc..ea370f5 100644 --- a/README.md +++ b/README.md @@ -13,26 +13,30 @@ $ composer create-project cleaniquecoders/laravel-boilerplate # Packages 1. [Cleanique Coders](https://github.com/cleaniquecoders) -- Artisan Makers -- Blueprint Macro -- Profile + + - Artisan Makers + - Blueprint Macro + - Profile + 2. [Laravel Proxy Package](https://github.com/fideloper/TrustedProxy) 3. [Spatie](https://github.com/spatie) -- Image Optimizer -- Laravel Activitylog -- Laravel Analytics -- Laravel Collection Macros -- Laravel Google Calendar -- Laravel Html -- Laravel Medialibrary -- Laravel Menu -- Laravel Permission -- Laravel Referer -- Laravel Responsecache -- Laravel Sluggable + + - Image Optimizer + - Laravel Activitylog + - Laravel Analytics + - Laravel Collection Macros + - Laravel Google Calendar + - Laravel Html + - Laravel Medialibrary + - Laravel Menu + - Laravel Permission + - Laravel Referer + - Laravel Responsecache + - Laravel Sluggable + 4. [Hashids](https://github.com/ivanakimov/hashids.php) -4. [Sweet Alert](https://github.com/uxweb/sweet-alert) -5. [Sempro PHPUnit Pretty Printer](https://github.com/Sempro/phpunit-pretty-print) +5. [Sweet Alert](https://github.com/uxweb/sweet-alert) +6. [Sempro PHPUnit Pretty Printer](https://github.com/Sempro/phpunit-pretty-print) # Setup From a981700dbfc0d2df12eb3d44c37bfe868a70dea2 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:36:52 +0800 Subject: [PATCH 10/19] Update root namespace, remove has profile trait and morphs trait. --- app/Console/Kernel.php | 2 +- app/Contracts/MacroContract.php | 11 -------- app/Exceptions/Handler.php | 2 +- .../Auth/ForgotPasswordController.php | 4 +-- app/Http/Controllers/Auth/LoginController.php | 4 +-- .../Controllers/Auth/RegisterController.php | 8 +++--- .../Auth/ResetPasswordController.php | 4 +-- app/Http/Controllers/Controller.php | 2 +- app/Http/Controllers/HomeController.php | 2 +- .../Controllers/User/AvatarController.php | 4 +-- app/Http/Controllers/User/LogController.php | 4 +-- app/Http/Controllers/WelcomeController.php | 2 +- app/Http/Kernel.php | 12 ++++----- app/Http/Middleware/EncryptCookies.php | 2 +- .../Middleware/RedirectIfAuthenticated.php | 2 +- app/Http/Middleware/TrimStrings.php | 2 +- app/Http/Middleware/TrustProxies.php | 2 +- app/Http/Middleware/VerifyCsrfToken.php | 2 +- app/Listeners/AssignDefaultRole.php | 2 +- app/Listeners/LogFailedLogin.php | 2 +- app/Listeners/LogPasswordReset.php | 2 +- app/Listeners/LogSuccessfulLogin.php | 2 +- app/Listeners/LogSuccessfulLogout.php | 2 +- app/Models/Address.php | 27 ------------------- app/Models/Country.php | 10 ------- app/Models/Email.php | 18 ------------- app/Models/Phone.php | 18 ------------- app/Models/PhoneType.php | 13 --------- app/Models/User.php | 12 ++++----- app/Observers/HashidsObserver.php | 2 +- app/Observers/Kernel.php | 10 +++---- app/Observers/ReferenceObserver.php | 2 +- app/Providers/AppServiceProvider.php | 2 +- app/Providers/AuthServiceProvider.php | 4 +-- app/Providers/BroadcastServiceProvider.php | 2 +- app/Providers/EventServiceProvider.php | 12 ++++----- app/Providers/MacroServiceProvider.php | 2 +- app/Providers/ObserverServiceProvider.php | 4 +-- app/Providers/RouteServiceProvider.php | 4 +-- app/Services/Hashids.php | 4 +-- app/Support/helpers.php | 2 +- app/Traits/HasMediaExtended.php | 2 +- app/Traits/HasProfile.php | 15 ----------- app/Traits/HasSlugExtended.php | 2 +- app/Traits/HasThumbnail.php | 2 +- app/Traits/LogsActivityExtended.php | 2 +- app/Traits/Morphs/Addressable.php | 17 ------------ app/Traits/Morphs/Emailable.php | 17 ------------ app/Traits/Morphs/Phoneable.php | 17 ------------ bootstrap/app.php | 6 ++--- composer.json | 4 +-- config/app.php | 14 +++++----- config/auth.php | 2 +- database/factories/UserFactory.php | 2 +- 54 files changed, 84 insertions(+), 247 deletions(-) delete mode 100644 app/Contracts/MacroContract.php delete mode 100644 app/Models/Address.php delete mode 100644 app/Models/Country.php delete mode 100644 app/Models/Email.php delete mode 100644 app/Models/Phone.php delete mode 100644 app/Models/PhoneType.php delete mode 100644 app/Traits/HasProfile.php delete mode 100644 app/Traits/Morphs/Addressable.php delete mode 100644 app/Traits/Morphs/Emailable.php delete mode 100644 app/Traits/Morphs/Phoneable.php diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ea4d6fd..a8c5158 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -1,6 +1,6 @@ [ - \OSI\Http\Middleware\EncryptCookies::class, + \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, - \OSI\Http\Middleware\VerifyCsrfToken::class, + \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \Spatie\Referer\CaptureReferer::class, \UxWeb\SweetAlert\ConvertMessagesIntoSweetAlert::class, @@ -57,7 +57,7 @@ class Kernel extends HttpKernel 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, - 'guest' => \OSI\Http\Middleware\RedirectIfAuthenticated::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, ]; } diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php index 53d975e..033136a 100644 --- a/app/Http/Middleware/EncryptCookies.php +++ b/app/Http/Middleware/EncryptCookies.php @@ -1,6 +1,6 @@ morphTo(); - } - - /** - * Get Country - * @return \OSI\Models\Country - */ - public function country() - { - return $this->belongsTo(Country::class); - } -} diff --git a/app/Models/Country.php b/app/Models/Country.php deleted file mode 100644 index 5aa6fdd..0000000 --- a/app/Models/Country.php +++ /dev/null @@ -1,10 +0,0 @@ -morphTo(); - } -} diff --git a/app/Models/Phone.php b/app/Models/Phone.php deleted file mode 100644 index 3bd4482..0000000 --- a/app/Models/Phone.php +++ /dev/null @@ -1,18 +0,0 @@ -morphTo(); - } -} diff --git a/app/Models/PhoneType.php b/app/Models/PhoneType.php deleted file mode 100644 index a32016a..0000000 --- a/app/Models/PhoneType.php +++ /dev/null @@ -1,13 +0,0 @@ - [ + \App\Observers\ReferenceObserver::class => [ ], - \OSI\Observers\HashidsObserver::class => [ - \OSI\Models\User::class, + \App\Observers\HashidsObserver::class => [ + \App\Models\User::class, \Spatie\MediaLibrary\Media::class, ], ]; /** * Make this class - * @return \OSI\Observers\Kernel + * @return \App\Observers\Kernel */ public static function make() { diff --git a/app/Observers/ReferenceObserver.php b/app/Observers/ReferenceObserver.php index d63cb07..9982b11 100644 --- a/app/Observers/ReferenceObserver.php +++ b/app/Observers/ReferenceObserver.php @@ -1,6 +1,6 @@ 'OSI\Policies\ModelPolicy', + 'App\Model' => 'App\Policies\ModelPolicy', ]; /** diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index e01fb7f..352cce4 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -1,6 +1,6 @@ [ - 'OSI\Listeners\AssignDefaultRole', + 'App\Listeners\AssignDefaultRole', ], 'Illuminate\Auth\Events\Login' => [ - 'OSI\Listeners\LogSuccessfulLogin', + 'App\Listeners\LogSuccessfulLogin', ], 'Illuminate\Auth\Events\Failed' => [ - 'OSI\Listeners\LogFailedLogin', + 'App\Listeners\LogFailedLogin', ], 'Illuminate\Auth\Events\Logout' => [ - 'OSI\Listeners\LogSuccessfulLogout', + 'App\Listeners\LogSuccessfulLogout', ], 'Illuminate\Auth\Events\PasswordReset' => [ - 'OSI\Listeners\LogPasswordReset', + 'App\Listeners\LogPasswordReset', ], ]; diff --git a/app/Providers/MacroServiceProvider.php b/app/Providers/MacroServiceProvider.php index dc90fe4..8f7fc90 100644 --- a/app/Providers/MacroServiceProvider.php +++ b/app/Providers/MacroServiceProvider.php @@ -1,6 +1,6 @@ observes(); + \App\Observers\Kernel::make()->observes(); } /** diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 13880e9..5ea48d3 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -1,6 +1,6 @@ morphMany(\OSI\Models\Address::class, 'addressable'); - } -} diff --git a/app/Traits/Morphs/Emailable.php b/app/Traits/Morphs/Emailable.php deleted file mode 100644 index a5d95a7..0000000 --- a/app/Traits/Morphs/Emailable.php +++ /dev/null @@ -1,17 +0,0 @@ -morphMany(\CLNQCDRS\Models\Email::class, 'emailable'); - } -} diff --git a/app/Traits/Morphs/Phoneable.php b/app/Traits/Morphs/Phoneable.php deleted file mode 100644 index 440dba2..0000000 --- a/app/Traits/Morphs/Phoneable.php +++ /dev/null @@ -1,17 +0,0 @@ -morphMany(\OSI\Models\Phone::class, 'phoneable'); - } -} diff --git a/bootstrap/app.php b/bootstrap/app.php index c745052..f2801ad 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -28,17 +28,17 @@ $app->singleton( Illuminate\Contracts\Http\Kernel::class, - OSI\Http\Kernel::class + App\Http\Kernel::class ); $app->singleton( Illuminate\Contracts\Console\Kernel::class, - OSI\Console\Kernel::class + App\Console\Kernel::class ); $app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, - OSI\Exceptions\Handler::class + App\Exceptions\Handler::class ); /* diff --git a/composer.json b/composer.json index 02fc57c..cdf222f 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "database/factories" ], "psr-4": { - "OSI\\": "app/" + "App\\": "app/" }, "files": [ "app/Support/helpers.php" @@ -48,7 +48,7 @@ }, "autoload-dev": { "psr-4": { - "Tests\\": "tests/" + "App\\Tests\\": "tests/" } }, "extra": { diff --git a/config/app.php b/config/app.php index d561322..e179488 100644 --- a/config/app.php +++ b/config/app.php @@ -180,13 +180,13 @@ /* * Application Service Providers... */ - OSI\Providers\AppServiceProvider::class, - OSI\Providers\AuthServiceProvider::class, - // OSI\Providers\BroadcastServiceProvider::class, - OSI\Providers\EventServiceProvider::class, - OSI\Providers\RouteServiceProvider::class, - OSI\Providers\MacroServiceProvider::class, - OSI\Providers\ObserverServiceProvider::class, + App\Providers\AppServiceProvider::class, + App\Providers\AuthServiceProvider::class, + // App\Providers\BroadcastServiceProvider::class, + App\Providers\EventServiceProvider::class, + App\Providers\RouteServiceProvider::class, + App\Providers\MacroServiceProvider::class, + App\Providers\ObserverServiceProvider::class, ], diff --git a/config/auth.php b/config/auth.php index 72769bf..3c3d93f 100644 --- a/config/auth.php +++ b/config/auth.php @@ -67,7 +67,7 @@ 'providers' => [ 'users' => [ 'driver' => 'eloquent', - 'model' => OSI\Models\User::class, + 'model' => App\Models\User::class, ], // 'users' => [ diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 04aaf53..71bd9be 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -13,7 +13,7 @@ | */ -$factory->define(\OSI\Models\User::class, function (Faker $faker) { +$factory->define(\App\Models\User::class, function (Faker $faker) { static $password; return [ From 74381b1f59db52e35e7e2cacd4105b699e161502 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:45:28 +0800 Subject: [PATCH 11/19] Added reload:db command --- app/Console/Commands/ReloadDbCommand.php | 44 ++++++++++++++++++++++++ app/Console/Kernel.php | 4 +-- 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 app/Console/Commands/ReloadDbCommand.php diff --git a/app/Console/Commands/ReloadDbCommand.php b/app/Console/Commands/ReloadDbCommand.php new file mode 100644 index 0000000..a8d6283 --- /dev/null +++ b/app/Console/Commands/ReloadDbCommand.php @@ -0,0 +1,44 @@ +call('migrate:fresh', ['--seed' => true]); + $this->info('Seeding Profile Dependencies'); + $this->call('profile:seed'); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a8c5158..a5af0b7 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ - // + \App\Console\Commands\ReloadDbCommand::class, ]; /** @@ -35,7 +35,7 @@ protected function schedule(Schedule $schedule) */ protected function commands() { - $this->load(__DIR__.'/Commands'); + $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } From 10715c1cea61ffd2500868ec04b3055d7bf7649a Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 09:49:49 +0800 Subject: [PATCH 12/19] Added reload:cache Command --- app/Console/Commands/ReloadCacheCommand.php | 46 +++++++++++++++++++++ app/Console/Kernel.php | 1 + 2 files changed, 47 insertions(+) create mode 100644 app/Console/Commands/ReloadCacheCommand.php diff --git a/app/Console/Commands/ReloadCacheCommand.php b/app/Console/Commands/ReloadCacheCommand.php new file mode 100644 index 0000000..862de1f --- /dev/null +++ b/app/Console/Commands/ReloadCacheCommand.php @@ -0,0 +1,46 @@ +call('cache:clear'); + $this->call('config:cache'); + $this->call('responsecache:flush'); + $this->call('route:cache'); + $this->call('view:clear'); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a5af0b7..d1e7bcb 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -14,6 +14,7 @@ class Kernel extends ConsoleKernel */ protected $commands = [ \App\Console\Commands\ReloadDbCommand::class, + \App\Console\Commands\ReloadCacheCommand::class, ]; /** From e796ca514f775d62f3e12d3fe8b88344df6eacd8 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 10:07:13 +0800 Subject: [PATCH 13/19] Update readme --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index ea370f5..d6d8b79 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,21 @@ A boilerplate to speed up web application development. $ composer create-project cleaniquecoders/laravel-boilerplate ``` +Configure your `.env`, then: + +``` +$ php artisan reload:db +``` + +# Usage + +## Commands + +There's some commands area ready built-in. Others, may refer to respective packages. + +- `reload:db` - Run `migrate:fresh --seed` with `profile:seed`. You may extend the usage. +- `reload:cache` - Recache everything + # Packages 1. [Cleanique Coders](https://github.com/cleaniquecoders) From d183fe016c55709fc8d65a60747dc810f45277be Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 10:13:27 +0800 Subject: [PATCH 14/19] Added License and update readme --- LICENSE.txt | 21 ++++++++++++++++ README.md | 72 +++++++++++++++++++++++++++++++++-------------------- 2 files changed, 66 insertions(+), 27 deletions(-) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..4a96b55 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index d6d8b79..e673beb 100644 --- a/README.md +++ b/README.md @@ -2,30 +2,9 @@ # Laravel Boilerplate -A boilerplate to speed up web application development. +A boilerplate based on Laravel Framework to speed up web application development setup. -# Installation - -``` -$ composer create-project cleaniquecoders/laravel-boilerplate -``` - -Configure your `.env`, then: - -``` -$ php artisan reload:db -``` - -# Usage - -## Commands - -There's some commands area ready built-in. Others, may refer to respective packages. - -- `reload:db` - Run `migrate:fresh --seed` with `profile:seed`. You may extend the usage. -- `reload:cache` - Recache everything - -# Packages +## Packages 1. [Cleanique Coders](https://github.com/cleaniquecoders) @@ -53,15 +32,54 @@ There's some commands area ready built-in. Others, may refer to respective packa 5. [Sweet Alert](https://github.com/uxweb/sweet-alert) 6. [Sempro PHPUnit Pretty Printer](https://github.com/Sempro/phpunit-pretty-print) -# Setup +## Installation -## Google API +``` +$ composer create-project cleaniquecoders/laravel-boilerplate +``` + +Configure your `.env`, then: + +``` +$ php artisan reload:db +``` + +### Google API Create [Google Service Account Credentials](https://console.developers.google.com/apis/dashboard?project=karnival-usahawan-desa) for: 1. [Google Calendar](https://github.com/spatie/laravel-google-calendar#how-to-obtain-the-credentials-to-communicate-with-google-calendar) 2. [Google Analytic](https://github.com/spatie/laravel-analytics#how-to-obtain-the-credentials-to-communicate-with-google-analytics) -# TODO +## Usage + +### Commands + +There's some commands area ready built-in. Others, may refer to respective packages. + +- `reload:db` - Run `migrate:fresh --seed` with `profile:seed`. You may extend the usage. +- `reload:cache` - Recache everything + +## Test + +To run the test, type `vendor/bin/phpunit` in your terminal. + +To have codes coverage, please ensure to install PHP XDebug then run the following command: + +``` +$ vendor/bin/phpunit -v --coverage-text --colors=never --stderr +``` + +## Contributions + +Everyone are welcome to contribute to this package. However, it's a good practice to provide: + +1. The problem you solved +2. Provide test +3. Documentation + +Without these 3, you may add extra work for the maintainer. + +## License -1. Media Library for User +This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT). From bda9771f5638d769feae03cb55685a99863098fd Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 11:23:28 +0800 Subject: [PATCH 15/19] Clean up helpers - allow non-unique abbreviation - refactor str_slug_fqcn - rename userlog to audit, and accept 3rd argument optionally --- app/Support/helpers.php | 47 ++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/app/Support/helpers.php b/app/Support/helpers.php index b60b248..964ad9a 100644 --- a/app/Support/helpers.php +++ b/app/Support/helpers.php @@ -15,22 +15,27 @@ function generate_sequence($input = 1) * Get Abbreviation fo the given text */ if (!function_exists('abbrv')) { - function abbrv($value) + function abbrv($value, $unique_characters = true) { $removeNonAlphanumeric = preg_replace("/[^A-Za-z0-9 ]/", '', $value); $removeVowels = str_replace( ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U', ' '], '', $removeNonAlphanumeric); - $uppercase = strtoupper($removeVowels); - $split = str_split($uppercase); - $unique_characters = []; - foreach ($split as $character) { - if (!in_array($character, $unique_characters)) { - $unique_characters[] = $character; + + $uppercase = strtoupper($removeVowels); + + if ($unique_characters) { + $split = str_split($uppercase); + $unique_characters = []; + foreach ($split as $character) { + if (!in_array($character, $unique_characters)) { + $unique_characters[] = $character; + } } + return implode('', $unique_characters); } - return implode('', $unique_characters); + return $uppercase; } } @@ -77,23 +82,27 @@ function hashids($salt = null, $length = null, $alphabet = null) * Get Slug Name for Fully Qualified Class Name (FQCN) */ if (!function_exists('str_slug_fqcn')) { - function str_slug_fqcn($value) + function str_slug_fqcn($object) { - $fqcn = get_class($value); - $fqcn = str_replace('\\', '-', $fqcn); - return strtolower($fqcn); + return strtolower(str_replace('\\', '-', get_class($object))); } } /** - * Log Current logged in user activities + * Audit Trail */ -if (!function_exists('userlog')) { - function userlog($model, $message) +if (!function_exists('audit')) { + function audit($model, $message, $causedBy = null) { - activity() - ->performedOn($model) - ->causedBy(auth()->user()) - ->log($message); + if (is_null($causedBy)) { + activity() + ->performedOn($model) + ->log($message); + } else { + activity() + ->performedOn($model) + ->causedBy(auth()->user()) + ->log($message); + } } } From 346a2de165b44c4ff011e967fe6c17840d809975 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 11:23:41 +0800 Subject: [PATCH 16/19] Rename userlog to audit --- app/Http/Controllers/User/AvatarController.php | 2 +- app/Listeners/LogPasswordReset.php | 2 +- app/Listeners/LogSuccessfulLogin.php | 2 +- app/Listeners/LogSuccessfulLogout.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/User/AvatarController.php b/app/Http/Controllers/User/AvatarController.php index 6cf22ac..96e1034 100644 --- a/app/Http/Controllers/User/AvatarController.php +++ b/app/Http/Controllers/User/AvatarController.php @@ -28,7 +28,7 @@ public function store(Request $request) ->usingFileName('avatar.png') ->toMediaCollection('avatar'); - userlog(auth()->user(), 'Uploaded new avatar'); + audit(auth()->user(), 'Uploaded new avatar'); alert()->success('New Avatar Uploaded'); diff --git a/app/Listeners/LogPasswordReset.php b/app/Listeners/LogPasswordReset.php index 0daad5d..ae62e51 100644 --- a/app/Listeners/LogPasswordReset.php +++ b/app/Listeners/LogPasswordReset.php @@ -24,6 +24,6 @@ public function __construct() */ public function handle(PasswordReset $event) { - userlog($event->user, 'User successfully logged in.'); + audit($event->user, 'User successfully reset password.'); } } diff --git a/app/Listeners/LogSuccessfulLogin.php b/app/Listeners/LogSuccessfulLogin.php index 7b4b368..6524ef2 100644 --- a/app/Listeners/LogSuccessfulLogin.php +++ b/app/Listeners/LogSuccessfulLogin.php @@ -24,6 +24,6 @@ public function __construct() */ public function handle(Login $event) { - userlog($event->user, 'User successfully logged in.'); + audit($event->user, 'User successfully logged in.'); } } diff --git a/app/Listeners/LogSuccessfulLogout.php b/app/Listeners/LogSuccessfulLogout.php index 0fb3997..d9abe45 100644 --- a/app/Listeners/LogSuccessfulLogout.php +++ b/app/Listeners/LogSuccessfulLogout.php @@ -24,6 +24,6 @@ public function __construct() */ public function handle(Logout $event) { - userlog($event->user, 'User successfully logged out.'); + audit($event->user, 'User successfully logged out.'); } } From 0a3fba437cff5c06be6f1840d7cc77fbc05fe352 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 11:23:58 +0800 Subject: [PATCH 17/19] Update readme on helpers section --- README.md | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/README.md b/README.md index e673beb..773b5b2 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,138 @@ There's some commands area ready built-in. Others, may refer to respective packa - `reload:db` - Run `migrate:fresh --seed` with `profile:seed`. You may extend the usage. - `reload:cache` - Recache everything +### Helpers + +**generate_sequence($count)** + +Generate sequence with leading zero like `000001`, `000002` and so on. + +Length for the leading zero can be configure in `.env` file - `DOCUMENT_SEQUENCE_LENGTH`. + +**abbrv($word, $unique_characters)** + +A helper to create abbreviation by removing non-alphanumeric, vowels. + +Passing second argument as false will return non-unique characters - means that you will see repeatative characters. + +Following are the sample usage and output: + +``` +>>> abbrv("Cleanique Coders") +=> "CLNQDRS" +>>> abbrv("Cleanique Coders", false) +=> "CLNQCDRS" +``` + +**generate_reference($prefix, $count)** + +Generate document reference string. Usually a document have their own reference on the particular date event. + +For instance a payslip document have a reference number / string like `CCR/PYSL/2018/01/000001`. + +The format generate is `abbrv/Year/Month/Date/reference_id`. + +You can use in two ways: + +``` +>>> generate_reference("Cleanique Coders Payroll") +=> "CLNQ/CDRS/PYRL/2018/02/04/TBIPOU" +>>> generate_reference("Cleanique Coders Payroll", 10) +=> "CLNQ/CDRS/PYRL/2018/02/04/000010" +``` + +The length of the `TBIPOU` or `000010` is depends on `DOCUMENT_SEQUENCE_LENGTH` in `.env` file. + +**hashids($salt, $length, $alphabet)** + +It's essential to have important resources to use other than just incremental id. One of the option is to use [Hashids](https://github.com/ivanakimov/hashids.php). + +Following are an example how to use the helper. + +``` +>>> hashids()->encode(1) +=> "yR5ajG4DBwlz" +>>> hashids('random-salt')->encode(1) +=> "WZvoOMBr19YN" +>>> hashids('random-salt', 24)->encode(1) +=> "GPz1W4mLavAeqAwB2XZbOgQn" +>>> hashids('random-salt', 6)->encode(1) +=> "5qy0lP" +>>> hashids('random-salt', 6, 'qwertyuiopasdfghjkl')->encode(1) +=> "orgpqe" +>>> hashids('random-salt', 6, ',./;<>?:"{}|[]\-=`~!@#$%^&*()')->encode(1) +=> "{&(^&-" +>>> hashids('random-salt', 12, ',./;<>?:"{}|[]\-=`~!@#$%^&*()')->encode(1) +=> "~-!\`-&(*[{)" +``` + +For `$salt`, by default it will use `APP_KEY`, but you may override it by passing the salt name at the first argument. + +For `$length`, you can pass any length of hashids you want to create. By default it's 12 characters. + +For `$alphabet`, you can put any characters as per example above. But remember, the alphabets need to be minimum of **16 characters**. + +**str_slug_fqcn($object)** + +Return slug name for given object. + +``` +>>> $user = \App\Models\User::first(); +=> App\Models\User {#1013 + id: 1, + hashslug: "krOErpkv6EVR", + slug: "elza-bins", + name: "Elza Bins", + email: "kautzer.polly@example.com", + deleted_at: null, + created_at: "2018-02-04 03:11:07", + updated_at: "2018-02-04 03:11:07", + } +>>> str_slug_fqcn($user) +=> "app-models-user" +``` + +**audit($model, $message, $causedBy)** + +Simply record audit trail on given `$model`, with proper `$message`. You can optionally passed the third argument - `$causedBy`. + +``` +>>> auth()->loginUsingId(1) +>>> $user = \App\Models\User::first(); +>>> audit($user, 'access via terminal') +>>> auth()->user()->activity->toArray() +=> [ + [ + "id" => 4, + "log_name" => "default", + "description" => "User successfully logged in.", + "subject_id" => 1, + "subject_type" => "App\Models\User", + "causer_id" => 1, + "causer_type" => "App\Models\User", + "properties" => Illuminate\Support\Collection {#971 + all: [], + }, + "created_at" => "2018-02-04 03:18:50", + "updated_at" => "2018-02-04 03:18:50", + ], + [ + "id" => 5, + "log_name" => "default", + "description" => "access via terminal", + "subject_id" => 1, + "subject_type" => "App\Models\User", + "causer_id" => 1, + "causer_type" => "App\Models\User", + "properties" => Illuminate\Support\Collection {#980 + all: [], + }, + "created_at" => "2018-02-04 03:19:16", + "updated_at" => "2018-02-04 03:19:16", + ], + ] +``` + ## Test To run the test, type `vendor/bin/phpunit` in your terminal. From 7ab3c920785dec04ced2d97c68cc512f4bb7b0bd Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 11:38:43 +0800 Subject: [PATCH 18/19] Added Service Provider Test --- tests/Feature/.gitignore | 1 + tests/Feature/ServiceProviderTest.php | 50 +++++++++++++++++++++++++++ tests/Unit/.gitignore | 1 + tests/Unit/ExampleTest.php | 19 ---------- 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 tests/Feature/.gitignore create mode 100644 tests/Feature/ServiceProviderTest.php create mode 100644 tests/Unit/.gitignore delete mode 100644 tests/Unit/ExampleTest.php diff --git a/tests/Feature/.gitignore b/tests/Feature/.gitignore new file mode 100644 index 0000000..f935021 --- /dev/null +++ b/tests/Feature/.gitignore @@ -0,0 +1 @@ +!.gitignore diff --git a/tests/Feature/ServiceProviderTest.php b/tests/Feature/ServiceProviderTest.php new file mode 100644 index 0000000..16406bb --- /dev/null +++ b/tests/Feature/ServiceProviderTest.php @@ -0,0 +1,50 @@ +assertTrue(in_array($provider, $config)); + } + } + + /** @test */ + public function it_has_spatie_packages() + { + $config = config('app.providers'); + $providers = [ + \Spatie\Permission\PermissionServiceProvider::class, + \Spatie\Analytics\AnalyticsServiceProvider::class, + \Spatie\Menu\Laravel\MenuServiceProvider::class, + \Spatie\GoogleCalendar\GoogleCalendarServiceProvider::class, + \Spatie\Html\HtmlServiceProvider::class, + ]; + foreach ($providers as $provider) { + $this->assertTrue(in_array($provider, $config)); + } + } + + /** @test */ + public function it_has_other_packages() + { + $config = config('app.providers'); + $providers = [ + \UxWeb\SweetAlert\SweetAlertServiceProvider::class, + ]; + foreach ($providers as $provider) { + $this->assertTrue(in_array($provider, $config)); + } + } +} diff --git a/tests/Unit/.gitignore b/tests/Unit/.gitignore new file mode 100644 index 0000000..f935021 --- /dev/null +++ b/tests/Unit/.gitignore @@ -0,0 +1 @@ +!.gitignore diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index e9fe19c..0000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,19 +0,0 @@ -assertTrue(true); - } -} From 699b1f8b74ce8966a5247957b23ea2559ec95665 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Date: Sun, 4 Feb 2018 11:43:53 +0800 Subject: [PATCH 19/19] Call reload:db and setup database connection in test. --- tests/CreatesApplication.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index 547152f..b5c7db8 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -6,6 +6,33 @@ trait CreatesApplication { + /** + * Setup the test environment. + */ + public function setUp() + { + parent::setUp(); + + $this->artisan('reload:db'); + } + + /** + * Define environment setup. + * + * @param \Illuminate\Foundation\Application $app + * @return void + */ + protected function getEnvironmentSetUp($app) + { + // Setup default database to use sqlite :memory: + $app['config']->set('database.default', 'testbench'); + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); + } + /** * Creates the application. * @@ -13,7 +40,7 @@ trait CreatesApplication */ public function createApplication() { - $app = require __DIR__.'/../bootstrap/app.php'; + $app = require __DIR__ . '/../bootstrap/app.php'; $app->make(Kernel::class)->bootstrap();