Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrijsmihailovs committed Jan 3, 2024
0 parents commit 4b501f9
Show file tree
Hide file tree
Showing 8 changed files with 335 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to `filament-json` will be documented in this file.

## 1.0.0 - 202X-XX-XX

- initial release
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Cube Agency <dmitrijs.mihailovs@cube.lv>

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.
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# JSON field for Filament

[![Latest Version on Packagist](https://img.shields.io/packagist/v/cube-agency/filament-json.svg?style=flat-square)](https://packagist.org/packages/cube-agency/filament-json)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/cube-agency/filament-json/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/cube-agency/filament-json/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/cube-agency/filament-json/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/cube-agency/filament-json/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/cube-agency/filament-json.svg?style=flat-square)](https://packagist.org/packages/cube-agency/filament-json)

Basic Filament field to save data as JSON

## Installation

You can install the package via composer:

```bash
composer require cube-agency/filament-json
```

## Usage

Add json column to your table:

```php
$table->json('meta')->nullable();
```

and add this field to your form:

```php
use CubeAgency\FilamentJson\Filament\Forms\Components\Json;

public static function form(Form $form): Form
{
return $form
->schema([
// ...
Json::make('meta')
->schema([
Grid::make()
->schema([
TextInput::make('title'),
TagsInput::make('keywords'),
]),
Grid::make()
->schema([
Textarea::make('description')
->rows(3),
FileUpload::make('image')
->image()
->imagePreviewHeight('64')
]),
]),
// ...
]);
}
```

## Testing

```bash
composer test
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Contributing

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

## Security Vulnerabilities

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

## Credits

- [Dmitrijs Mihailovs](https://github.com/dmitrijs.mihailovs)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
74 changes: 74 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "cube-agency/filament-json",
"description": "JSON field for Filament",
"keywords": [
"cube-agency",
"laravel",
"filament",
"filament-json"
],
"homepage": "https://github.com/cube-agency/filament-json",
"support": {
"issues": "https://github.com/cube-agency/filament-json/issues",
"source": "https://github.com/cube-agency/filament-json"
},
"license": "MIT",
"authors": [
{
"name": "Dmitrijs Mihailovs",
"email": "dmitrijs.mihailovs@cube.lv",
"role": "Developer"
}
],
"require": {
"php": "^8.1",
"filament/filament": "^3.0",
"spatie/laravel-package-tools": "^1.15.0",
"illuminate/contracts": "^10.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0"
},
"autoload": {
"psr-4": {
"CubeAgency\\FilamentJson\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"CubeAgency\\FilamentJson\\Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
},
"extra": {
"laravel": {
"providers": [
"CubeAgency\\FilamentJson\\FilamentJsonServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
17 changes: 17 additions & 0 deletions src/Filament/Forms/Components/Json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace CubeAgency\FilamentJson\Filament\Forms\Components;

use Filament\Forms\Components\Field;

class Json extends Field
{
protected string $view = 'filament-forms::components.fieldset';

protected function setUp(): void
{
parent::setUp();

$this->columnSpan('full');
}
}
37 changes: 37 additions & 0 deletions src/FilamentJsonPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace CubeAgency\FilamentJson;

use Filament\Contracts\Plugin;
use Filament\Panel;

class FilamentJsonPlugin implements Plugin
{
public function getId(): string
{
return 'filament-json';
}

public function register(Panel $panel): void
{
//
}

public function boot(Panel $panel): void
{
//
}

public static function make(): static
{
return app(static::class);
}

public static function get(): static
{
/** @var static $plugin */
$plugin = filament(app(static::class)->getId());

return $plugin;
}
}
36 changes: 36 additions & 0 deletions src/FilamentJsonServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace CubeAgency\FilamentJson;

use Spatie\LaravelPackageTools\Commands\InstallCommand;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class FilamentJsonServiceProvider extends PackageServiceProvider
{
public static string $name = 'filament-json';

public static string $viewNamespace = 'filament-json';

public function configurePackage(Package $package): void
{
/*
* This class is a Package Service Provider
*
* More info: https://github.com/spatie/laravel-package-tools
*/
$package->name(static::$name)
->hasInstallCommand(function (InstallCommand $command) {
$command
->askToStarRepoOnGitHub('cube-agency/filament-json');
});
}

public function packageRegistered(): void
{
}

public function packageBooted(): void
{
}
}

0 comments on commit 4b501f9

Please sign in to comment.