Skip to content

Commit 650cfd4

Browse files
committed
first commit
0 parents  commit 650cfd4

File tree

19 files changed

+506
-0
lines changed

19 files changed

+506
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
indent_style = space
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml,js,scss,css}]
15+
indent_size = 2

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.github export-ignore
2+
/.editorconfig export-ignore
3+
/.gitattributes export-ignore
4+
/.gitignore export-ignore
5+
/phpcs.xml export-ignore

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Please see the documentation for all configuration options:
2+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
11+
labels:
12+
- "dependencies"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: dependabot-auto-merge
2+
on: pull_request_target
3+
4+
permissions:
5+
pull-requests: write
6+
contents: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
12+
steps:
13+
14+
- name: Dependabot metadata
15+
id: metadata
16+
uses: dependabot/[email protected]
17+
with:
18+
github-token: "${{ secrets.GITHUB_TOKEN }}"
19+
20+
- name: Auto-merge Dependabot PRs for semver-minor updates
21+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
22+
run: gh pr merge --auto --merge "$PR_URL"
23+
env:
24+
PR_URL: ${{github.event.pull_request.html_url}}
25+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
26+
27+
- name: Auto-merge Dependabot PRs for semver-patch updates
28+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
29+
run: gh pr merge --auto --merge "$PR_URL"
30+
env:
31+
PR_URL: ${{github.event.pull_request.html_url}}
32+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Update Changelog"
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
update:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
with:
15+
ref: main
16+
17+
- name: Update Changelog
18+
uses: stefanzweifel/changelog-updater-action@v1
19+
with:
20+
latest-version: ${{ github.event.release.name }}
21+
release-notes: ${{ github.event.release.body }}
22+
23+
- name: Commit updated CHANGELOG
24+
uses: stefanzweifel/git-auto-commit-action@v4
25+
with:
26+
branch: main
27+
commit_message: Update CHANGELOG
28+
file_pattern: CHANGELOG.md

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea
2+
.php_cs
3+
.php_cs.cache
4+
.php-cs-fixer.cache
5+
composer.lock
6+
vendor

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
All notable changes to will be documented in this file.

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 runthis
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Laravel Media
2+
3+
A tiny laravel package to conveniently handle single file media uploads with little configuration.
4+
5+
6+
7+
## Installation
8+
9+
composer require runthis/laravel-media
10+
11+
12+
13+
## Usage
14+
15+
Add to the file you want to process uploads in, such as a controller.
16+
17+
use Runthis\Media\Facades\Media;
18+
use Runthis\Media\Requests\MediaRequest;
19+
20+
21+
Include the `MediaRequest` class in the function parameter and execute the `create` method on the `Media` facade.
22+
23+
Example:
24+
25+
public function upload(MediaRequest $request) {
26+
$test = Media::create($request);
27+
dd($test);
28+
}
29+
30+
Inside the `dd()` you can see the complete object details and process these as you see fit (such as keeping track of these uploads in a database if you like).
31+
32+
Within the object results is a `size` key. You can simply echo this out to get the bytes, or you can add `->pretty()` to get a prettier output.
33+
You can also pass a string parameter to the `pretty()` method.
34+
35+
Options:
36+
37+
l: lowercase suffix (12.45 mb instead of 12.45 MB)
38+
s: spacing omitted (12.45MB instead of 12.45 MB)
39+
b: Ending "B" removed (12.45 M instead of 12.45 MB)
40+
41+
Examples:
42+
43+
$test->size->pretty('sb'); // 12.45M
44+
$test->size->pretty('ls'); // 12.45m
45+
$test->size->pretty('l'); // 12.45 mb
46+
$test->size->pretty('bl'); // 12.45 m
47+
48+
49+
*The `Media::create` method expects a file with the key named file.*
50+
51+
52+
53+
## Publish Config
54+
55+
If you want, run the below command to add a media.php file to your config folder.
56+
57+
php artisan vendor:publish --tag="media-config"
58+
59+
From the media config file you can change the storage disk name and the rules for the media (such as file types, size limit, etc).
60+
61+
62+
63+
## Changelog
64+
65+
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
66+

composer.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "runthis/laravel-media",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"description": "Handle media in laravel packages",
6+
"keywords": [
7+
"laravel",
8+
"media"
9+
],
10+
"homepage": "https://github.com/runthis/laravel-media",
11+
"authors": [
12+
{
13+
"name": "runthis"
14+
}
15+
],
16+
"require": {
17+
"php": "^8.0",
18+
"guzzlehttp/guzzle": "^7.4",
19+
"illuminate/contracts": "^9.0",
20+
"illuminate/http": "^9.9",
21+
"illuminate/support": "^9.9",
22+
"spatie/laravel-package-tools": "^1.9.2"
23+
},
24+
"require-dev": {
25+
"nunomaduro/collision": "^6.0",
26+
"orchestra/testbench": "^7.0",
27+
"spatie/laravel-ray": "^1.26",
28+
"squizlabs/php_codesniffer": "^3.6"
29+
},
30+
"autoload": {
31+
"psr-4": {
32+
"Runthis\\Media\\": "src"
33+
}
34+
},
35+
"config": {
36+
"sort-packages": true
37+
},
38+
"extra": {
39+
"laravel": {
40+
"providers": [
41+
"Runthis\\Media\\MediaServiceProvider"
42+
],
43+
"aliases": {
44+
"Media": "Runthis\\Media\\Facades\\Media"
45+
}
46+
}
47+
},
48+
"minimum-stability": "dev",
49+
"prefer-stable": true
50+
}

0 commit comments

Comments
 (0)