{"id":13665025,"url":"https://github.com/poowf/otter","last_synced_at":"2025-04-05T05:06:13.024Z","repository":{"id":33881383,"uuid":"160336399","full_name":"poowf/otter","owner":"poowf","description":"A relatively automatic CRUD backend administration panel for Laravel","archived":false,"fork":false,"pushed_at":"2023-01-05T22:25:37.000Z","size":19690,"stargazers_count":258,"open_issues_count":25,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T04:06:55.405Z","etag":null,"topics":["administration","backend","dashboard","eloquent-models","hacktoberfest","laravel","laravel-nova","otter"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/poowf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-04T09:59:08.000Z","updated_at":"2025-03-24T01:09:31.000Z","dependencies_parsed_at":"2023-01-15T03:08:06.341Z","dependency_job_id":null,"html_url":"https://github.com/poowf/otter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poowf%2Fotter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poowf%2Fotter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poowf%2Fotter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poowf%2Fotter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poowf","download_url":"https://codeload.github.com/poowf/otter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289426,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["administration","backend","dashboard","eloquent-models","hacktoberfest","laravel","laravel-nova","otter"],"created_at":"2024-08-02T05:03:15.477Z","updated_at":"2025-04-05T05:06:13.002Z","avatar_url":"https://github.com/poowf.png","language":"CSS","funding_links":[],"categories":["CSS"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://poowf.blob.core.windows.net/otter/assets/otterbanner.svg\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://travis-ci.org/poowf/otter\"\u003e\u003cimg src=\"https://travis-ci.org/poowf/otter.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/poowf/otter\"\u003e\u003cimg src=\"https://poser.pugx.org/poowf/otter/d/total.svg\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/poowf/otter\"\u003e\u003cimg src=\"https://poser.pugx.org/poowf/otter/v/unstable.svg\" alt=\"Latest Unstable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/poowf/otter\"\u003e\u003cimg src=\"https://poser.pugx.org/poowf/otter/v/stable.svg\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/poowf/otter\"\u003e\u003cimg src=\"https://poser.pugx.org/poowf/otter/license.svg\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003eA relatively ottermatic (automatic) CRUD backend administration panel\u003c/p\u003e\n\n# Introduction\nOtter was created as an open-source alternative to Laravel Nova. The backend administration panel is built with the beautiful tabler template and follows the structure of the popular laravel extension packages like horizon and telescope.\n\nOtter is designed to handle almost everything for you through `OtterResource` files that essentially tie to your Eloquent Models.\n\n# Screenshots\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://imgur.com/a/U4ujI8c\"\u003e\u003cimg width=\"80\" src=\"https://img.shields.io/badge/Light-lightgrey.svg?colorB=9aa0ac\u0026style=flat-square\"\u003e\u003c/a\u003e\n\u003ca href=\"https://imgur.com/a/1rdYjbY\"\u003e\u003cimg width=\"80\" src=\"https://img.shields.io/badge/Dark-black.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Installation\n\nInstall Otter with [composer](https://getcomposer.org/doc/00-intro.md):\n\n```bash\n$ composer require poowf/otter\n```\n\n\u003e In Laravel 5.5+, [service providers and aliases are automatically registered](https://laravel.com/docs/packages#package-discovery). If you're using Laravel 5.5+, skip ahead directly to step 2.\n\nOnce the composer installation completes, all you need to do is add the service provider. Open `config/app.php`, and make the following changes:\n\n1) Add a new item to the `providers` array:\n\n    ```php\n    Poowf\\Otter\\OtterServiceProvider::class,\n    ```\n\n2) Install all the relevant Otter assets:\n    \u003e If you are updating Otter, run `php artisan otter:publish` instead\n    ```bash\n    php artisan otter:install\n    ```\n    \n# Usage\nDefining the Models to be registered to Otter is very simple. Let's create an `OtterResource` by running the following command:\n```bash\nphp artisan otter:resource User\n``` \n\u003e You may specify a model class name with the `--model` argument\n\nThis will generate a `OtterResource` file located in `app/Otter`.\n\n# OtterResource Conventions\nThis is an example of an `OtterResource` that is generated by the `otter:resource` command, which will be automatically registered by Otter.\n```php\n\u003c?php\n\nnamespace App\\Otter;\n\nuse Poowf\\Otter\\Http\\Resources\\OtterResource;\n\nclass User extends OtterResource\n{\n    //\n}\n```\n\n## Model\nThe `$model` variable is where we define the Eloquent Model that the `OtterResource` is responsible for.\n\n```php\n\u003c?php\n\nnamespace App\\Otter;\n\nuse Poowf\\Otter\\Http\\Resources\\OtterResource;\n\nclass User extends OtterResource\n{\n    /**\n     * The model the resource corresponds to.\n     *\n     * @var string\n     */\n    public static $model = 'App\\User';\n}\n```\n\n## Fields\nThe `fields` function will return a key value pair of the available columns that you would like to control in the Otter.\nThey key is the name of the column in the model, and the value is the type of the input.\n\n```php\n\u003c?php\n\nnamespace App\\Otter;\n\nuse Poowf\\Otter\\Http\\Resources\\OtterResource;\n\nclass User extends OtterResource\n{\n    /**\n     * Get the fields and types used by the resource\n     *\n     * @return array\n     */\n    public function fields()\n    {\n        return [\n            'name' =\u003e 'text',\n            'password' =\u003e 'password',\n            'email' =\u003e 'email',\n        ];\n    }\n}\n```\n\nYou can hide certain fields in the index and single view resources by defining a `hidden` function returning an array of the keys that you would like hidden. An example configuration would be to hide the password field for a User.\n\n```php\n\u003c?php\n\nnamespace App\\Otter;\n\nuse Poowf\\Otter\\Http\\Resources\\OtterResource;\n\nclass User extends OtterResource\n{\n    /**\n     * Fields to be hidden in the resource collection\n     *\n     * @return array\n     */\n    public function hidden()\n    {\n        return [\n            'password'\n        ];\n    }\n}\n```\n\n## Validation\nWhen creating or updating the resources in storage, you should add some validation rules to ensure that the data is stored correctly. You can do this for both the client and server side by defining a `validations` method in the `OtterResource`. The below example has defined rules for both the client and server side for the create and updated methods.\nThe client side is utilising VeeValidate for validation so please see the available rules at the [VeeValidate Rules Documentation](https://baianat.github.io/vee-validate/guide/rules.html). The server side is utilising the default [Laravel Validation Rules](https://laravel.com/docs/validation#available-validation-rules).\n\n```php\n/**\n * Get the validation rules used by the resource\n *\n * @return array\n */\npublic static function validations()\n{\n    return [\n        'client' =\u003e [\n            'create' =\u003e [\n                'name' =\u003e 'required|min:4',\n                'email' =\u003e 'required|email',\n                'password' =\u003e 'required',\n            ],\n            'update' =\u003e [\n                'name' =\u003e 'required|min:4',\n                'email' =\u003e 'required|email',\n                'password' =\u003e '',\n            ]\n        ],\n        'server' =\u003e [\n            'create' =\u003e [\n                'name' =\u003e 'required|min:4',\n                'email' =\u003e 'required|email|unique:users',\n                'password' =\u003e 'required',\n            ],\n            'update' =\u003e [\n                'name' =\u003e 'required|string|min:4',\n                'email' =\u003e 'required|email|unique:users,email,' . auth()-\u003euser()-\u003eid,\n                'password' =\u003e 'required',\n            ]\n        ],\n    ];\n}\n```\n\n## Relationships\n\nOtter has partial support for Eloquent relationships. You have to define your relationships in the `OtterResource` file and define the Relationship `method name` as the key and the `OtterResource` class name that links to the relationship.\n \nYou can also define a custom foreign key if you are not using the Laravel defaults.\n\nThe `title` property should be the column of the model that will be displayed in the options list during editing/creating of new resources .\n\n```php\n\u003c?php\n\nnamespace App\\Otter;\n\nuse Poowf\\Otter\\Http\\Resources\\OtterResource;\n\nclass User extends OtterResource\n{\n    /**\n     * The column of the model to display in select options\n     *\n     * @var string\n     */\n    public static $title = 'name';\n        \n    /**\n     * Get the relations used by the resource\n     *\n     * @return array\n     */\n    public function relations()\n    {\n        return [\n            'company' =\u003e ['Company', 'company_id'],\n            'company' =\u003e 'Company',\n        ];\n    }\n}\n```\n\n# Authorization\nOtter exposes a dashboard at `/otter`. By default, you will only be able to access this dashboard in the local environment. Within your `app/Providers/OtterServiceProvider.php` file, there is a gate method. This authorization gate controls access to Otter in non-local environments. You are free to modify this gate as needed to restrict access to your Otter installation:\n\n```php\n/**\n * Register the Otter gate.\n *\n * This gate determines who can access Otter in non-local environments.\n *\n * @return void\n */\nprotected function gate()\n{\n    Gate::define('viewOtter', function ($user) {\n        return in_array($user-\u003eemail, [\n            'zane@poowf.com'\n        ]);\n    });\n}\n```\n\n# Configuration\nAfter publishing Otter's assets, its primary configuration file will be located at `config/otter.php`. \n\nThis configuration file will allow you to configure the middleware for both the `api` and `web` routes that is automatically registered by Otter. \n\nYou can also configure the keys of the `Auth::user()` instance for the `name` and `email` properties that is used in the top right dropdown. \n\nThe `pagination` configuration value is used to display the number of records in the index pages.\n```php\n'middleware.web' =\u003e ['web'],\n'middleware.api' =\u003e ['api'],\n\n'pagination' =\u003e 20,\n\n'user' =\u003e [\n    'name' =\u003e 'name',\n    'email' =\u003e 'email',\n],\n```\n\n# Extras\nA dark/night theme can be enabled by specifying `Otter::night()` in the boot method of the OtterServiceProvider\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoowf%2Fotter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoowf%2Fotter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoowf%2Fotter/lists"}