-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 30e6f54
Showing
30 changed files
with
790 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Ignore all test and documentation with "export-ignore". | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
.github export-ignore | ||
.gitignore export-ignore | ||
.php-cs-fixer.cache export-ignore | ||
.php-cs-fixer.php export-ignore | ||
/art export-ignore | ||
/docs export-ignore | ||
/tests export-ignore | ||
UPGRADING.md export-ignore | ||
testbench.yaml export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
blank_issues_enabled: false | ||
contact_links: | ||
- name: Ask a question | ||
url: https://github.com/abordage/nova-table-card/discussions/new?category=q-a | ||
about: Ask the community for help | ||
- name: Request a feature | ||
url: https://github.com/abordage/nova-table-card/discussions/new?category=ideas | ||
about: Share ideas for new features | ||
- name: Report a bug | ||
url: https://github.com/abordage/nova-table-card/issues/new | ||
about: Report a reproducible bug | ||
- name: Report a security issue | ||
url: https://github.com/abordage/nova-table-card/security/policy | ||
about: Learn how to notify us for sensitive bugs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Please see the documentation for all configuration options: | ||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
labels: | ||
- "dependencies" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Check Links | ||
|
||
on: | ||
repository_dispatch: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "30 3 * * 1" | ||
|
||
jobs: | ||
linkChecker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Link Checker | ||
id: lychee | ||
uses: lycheeverse/lychee-action@v1.5.0 | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Create Issue From File | ||
if: steps.lychee.outputs.exit_code != 0 | ||
uses: peter-evans/create-issue-from-file@v4 | ||
with: | ||
title: Link Checker Report | ||
content-filepath: ./lychee/out.md | ||
labels: report, automated issue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Dependabot auto-merge | ||
|
||
on: pull_request_target | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
|
||
jobs: | ||
dependabot: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.actor == 'dependabot[bot]' }} | ||
steps: | ||
|
||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/fetch-metadata@v1.3.3 | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
- name: Auto-merge Dependabot PRs for semver-minor updates | ||
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} | ||
run: gh pr merge --auto --merge "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Auto-merge Dependabot PRs for semver-patch updates | ||
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} | ||
run: gh pr merge --auto --merge "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: PHP CS Fixer | ||
|
||
on: [ push ] | ||
|
||
jobs: | ||
php-cs-fixer: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Run PHP CS Fixer | ||
uses: docker://oskarstark/php-cs-fixer-ga | ||
with: | ||
args: --config=.php-cs-fixer.dist.php | ||
|
||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: fix styling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: "Update Changelog" | ||
|
||
on: | ||
release: | ||
types: [released] | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.release.target_commitish }} | ||
|
||
- name: Update Changelog | ||
uses: stefanzweifel/changelog-updater-action@v1 | ||
with: | ||
latest-version: ${{ github.event.release.tag_name }} | ||
release-notes: ${{ github.event.release.body }} | ||
|
||
- name: Commit updated CHANGELOG | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
branch: ${{ github.event.release.target_commitish }} | ||
commit_message: update CHANGELOG | ||
file_pattern: CHANGELOG.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.php-cs-fixer.cache | ||
.php-cs-fixer.php | ||
.phpunit.result.cache | ||
/.vscode | ||
/.idea | ||
/build | ||
/coverage | ||
/vendor | ||
composer.lock | ||
node_modules | ||
npm-debug.log | ||
phpstan.neon | ||
phpunit.xml | ||
testbench.yaml | ||
/package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
$finder = Symfony\Component\Finder\Finder::create() | ||
->in([ | ||
__DIR__ . '/src' | ||
]) | ||
->name('*.php') | ||
->notName('*.blade.php') | ||
->ignoreDotFiles(true) | ||
->ignoreVCS(true); | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRules([ | ||
'@PSR12' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'ordered_imports' => ['sort_algorithm' => 'alpha'], | ||
'no_unused_imports' => true, | ||
'not_operator_with_successor_space' => false, | ||
'trailing_comma_in_multiline' => false, | ||
'phpdoc_scalar' => true, | ||
'unary_operator_spaces' => true, | ||
'binary_operator_spaces' => true, | ||
'blank_line_before_statement' => [ | ||
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], | ||
], | ||
'phpdoc_single_line_var_spacing' => true, | ||
'phpdoc_var_without_name' => true, | ||
'class_attributes_separation' => [ | ||
'elements' => [ | ||
'method' => 'one', | ||
], | ||
], | ||
'method_argument_space' => [ | ||
'on_multiline' => 'ensure_fully_multiline', | ||
'keep_multiple_spaces_after_comma' => true, | ||
], | ||
'single_trait_insert_per_statement' => true, | ||
]) | ||
->setFinder($finder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Changelog | ||
|
||
All notable changes to `nova-table-card` will be documented in this file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) abordage <box@abordage.dev> | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# Nova Table Card | ||
|
||
A Laravel Nova card for displaying lists with links to view and edit. | ||
|
||
[//]: # (<p style="text-align: center;" align="center">) | ||
|
||
[//]: # (<img alt="Laravel Nova Table Card" src="https://github.com/abordage/nova-table-card/blob/master/docs/images/abordage-nova-table-card.png?raw=true">) | ||
|
||
[//]: # (</p>) | ||
|
||
[//]: # () | ||
[//]: # () | ||
[//]: # (<p style="text-align: center;" align="center">) | ||
|
||
[//]: # () | ||
[//]: # (<a href="https://packagist.org/packages/abordage/nova-table-card" title="Packagist version">) | ||
|
||
[//]: # ( <img alt="Packagist Version" src="https://img.shields.io/packagist/v/abordage/nova-table-card">) | ||
|
||
[//]: # (</a>) | ||
|
||
[//]: # () | ||
[//]: # (<a href="https://github.com/abordage/nova-table-card/actions/workflows/php-cs-fixer.yml" title="GitHub Code Style Status">) | ||
|
||
[//]: # ( <img alt="GitHub Code Style Status" src="https://img.shields.io/github/workflow/status/abordage/nova-table-card/PHP%20CS%20Fixer?label=code%20style">) | ||
|
||
[//]: # (</a>) | ||
|
||
[//]: # () | ||
[//]: # (<a href="https://nova.laravel.com/docs/4.0/" title="Laravel Nova Version">) | ||
|
||
[//]: # ( <img alt="Laravel Nova Version" src="https://img.shields.io/badge/laravel%20nova-4.0-1DA5E7">) | ||
|
||
[//]: # (</a>) | ||
|
||
[//]: # () | ||
[//]: # (<a href="https://www.php.net/" title="PHP version">) | ||
|
||
[//]: # ( <img alt="PHP Version Support" src="https://img.shields.io/packagist/php-v/abordage/nova-table-card">) | ||
|
||
[//]: # (</a>) | ||
|
||
[//]: # () | ||
[//]: # (<a href="https://github.com/abordage/nova-table-card/blob/master/LICENSE.md" title="License">) | ||
|
||
[//]: # ( <img alt="License" src="https://img.shields.io/github/license/abordage/nova-table-card">) | ||
|
||
[//]: # (</a>) | ||
|
||
[//]: # () | ||
[//]: # () | ||
[//]: # (</p>) | ||
|
||
## Requirements | ||
- PHP 7.4 or higher | ||
- Nova 4 | ||
|
||
## Installation | ||
|
||
You can install the package via composer: | ||
|
||
```bash | ||
composer require abordage/nova-table-card | ||
``` | ||
|
||
## Usage | ||
|
||
To create a cards use the `artisan` command: | ||
|
||
```bash | ||
php artisan nova-table-card MyTableCard | ||
``` | ||
By default, all new cards will be placed in the `app/Nova/Cards` directory. | ||
Once your table card class has been generated, you're ready to customize it: | ||
|
||
```php | ||
<?php | ||
|
||
namespace App\Nova\Cards; | ||
|
||
use Abordage\TableCard\TableCard; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class MyTableCard extends TableCard | ||
{ | ||
/** | ||
* Name of the card. | ||
*/ | ||
public string $title = 'My Table Card'; | ||
|
||
/** | ||
* The width of the card (1/2, 1/3, 1/4 or full). | ||
*/ | ||
public $width = '1/3'; | ||
|
||
/** | ||
* Array of table rows | ||
* | ||
* Required keys: title, viewUrl | ||
* Optional keys: subtitle, editUrl | ||
*/ | ||
public function rows(): array | ||
{ | ||
$rows = []; | ||
|
||
/** for example */ | ||
$models = \App\Models\User::limit(5)->get(); | ||
foreach ($models as $model) { | ||
$rows[] = [ | ||
'title' => $model->name, | ||
'subtitle' => $model->email, | ||
'viewUrl' => $this->getResourceUrl($model), | ||
'editUrl' => $this->getResourceUrl($model) . '/edit', | ||
]; | ||
} | ||
|
||
return $rows; | ||
} | ||
|
||
/** | ||
* @param Model $model | ||
* @return string | ||
*/ | ||
private function getResourceUrl(Model $model): string | ||
{ | ||
return config('nova.path') . '/resources/' . str_replace('_', '-', $model->getTable()) . '/' . $model->getKey(); | ||
} | ||
} | ||
``` | ||
|
||
Once you have defined a card, you are ready to attach it to a dashboard or resource. You should simply add it to the array of cards. | ||
|
||
## Feedback | ||
If you have any feedback, comments or suggestions, please feel free to open an issue within this repository. | ||
|
||
## Credits | ||
|
||
- [Pavel Bychko](https://github.com/abordage) | ||
- [All Contributors](../../contributors) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
Oops, something went wrong.