Skip to content

Commit c4916bf

Browse files
committed
Add project
1 parent b6a94ed commit c4916bf

31 files changed

+1796
-0
lines changed

.codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
comment: off

.editorconfig

Lines changed: 766 additions & 0 deletions
Large diffs are not rendered by default.

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
* text=auto
2+
3+
.github/ export-ignore
4+
tests/ export-ignore
5+
6+
.codecov.yml export-ignore
7+
.editorconfig export-ignore
8+
.gitattributes export-ignore
9+
.gitignore export-ignore
10+
.scrutinizer.yml export-ignore
11+
.styleci.yml export-ignore
12+
13+
phpunit.xml export-ignore

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.idea/
2+
3+
build/
4+
node_modules/
5+
vendor/
6+
7+
*.bak
8+
*.cache
9+
*.clover
10+
*.orig
11+
12+
*.lock
13+
14+
mix-manifest.json
15+
16+
resources/apps/
17+
.vscode/settings.json

.styleci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
preset: psr12
2+
3+
risky: true
4+
5+
enabled:
6+
- align_double_arrow
7+
- align_equals
8+
- align_phpdoc
9+
- alpha_ordered_imports
10+
- binary_operator_spaces
11+
- blank_line_before_continue
12+
- blank_line_before_declare
13+
- blank_line_before_return
14+
- blank_line_before_throw
15+
- blank_line_before_try
16+
- cast_spaces
17+
- combine_consecutive_issets
18+
- const_separation
19+
- dir_constant
20+
- fully_qualified_strict_types
21+
- logical_operators
22+
- method_separation
23+
- no_alias_functions
24+
- no_blank_lines_after_phpdoc
25+
- no_blank_lines_between_traits
26+
- no_empty_comment
27+
- no_empty_phpdoc
28+
- no_extra_block_blank_lines
29+
- no_extra_consecutive_blank_lines
30+
- no_short_bool_cast
31+
- no_trailing_comma_in_singleline_array
32+
- no_unneeded_control_parentheses
33+
- no_unused_imports
34+
- ordered_class_elements
35+
- php_unit_construct
36+
- php_unit_fqcn_annotation
37+
- phpdoc_indent
38+
- phpdoc_inline_tag
39+
- phpdoc_link_to_see
40+
- phpdoc_no_access
41+
- phpdoc_no_empty_return
42+
- phpdoc_no_package
43+
- phpdoc_no_useless_inheritdoc
44+
- phpdoc_order
45+
- phpdoc_property
46+
- phpdoc_return_self_reference
47+
- phpdoc_scalar
48+
- phpdoc_separation
49+
- phpdoc_summary
50+
- phpdoc_to_comment
51+
- phpdoc_trim
52+
- phpdoc_type_to_var
53+
- phpdoc_types
54+
- phpdoc_types_order
55+
- phpdoc_var_without_name
56+
- property_separation
57+
- self_accessor
58+
- short_array_syntax
59+
- short_list_syntax
60+
- single_line_class_definition
61+
- single_line_throw
62+
- single_quote
63+
- space_after_semicolon
64+
- standardize_not_equals
65+
- ternary_to_null_coalescing
66+
- trailing_comma_in_multiline_array
67+
- trim_array_spaces

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Readable Numbers
2+
3+
[![EgoistDeveloper Readable Numbers](https://preview.dragon-code.pro/EgoistDeveloper/Readable-Numbers.svg?brand=laravel)](https://github.com/laravel-ready/readable-numbers)
4+
5+
[![Stable Version][badge_stable]][link_packagist]
6+
[![Unstable Version][badge_unstable]][link_packagist]
7+
[![Total Downloads][badge_downloads]][link_packagist]
8+
[![License][badge_license]][link_license]
9+
10+
Human readable numbers for Laravel. In some cases, you may need to format numbers in a way that is easier to read. Especially when you are dealing with numbers that are very large, for example we want to show page views and we have `100000000` views. So we can show it in the `100M` format.
11+
12+
## Installation
13+
14+
```bash
15+
composer require laravel-ready/readable-numbers
16+
```
17+
18+
## Thresholds
19+
20+
| Threshold | Suffix | Result |
21+
| ------------------ | ----------- | ------ |
22+
| 900 | | 900 |
23+
| 900.000 | k | 0.9 K |
24+
| 900.000.000 | m | 0.9 M |
25+
| 900.000.000.000 | b | 9 T |
26+
| 90.000.000.000.000 | t | 900 T |
27+
28+
## Usages
29+
30+
`make` method takes 3 aguments: `make(float $value, int $decimals = 1, $lang = null)`
31+
32+
33+
### Service Example
34+
35+
```php
36+
37+
use LaravelReady\ReadableNumbers\Services\ReadableNumbers;
38+
39+
...
40+
41+
$readableNumber = ReadableNumbers::make(123456789); // 123.5 M
42+
$readableNumber = ReadableNumbers::make(-123456789); // -123.5 M
43+
44+
// with more decimals
45+
$readableNumber = ReadableNumbers::make(123456789, 2); // 123.46 M
46+
47+
// with target language (default is english)
48+
$readableNumber = ReadableNumbers::make(123456789, 2, 'tr'); // 123.46 Mn
49+
$readableNumber = ReadableNumbers::make(123456789, 3, 'ja'); // 123.457 億
50+
$readableNumber = ReadableNumbers::make(123456789, 4, 'de'); // 123.4568 Mio.
51+
52+
```
53+
54+
### Directive Example
55+
56+
There is only one directive: `@readableNumber()`, again takes three arguments: `@readableNumber(float $value, int $decimals = 1, $lang = null)` and all arguments are required. If you use a multi-language system, you should remember to directives are cached. So, you should pass decimal count and language.
57+
58+
59+
```html
60+
61+
...
62+
63+
<span>
64+
@readableNumber(123456789, 1, app()->getLocale())
65+
</span>
66+
67+
...
68+
69+
<span class="view-counter">
70+
<i class="icon icon-eye"></i>
71+
72+
Viewed @readableNumber($blogPost->views, 1, app()->getLocale()) times
73+
</span>
74+
75+
```
76+
77+
## Languages
78+
79+
Supported languages are listed [here](lang/) and reference are used in [unicode.org](https://www.unicode.org/cldr/cldr-aux/charts/28/verify/numbers/). If you want to add your own language and send PR.
80+
81+
Don't forget to these shortings are depends on a mathematical view.
82+
83+
84+
[badge_downloads]: https://img.shields.io/packagist/dt/laravel-ready/readable-numbers.svg?style=flat-square
85+
86+
[badge_license]: https://img.shields.io/packagist/l/laravel-ready/readable-numbers.svg?style=flat-square
87+
88+
[badge_stable]: https://img.shields.io/github/v/release/laravel-ready/readable-numbers?label=stable&style=flat-square
89+
90+
[badge_unstable]: https://img.shields.io/badge/unstable-dev--main-orange?style=flat-square
91+
92+
[link_license]: LICENSE
93+
94+
[link_packagist]: https://packagist.org/packages/laravel-ready/readable-numbers
95+

composer.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "laravel-ready/readable-numbers",
3+
"description": "Human readable numbers for Laravel",
4+
"type": "library",
5+
"license": "MIT",
6+
"version": "1.0.0",
7+
"keywords": [
8+
"laravel",
9+
"readable numbers",
10+
"human readable numbers"
11+
],
12+
"authors": [
13+
{
14+
"name": "EgoistDeveloper",
15+
"email": "[email protected]"
16+
}
17+
],
18+
"support": {
19+
"issues": "https://github.com/laravel-ready/theme-store/issues",
20+
"source": "https://github.com/laravel-ready/theme-store"
21+
},
22+
"require": {
23+
"php": "^8.0.2",
24+
"illuminate/support": "^9.0"
25+
},
26+
"require-dev": {
27+
"mockery/mockery": "^1.4",
28+
"orchestra/testbench": "^7.0.0",
29+
"phpunit/phpunit": "^9.5"
30+
},
31+
"autoload": {
32+
"psr-4": {
33+
"LaravelReady\\ReadableNumbers\\": "src/"
34+
}
35+
},
36+
"autoload-dev": {
37+
"psr-4": {
38+
"Tests\\": "tests"
39+
}
40+
},
41+
"config": {
42+
"preferred-install": "dist",
43+
"sort-packages": true
44+
},
45+
"extra": {
46+
"laravel": {
47+
"providers": [
48+
"LaravelReady\\ReadableNumbers\\ReadableNumbersServiceProvider"
49+
],
50+
"aliases": {
51+
"ReadableNumbers": "LaravelReady\\ReadableNumbers\\Facades\\ReadableNumbers"
52+
}
53+
}
54+
},
55+
"minimum-stability": "stable",
56+
"prefer-stable": true
57+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Config;
4+
use Illuminate\Support\Facades\Schema;
5+
use Illuminate\Database\Schema\Blueprint;
6+
use Illuminate\Database\Migrations\Migration;
7+
8+
class CreateTsThemesTable extends Migration
9+
{
10+
public function __construct()
11+
{
12+
$this->prefix = Config::get('theme-store.default_table_prefix', 'ts_');
13+
14+
$this->table = "{$this->prefix}_themes";
15+
}
16+
17+
/**
18+
* Run the migrations.
19+
*
20+
* @return void
21+
*/
22+
public function up()
23+
{
24+
if (!Schema::hasTable($this->table)) {
25+
Schema::create($this->table, function (Blueprint $table) {
26+
$table->bigIncrements('id');
27+
28+
$table->string('name', 50);
29+
$table->string('slug', 50)->unique();
30+
$table->text('description');
31+
$table->string('vendor', 50);
32+
$table->string('group', 50);
33+
$table->boolean('status')->default(true);
34+
$table->string('cover', 50)->nullable();
35+
$table->boolean('featured')->default(false);
36+
37+
$table->unique(['slug', 'vendor', 'group']);
38+
39+
$table->softDeletes();
40+
$table->timestamps();
41+
});
42+
}
43+
}
44+
45+
/**
46+
* Reverse the migrations.
47+
*
48+
* @return void
49+
*/
50+
public function down()
51+
{
52+
if (Schema::hasTable($this->table)) {
53+
Schema::table($this->table, function (Blueprint $table) {
54+
$table->dropUnique(['slug', 'vendor', 'group']);
55+
56+
$table->dropIfExists();
57+
});
58+
}
59+
}
60+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Config;
4+
use Illuminate\Support\Facades\Schema;
5+
use Illuminate\Database\Schema\Blueprint;
6+
use Illuminate\Database\Migrations\Migration;
7+
8+
class CreateTsAuthorsTable extends Migration
9+
{
10+
public function __construct()
11+
{
12+
$this->prefix = Config::get('theme-store.default_table_prefix', 'ts_');
13+
14+
$this->table = "{$this->prefix}_authors";
15+
}
16+
17+
/**
18+
* Run the migrations.
19+
*
20+
* @return void
21+
*/
22+
public function up()
23+
{
24+
if (!Schema::hasTable($this->table)) {
25+
Schema::create($this->table, function (Blueprint $table) {
26+
$table->bigIncrements('id');
27+
28+
$table->string('name', 50);
29+
$table->string('slug', 50);
30+
$table->string('contact', 50);
31+
$table->string('avatar', 50)->nullable();
32+
$table->boolean('featured')->default(false);
33+
34+
$table->softDeletes();
35+
$table->timestamps();
36+
37+
$table->unique(['name', 'contact']);
38+
});
39+
}
40+
}
41+
42+
/**
43+
* Reverse the migrations.
44+
*
45+
* @return void
46+
*/
47+
public function down()
48+
{
49+
if (Schema::hasTable($this->table)) {
50+
Schema::table($this->table, function (Blueprint $table) {
51+
$table->dropIfExists();
52+
});
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)