Skip to content

Commit 7cf9749

Browse files
committed
Further updates
1 parent 7646598 commit 7cf9749

21 files changed

+521
-109
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Eloquent Encryptable
3+
description: Eases using and generating slugs Laravel Eloquent models.
4+
type: library
5+
platform: Laravel
6+
github: https://github.com/kduma-OSS/LV-eloquent-encryptable
7+
---
8+
9+
::u-button-group
10+
:u-button[GitHub Repository]{icon="bxl:github" href="https://github.com/kduma-OSS/LV-eloquent-encryptable" blank}
11+
12+
:u-button[Releases]{icon="material-symbols:cloud-download" href="https://github.com/kduma-OSS/LV-eloquent-encryptable/releases/latest/" blank}
13+
14+
:u-button[Packagist]{icon="simple-icons:packagist" href="https://packagist.org/packages/kduma/eloquent-encryptable" blank}
15+
::
16+
17+
## Setup
18+
Add the package to the require section of your composer.json and run `composer update`
19+
20+
"kduma/eloquent-encryptable": "^1.1"
21+
22+
## Prepare models
23+
In your model add following lines:
24+
25+
use \KDuma\Eloquent\Encryptable;
26+
protected $encrypted=['list', 'of', 'fields', 'you', 'wan\'t', 'to', 'encrypt'];
27+
28+
## Usage
29+
30+
It will be automatically encrypting and decrypting fields defined in `$encrypted` property of your model.
31+
32+
Those fields must be `string` or `text` for longer values.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Eloquent Sluggable
3+
description: Eases using and generating slugs Laravel Eloquent models.
4+
type: library
5+
platform: Laravel
6+
github: https://github.com/kduma-OSS/LV-eloquent-sluggable
7+
---
8+
9+
::u-button-group
10+
:u-button[GitHub Repository]{icon="bxl:github" href="https://github.com/kduma-OSS/LV-eloquent-sluggable" blank}
11+
12+
:u-button[Releases]{icon="material-symbols:cloud-download" href="https://github.com/kduma-OSS/LV-eloquent-sluggable/releases/latest/" blank}
13+
14+
:u-button[Packagist]{icon="simple-icons:packagist" href="https://packagist.org/packages/kduma/eloquent-sluggable" blank}
15+
::
16+
17+
## Setup
18+
Add the package to the require section of your composer.json and run `composer update`
19+
20+
"kduma/eloquent-sluggable": "^1.1"
21+
22+
## Prepare models
23+
Inside your model (not on top of file) add following lines:
24+
25+
use \KDuma\Eloquent\Slugabble;
26+
27+
Optionally you can add also `SluggableString` function which will return string from which slug will be made (default it uses `title` field):
28+
29+
protected function SluggableString(){
30+
return $this->year.' '.$this->title;
31+
}
32+
33+
In database create `slug` string field. If you use migrations, you can use following snippet:
34+
35+
$table->string('slug')->unique();
36+
37+
## Usage
38+
By default it generates slug on first save.
39+
40+
- `$model->newSlug()` - Generate new slug. (Remember to save it by yourself)
41+
- `Model::whereSlug($slug)->first()` - Find by slug. (`whereSlug` is query scope)

content/3.libraries/100.php/eloquent-tokenable.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ github: https://github.com/kduma-OSS/LV-eloquent-tokenable
1414
:u-button[Packagist]{icon="simple-icons:packagist" href="https://packagist.org/packages/kduma/eloquent-tokenable" blank}
1515
::
1616

17-
# Setup
17+
## Setup
1818
Add the package to the require section of your composer.json and run `composer update`
1919

2020
"kduma/eloquent-tokenable": "^1.1"
2121

22-
# Prepare models
22+
## Prepare models
2323
In your model add following lines:
2424

2525
use \KDuma\Eloquent\Tokenable;
@@ -36,6 +36,6 @@ Optionally you can add also:
3636
- `protected $alphabet = 'qwertyuiopasdfghjklzxcvbnm1234567890';`
3737
A hash alphabet. Default is `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`
3838

39-
# Usage
39+
## Usage
4040
- `$model->token` - Generate tokens
4141
- `Model::whereToken($id)->first()` - Find by token. (`whereToken` is query scope)

content/3.libraries/100.php/eloquent-ulidable.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ github: https://github.com/kduma-OSS/LV-eloquent-ulidable
1414
:u-button[Packagist]{icon="simple-icons:packagist" href="https://packagist.org/packages/kduma/eloquent-ulidable" blank}
1515
::
1616

17-
# Setup
17+
## Setup
1818
Install it using composer
1919

2020
composer require kduma/eloquent-ulidable
2121

22-
# Prepare models
22+
## Prepare models
2323
Inside your model (not on top of file) add following lines:
2424

2525
use \KDuma\Eloquent\Ulidable;
@@ -28,7 +28,7 @@ In database create `ulid` string field. If you use migrations, you can use follo
2828

2929
$table->ulid()->unique();
3030

31-
# Usage
31+
## Usage
3232
By default, it generates slug on first save.
3333

3434
- `$model->regenerateUlid()` - Generate new ulid. (Remember to save it by yourself)

content/3.libraries/100.php/eloquent-uuidable.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ github: https://github.com/kduma-OSS/LV-eloquent-uuidable
1414
:u-button[Packagist]{icon="simple-icons:packagist" href="https://packagist.org/packages/kduma/eloquent-uuidable" blank}
1515
::
1616

17-
# Setup
17+
## Setup
1818
Install it using composer
1919

2020
composer require kduma/eloquent-uuidable
2121

22-
# Prepare models
22+
## Prepare models
2323
Inside your model (not on top of file) add following lines:
2424

2525
use \KDuma\Eloquent\Uuidable;
@@ -28,13 +28,13 @@ In database create `uuid` string field. If you use migrations, you can use follo
2828

2929
$table->uuid('uuid')->unique();
3030

31-
# Usage
31+
## Usage
3232
By default it generates slug on first save.
3333

3434
- `$model->regenerateUuid()` - Generate new uuid. (Remember to save it by yourself)
3535
- `Model::whereUuid($uuid)->first()` - Find by guid. (`whereUuid` is query scope)
3636

37-
# Upgrade from 1.x/2.x version of `kduma/eloquent-guidable`
37+
## Upgrade from 1.x/2.x version of `kduma/eloquent-guidable`
3838

3939
Add following line to yours models to switch from using `uuid` column name to `guid` as it was used in previous versions:
4040

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
navigation:
3+
title: File Hasher.PHP
4+
title: File Hasher (PHP)
5+
description: MD5 and SHA1 file hash calculator and checker library
6+
type: library
7+
platform: PHP
8+
active: true
9+
---
10+
11+
::u-button-group
12+
:u-button[GitHub Repository]{icon="bxl:github" href="https://github.com/kduma-OSS/PHP-file-hasher" blank}
13+
14+
:u-button[Releases]{icon="material-symbols:cloud-download" href="https://github.com/kduma-OSS/PHP-file-hasher/releases/latest/" blank}
15+
16+
:u-button[Packagist]{icon="simple-icons:packagist" href="https://packagist.org/packages/kduma/file-hasher" blank}
17+
::
18+
19+
## Install
20+
21+
Via Composer
22+
23+
``` bash
24+
$ composer require kduma/file-hasher
25+
```
26+
27+
## Usage
28+
29+
``` php
30+
use KDuma\FileHasher\Checker;
31+
use KDuma\FileHasher\Hasher;
32+
33+
var_dump(Hasher::file('test.php'));
34+
var_dump(Checker::file('test.php.ph'));
35+
```
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: Content Negotiable Responses for Laravel
3+
description: This package makes it easy to aautomaticallly negotiate content based on the client's Accept header.
4+
type: library
5+
platform: Laravel
6+
github: https://github.com/kduma-OSS/LV-content-negotiable-responses
7+
---
8+
9+
::u-button-group
10+
:u-button[GitHub Repository]{icon="bxl:github" href="https://github.com/kduma-OSS/LV-content-negotiable-responses" blank}
11+
12+
:u-button[Releases]{icon="material-symbols:cloud-download" href="https://github.com/kduma-OSS/LV-content-negotiable-responses/releases/latest/" blank}
13+
14+
:u-button[Packagist]{icon="simple-icons:packagist" href="https://packagist.org/packages/kduma/content-negotiable-responses" blank}
15+
::
16+
17+
## Installation
18+
19+
```bash
20+
composer require kduma/content-negotiable-responses
21+
```
22+
23+
## Content Formats (for `ArrayResponse` and `BasicViewResponse`)
24+
25+
Currently supported formats are:
26+
- `text/plain` (disabled by default, to enable it in your custom class implement `TextResponseInterface`) - resulting response will be output of built-in PHP function `print_r`
27+
- `application/json` - resulting response will be output of built-in PHP function `json_encode`
28+
- `application/yaml` - resulting response will be generated using [symfony/yaml](https://packagist.org/packages/symfony/yaml) package
29+
- `application/xml` - resulting response will be generated using [spatie/array-to-xml](https://packagist.org/packages/spatie/array-to-xml) package
30+
- `application/msgpack` - resulting response will be generated using [rybakit/msgpack](https://packagist.org/packages/rybakit/msgpack) package
31+
- `text/html` (only for `BasicViewResponse`) - resulting response will be generated using view provided to constructor with passed data array
32+
33+
## Usage
34+
35+
### Basic Array Usage (for API responses)
36+
37+
```php
38+
Route::get('/test', function () {
39+
return new \KDuma\ContentNegotiableResponses\ArrayResponse([
40+
'success' => true,
41+
'timestamp' => time(),
42+
]);
43+
});
44+
```
45+
As the result, response will be formatted accordingly to acceptable formats passed in `Accept` HTTP header or as JSON if not specified.
46+
47+
### Basic View Usage (for Web and API responses)
48+
49+
```php
50+
Route::get('/', function () {
51+
return new \KDuma\ContentNegotiableResponses\BasicViewResponse('welcome', [
52+
'success' => true,
53+
'timestamp' => time(),
54+
]);
55+
});
56+
```
57+
58+
### Customized Usage
59+
60+
```php
61+
namespace App\Http\Responses;
62+
63+
use KDuma\ContentNegotiableResponses\BaseViewResponse;
64+
use Illuminate\Database\Eloquent\Collection;
65+
use Illuminate\Http\Request;
66+
67+
class UsersListResponse extends BaseViewResponse
68+
{
69+
public $users;
70+
71+
public function __construct(Collection $users)
72+
{
73+
$this->users = $users;
74+
}
75+
76+
protected function generateView(Request $request)
77+
{
78+
return $this->view('users.list');
79+
}
80+
}
81+
82+
Route::get('/users', function () {
83+
return new \App\Http\Responses\UsersListResponse(\App\User::all());
84+
});
85+
```
86+
87+
As the result, when opening in web browser, there will be rendered `users.list` view with passed all public properties to it.
88+
In non HTML clients (specyfing other `Accept` headers) will get serialized public properties (in any supported format), for example:
89+
90+
```json
91+
{
92+
"users": [
93+
{
94+
"name": "user 1",
95+
"email": "user1@localhost"
96+
},
97+
{
98+
"name": "user 2",
99+
"email": "user2@localhost"
100+
},
101+
{
102+
"name": "user 3",
103+
"email": "user3@localhost"
104+
}
105+
]
106+
}
107+
```
108+
109+
If you want to customize serialized array, you need to override `getDataArray` method:
110+
111+
```php
112+
/**
113+
* @return array
114+
*/
115+
protected function getDataArray() {
116+
return [
117+
'my_super_users_collection' => $this->users->toArray(),
118+
'hello' => true
119+
];
120+
}
121+
```
122+
123+
Then the result will be:
124+
125+
```json
126+
{
127+
"my_super_users_collection": [
128+
{
129+
"name": "user 1",
130+
"email": "user1@localhost"
131+
},
132+
{
133+
"name": "user 2",
134+
"email": "user2@localhost"
135+
},
136+
{
137+
"name": "user 3",
138+
"email": "user3@localhost"
139+
}
140+
],
141+
"hello": true
142+
}
143+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: Polish Validator Rules for Laravel
3+
description: Polish Validation rules for Laravel Validator
4+
type: library
5+
platform: Laravel
6+
github: https://github.com/kduma-OSS/LV-polish-validator-rules
7+
---
8+
9+
::u-button-group
10+
:u-button[GitHub Repository]{icon="bxl:github" href="https://github.com/kduma-OSS/LV-polish-validator-rules" blank}
11+
12+
:u-button[Releases]{icon="material-symbols:cloud-download" href="https://github.com/kduma-OSS/LV-polish-validator-rules/releases/latest/" blank}
13+
14+
:u-button[Packagist]{icon="simple-icons:packagist" href="https://packagist.org/packages/kduma/polish-validator" blank}
15+
::
16+
17+
## Setup
18+
19+
You can install the package via composer:
20+
21+
composer require kduma/polish-validator
22+
23+
If you are using Laravel 5.5, the service provider will automatically be discovered.
24+
25+
On earlier versions, you need to do that manually. You must add the Service Provider to the providers array in `config/app.php`:
26+
27+
KDuma\Validator\PolishValidatorRulesServiceProvider::class,
28+
29+
30+
## Usage
31+
You have 2 new Validator rules:
32+
33+
- `pesel` or `\KDuma\Validator\PeselNumberRule()` - Checks if number is valid PESEL number
34+
- `identity_card` or `\KDuma\Validator\PolishIdentityCardNumberRule()` - Checks if number is polish identity document number

0 commit comments

Comments
 (0)