Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MohmmedAshraf committed Nov 12, 2018
0 parents commit d90e6cc
Show file tree
Hide file tree
Showing 14 changed files with 10,871 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/.idea
/vendor
/node_modules
package-lock.json
composer.phar
composer.lock
phpunit.xml
.phpunit.result.cache
.DS_Store
Thumbs.db
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) Four Stacks Ltd

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.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Laravel Nova Hidden Field

## Description
This field give the ability to add a hidden fields to your resources.

## Requrements
* Laravel 5.7+ with [Nova](https://nova.laravel.com).

## Installation
This package can be installed through Composer.
```bash
composer require outhebox/nova-hidden-field
```

## Example Usage
Add the field to your resource in the ```fields``` method:
```php
use Outhebox\NovaHiddenField\HiddenField;

HiddenField::make('User', 'user_id')
->current_user_id(),
```

Also you can override the default value:
```php
use Outhebox\NovaHiddenField\HiddenField;

HiddenField::make('User', 'column_name')
->default($this->get_client_id()),

/**
* Function will return your value
* the returned value should be string
*
* @return string
*/
public function get_client_id()
{
$client = Client::find(1)->first();
return $client->id;
}
```

Another option you may like if you want to use the relationship fields:
```php
use Laravel\Nova\Fields\BelongsTo;
use Outhebox\NovaHiddenField\HiddenField;

HiddenField::make('User', 'user_id')
->hideFromIndex(),
->hideFromDetail(),
->current_user_id()

BelongsTo::make('User')
->hideWhenCreating(),
->hideWhenUpdating(),
```

## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
39 changes: 39 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "outhebox/nova-hidden-field",
"description": "A Laravel Nova Hidden field.",
"keywords": [
"laravel",
"nova",
"field",
"nova default value",
"nova hidden field"
],
"license": "MIT",
"authors": [
{
"name": "Mohamed Ashraf",
"email": "[email protected]",
"role": "Developer"
}
],
"require": {
"php": ">=7.1.0"
},
"autoload": {
"psr-4": {
"Outhebox\\NovaHiddenField\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Outhebox\\NovaHiddenField\\FieldServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Loading

0 comments on commit d90e6cc

Please sign in to comment.