Skip to content

Commit

Permalink
First public version
Browse files Browse the repository at this point in the history
  • Loading branch information
ModestasV committed May 6, 2024
0 parents commit eb4550a
Show file tree
Hide file tree
Showing 247 changed files with 31,639 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
64 changes: 64 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
APP_NAME=FilaStart
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync

CACHE_STORE=database
CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
33 changes: 33 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run tests

on:
pull_request:
branches: [ "main" ]

jobs:
laravel-tests:

runs-on: ubuntu-latest

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via Pest
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/pest
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
dump.rdb
63 changes: 63 additions & 0 deletions .readme/CustomFields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FilaStart is built with customization in mind. You can create your own custom fields to suit your needs. Here's a quick guide on how to make a custom field:

## Defining the Field

First, we need to tell our system that this field exists. To do this, open up:

**app/Enums/CrudFieldTypes.php**

And add a new field type:

```php
// ...
const CUSTOM_FIELD = 'custom_field';
// ...
```

Of course, remember to add it to the `getLabel()` method, as it will automatically populate the select field.

## Creating the Field Class

Next, we need a new class for our field. Create a new file in:

**systems/generators/filament3/src/Generators/Fields**

**Note:** You can copy and modify one of the existing fields to suit your needs.

Once that is done - you can override methods as you need. But here's a few important ones:

```php
// Class to use in the form
protected string $formComponentClass = 'DatePicker';

// Class to use in the table
protected string $tableColumnClass = 'TextColumn';

// The key to use in the form
protected function resolveFormComponent(): void
{
$this->formKey = $this->field->key;
}

// The key to use in the table
protected function resolveTableColumn(): void
{
$this->tableKey = $this->field->key;
}
```

Once this is done, we have another step to take - register the field in the generator.

Open up `systems/generators/filament3/src/Generators/Fields/RetrieveGeneratorForField.php` and add your field to the match statement.

## Using the Field

You can now use your field in the CRUD editor. Select the "Custom Field" type and fill in the form as you would with any other field.

## Testing

We strongly recommend testing your field before using it in production. To do this, create a new file in `tests/Feature/Filament3/Fields` and make a test for your field.

## Other Customizations

When creating a new field, remember to look at `systems/generators/filament3/src/Generators/Fields/BaseField.php`, as this is the base class for all fields. You can override any method you need in your custom field.
21 changes: 21 additions & 0 deletions .readme/ModifyingTemplates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
While our generator covers most basic things, you should add different stuff to your files. To do that, you can modify the templates we use:

## Modifying Filament Templates

Our Filament file templates are in the `systems/generators/filament3/src/templates` directory.

You can modify the files in that directory to change the generated code.

**Note:** Sometimes, you might need to modify the generators themselves. Search for the file name in the `systems/generators/filament3/src/Generators` directory and modify the file.

## Modifying Laravel Templates

Our Laravel file templates are in the `systems/generators/laravel11/src/templates` directory.

As with Filament, you can modify the files in that directory to change the generated code.

**Note:** Sometimes, you might need to modify the generators themselves. Search for the file name in the `systems/generators/laravel11/src/Generators` directory and modify the file.

---

File templates are written in Blade, so you can use all its features.
109 changes: 109 additions & 0 deletions .readme/ModulesReadme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
A quick overview of how Modules work.

## What is a Module?

In this system, a module is a set of pre-defined CRUD details. For example, a module can contain more information for a `User` CRUD.

This module will have the following details:

- Unlimited amount of CRUDs inside
- Each CRUD will have its own details
- Each CRUD will have its own fields
- Each field will have its own details

These modules are quickly installed using `app/Interfaces/ModuleBase.php` methods `install()` and `uninstall()`.

Each module, if needed, can override those methods.

---

## How to create a Module?

To create a module, you have a few options:

1. Start from scratch
2. Copy one of the existing modules and modify it

In both cases, the result should be the same:

1. A file in the `systems/generators/filament3/src/Modules` folder
2. A-line with unique `slug` in `systems/generators/filament3/src/Modules/ModuleManager.php.`

Now, each module should have an implementation of the `getCruds()` method. This method should return an array of CRUDs. For example, take from `BaseModule`:

```php
public function getCruds(): array
{
return [
(new Crud([
'type' => CrudTypes::PARENT,
'title' => str('User Management')->singular()->studly(),
'visual_title' => 'User Management',
'icon' => 'heroicon-o-users',
'menu_order' => 1,
'is_hidden' => false,
'module_crud' => true,
'system' => true,
])),
(new Crud([
'parent_id' => str('User Management')->singular()->studly(),
'type' => CrudTypes::CRUD,
'title' => str('Permissions')->singular()->studly(),
'visual_title' => 'Permissions',
'icon' => '',
'menu_order' => 1,
'is_hidden' => false,
'module_crud' => true,
'system' => true,
]))
->setRelation('fields', [
$this->getIDField(),
new CrudField([
'type' => CrudFieldTypes::TEXT,
'key' => str('Title')->lower()
->snake()
->toString(),
'label' => 'Title',
'validation' => 'required',
'in_list' => true,
'in_show' => true,
'in_create' => true,
'in_edit' => true,
'nullable' => false,
'tooltip' => null,
'system' => true,
'enabled' => true,
'order' => 2,
]),
$this->getCreatedAtField(3),
$this->getUpdatedAtField(4),
$this->getDeletedAtField(5),
]
),
];
}
```

Everything is done via new Module instances. We don't save them to the database; we use them as DTOs.

---

## Installing / Removing a Module

Installation/Removal is handled automatically in the system. It is done via:

```php
ModuleService::getModuleClass(App\Models\Panel, 'module-slug-goes-here')
->install(App\Models\Panel);
```

And:

```php
ModuleService::getModuleClass(App\Models\Panel, 'module-slug-goes-here')
->uninstall(App\Models\Panel);
```

Both methods accept a `Panel` (the current admin panel) as a parameter and a module SLUG.

---
Loading

0 comments on commit eb4550a

Please sign in to comment.