Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 4 hours 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 (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-13T05:52:16.000Z (almost 2 years ago)
- Last Synced: 2024-09-23T16:31:08.297Z (1 day ago)
- Topics: laravel, laravel-nova, laravel-nova-field, laravel8, nova, php
- Language: PHP
- Homepage: https://twitter.com/M7ammed_Ashraf
- Size: 104 KB
- Stars: 33
- Watchers: 3
- 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
[![GitHub license](https://img.shields.io/github/license/MohmmedAshraf/nova-hidden-field.svg)](https://github.com/MohmmedAshraf/nova-hidden-field/blob/master/LICENSE.md)
[![GitHub issues](https://img.shields.io/github/issues/MohmmedAshraf/nova-hidden-field.svg)](https://github.com/MohmmedAshraf/nova-hidden-field/issues)
[![Total Downloads](https://poser.pugx.org/outhebox/nova-hidden-field/downloads)](https://packagist.org/packages/outhebox/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')
->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.