├── .gitignore ├── composer.json ├── readme.md ├── license.md └── src └── FieldServiceProvider.php /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /vendor 3 | /node_modules 4 | package-lock.json 5 | composer.phar 6 | composer.lock 7 | phpunit.xml 8 | .phpunit.result.cache 9 | .DS_Store 10 | Thumbs.db 11 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dillingham/nova-index-textarea", 3 | "description": "Extends Nova textarea for index view", 4 | "keywords": [ 5 | "laravel", 6 | "nova" 7 | ], 8 | "license": "MIT", 9 | "require": { 10 | "php": ">=7.1.0" 11 | }, 12 | "autoload": { 13 | "psr-4": { 14 | "Dillingham\\NovaTextarea\\": "src/" 15 | } 16 | }, 17 | "extra": { 18 | "laravel": { 19 | "providers": [ 20 | "Dillingham\\NovaTextarea\\FieldServiceProvider" 21 | ] 22 | } 23 | }, 24 | "config": { 25 | "sort-packages": true 26 | }, 27 | "minimum-stability": "dev", 28 | "prefer-stable": true 29 | } 30 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Nova Index Textarea 2 | 3 | [![Latest Version on Github](https://img.shields.io/github/release/dillingham/nova-index-textarea.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-index-textarea) 4 | [![Total Downloads](https://img.shields.io/packagist/dt/dillingham/nova-index-textarea.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-index-textarea) [![Twitter Follow](https://img.shields.io/twitter/follow/im_brian_d?color=%231da1f1&label=Twitter&logo=%231da1f1&logoColor=%231da1f1&style=flat-square)](https://twitter.com/im_brian_d) 5 | 6 | Nova package for showing textarea content on index with limits 7 | 8 | ### Install 9 | 10 | ```bash 11 | composer require dillingham/nova-index-textarea 12 | ``` 13 | 14 | ### Usage 15 | 16 | This package adds two methods to the existing `Textarea` Nova field 17 | 18 | ```php 19 | use Laravel\Nova\Fields\Textarea; 20 | ``` 21 | ```php 22 | Textarea::make('Description')->showOnIndex()->limit(10) 23 | ``` 24 | 25 | ### Options 26 | 27 | `limit($amount, $ending='...')` 28 | 29 | 30 | ### Sidenote 31 | 32 | Add `->showAlways()` to turn off toggling on detail 33 | 34 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Brian Dillingham 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/FieldServiceProvider.php: -------------------------------------------------------------------------------- 1 | showOnIndex = true; 21 | 22 | return $this; 23 | }); 24 | 25 | Textarea::macro('limit', function($amount, $ending = '...') { 26 | if(resolve(NovaRequest::class)->resourceId == null) { 27 | $this->displayUsing(function() use($amount, $ending) { 28 | return str_limit($this->value, $amount, $ending); 29 | }); 30 | } 31 | 32 | return $this; 33 | }); 34 | } 35 | 36 | /** 37 | * Register any application services. 38 | * 39 | * @return void 40 | */ 41 | public function register() 42 | { 43 | // 44 | } 45 | } 46 | --------------------------------------------------------------------------------