https://github.com/mohmmedashraf/nova-hidden-field
A Laravel Nova Hidden field.
https://github.com/mohmmedashraf/nova-hidden-field
laravel laravel-nova laravel-nova-field laravel8 nova php
Last synced: 3 months ago
JSON representation
A Laravel Nova Hidden field.
- Host: GitHub
- URL: https://github.com/mohmmedashraf/nova-hidden-field
- Owner: MohmmedAshraf
- License: mit
- Created: 2018-11-12T20:08:13.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-14T11:42:19.000Z (9 months ago)
- Last Synced: 2025-03-29T10:09:09.941Z (4 months ago)
- Topics: laravel, laravel-nova, laravel-nova-field, laravel8, nova, php
- Language: PHP
- Homepage: https://twitter.com/M7ammed_Ashraf
- Size: 108 KB
- Stars: 34
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Nova Hidden Field
[](https://github.com/MohmmedAshraf/nova-hidden-field/blob/master/LICENSE.md)
[](https://github.com/MohmmedAshraf/nova-hidden-field/issues)
[](https://packagist.org/packages/outhebox/nova-hidden-field)## Description
This field give the ability to add a hidden fields to your resources.## Support
[
](https://outhebox.dev/github-ad-click/nova-hidden-field).
Thank you for considering supporting the development of this package! If you'd like to contribute, you can buy me a coffee or sponsor me to help keep me motivated to continue improving this package. You can also support the project by starring ⭐ the repository.
To buy me a coffee, click the button below:
## 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')
->defaultValue($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.## Donate
If you like this package, you can show your appreciation 💜 by [donating any amount via Patreon](https://www.patreon.com/m_ashraf) to support ongoing development.