arrow-left

Only this pageAll pages
gitbookPowered by GitBook
1 of 22

CodeCrafters Docs

Loading...

Getting Started

Loading...

Plugins

Loading...

Loading...

Loading...

Project

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Blockchain

Loading...

Loading...

Loading...

Loading...

Loading...

Welcome

Welcome to CodeCrafters Docs, the official documentation hub for all open-source projects created and maintained by the CodeCrafters community. Whether you are a seasoned developer, a budding coder, or simply someone interested in the vibrant world of open-source software, this site is your go-to resource for comprehensive, well-organized, and user-friendly documentation.

hashtag
About CodeCrafters Community

CodeCrafters is a passionate community of developers dedicated to crafting high-quality, innovative, and impactful open-source projects. Our community thrives on collaboration, knowledge-sharing, and the collective effort to push the boundaries of what’s possible in software development.

hashtag
What You'll Find Here

At CodeCrafters Docs, you will find detailed documentation for a wide array of projects spanning various domains and technologies. Our documentation is designed to help you:

  • Understand the Projects: Get in-depth information about the purpose, functionality, and architecture of each project.

  • Get Started Quickly: Follow step-by-step guides to set up and start using our projects with ease.

  • Contribute Effectively: Learn how to contribute to projects, from reporting issues to submitting pull requests and participating in discussions.

hashtag
Join Us

We believe that open-source is all about community. We encourage you to join us, contribute to our projects, and help us make CodeCrafters a thriving hub of innovation and excellence. Whether you’re fixing bugs, writing documentation, creating new features, or simply spreading the word, every contribution counts.

hashtag
Stay Connected

Stay up-to-date with the latest developments by following our blog, joining our forums, and connecting with us on social media. We also host regular meetups, webinars, and coding sessions to foster learning and collaboration.

Thank you for visiting CodeCrafters Docs. We are excited to have you here and look forward to building amazing things together.


Welcome to the journey of creating, learning, and innovating with CodeCrafters!

Happy Coding!

The CodeCrafters Community

How to Join

Are you passionate about open-source development and eager to collaborate with like-minded individuals? Joining the CodeCrafters community is easy and rewarding. Follow the steps below to become a part of our vibrant and innovative network of developers.

hashtag
Step 1: Express Your Interest

Send an email to Rupadana at rupadanawayan[@]gmail.com with the subject line "Joining CodeCrafters Community". In your email, please include the following information:

  • Name: Your full name.

  • GitHub Username: Your GitHub username or profile link.

  • Skills and Interests: A brief description of your programming skills, languages you are proficient in, and areas of interest.

  • Projects: Any relevant open-source projects you have worked on or are currently working on (if applicable).

  • Motivation: A short paragraph on why you want to join CodeCrafters and how you hope to contribute.

hashtag
Step 2: Await Response

Once your email is received, our team will review your application. You will receive a response within a few days with further instructions on how to proceed. We may ask for additional information or a brief interview to better understand your skills and interests.

hashtag
Step 3: Get Onboarded

Upon acceptance, you will be onboarded into the CodeCrafters community. This includes:

  • Access to Community Platforms: You will be invited to join our forums, chat groups, and other collaborative platforms where you can interact with fellow members.

  • Introduction to Projects: You will receive an overview of ongoing projects and find out how you can start contributing immediately.

  • Guidelines and Resources: We will provide you with community guidelines, coding standards, and other resources to help you get started.

hashtag
Step 4: Start Contributing

With access to our community and projects, you can begin contributing in various ways:

  • Code Contributions: Write code, fix bugs, and implement new features in our open-source projects.

  • Documentation: Help improve project documentation to make it easier for others to understand and use.

  • Support and Mentorship: Provide support to other community members, mentor new contributors, and share your knowledge.


We are thrilled to have you consider joining CodeCrafters and look forward to your contributions. Together, we can continue to create amazing open-source projects and foster a collaborative, supportive environment for developers everywhere.

For any questions or additional information, feel free to contact Rupadana at .

Welcome to CodeCrafters!

The CodeCrafters Community

Community Engagement: Participate in discussions, attend meetups, and collaborate on new ideas and initiatives.

[email protected]envelope

Explore Examples and Use Cases: Discover real-world examples and use cases to understand how our projects can be applied to solve real problems.

Cover

How to Join the CodeCrafters Community

Blockchain - Testnet

How to use it?

Requirements

  • Ubuntu 18.04 or later LTS

  • 6 core physical CPU or More

  • 32GB of RAM

  • 240GB SSD storage or more

Testnet

Empeiria

Installation

First thing first, lets clone the repository

git clone https://github.com/rupadana/code-deploy

change your directory to project and install packages

composer install

Run this command to setup .env file or you can do it manually.

composer run-script post-root-package-install

Generate laravel app key using :

Run this command to migrate & create super admin user

Log in to dashboard and create team!

Create a server

Let's create a server first. please use root user.

After creating the server, we need to adding public key to our server. if you did'nt setup the server yet, please follow this instruction.

Copy the ssh public key.

Remote your server with root user

ssh [email protected]

open authorized_keys and paste your public key

and then Check connection, make sure the connection is successfully

Congrats, your server added to CodeDeploy!

Code Deploy

CodeDeploy is an advanced deployment tool specifically designed for developers who want to streamline the process of deploying web applications directly from GitHub. Leveraging the Push to Deploy method, CodeDeploy simplifies the deployment workflow, enabling developers to deploy code with a single push to their repository.

Key Features:

  • Push to Deploy: Automatically deploy your web application with each push to your GitHub repository, eliminating the need for manual deployments.

Installation

hashtag
Install Dependencies

hashtag
tall GO if needed

Pre-requisite

To running this project you need to prepare a VPS or you can do it locally on your dev environment and run it with to optimize push to deploy feature.

VPS Minimum Spesification :

  • CPU : 1 core

  • Ram : 1 GB

php artisan key:generate --ansi
Optimized Performance: Engineered for speed and efficiency, CodeDeploy ensures that your web projects are deployed quickly and reliably.
  • Automated Testing: Run automated tests before deployment to catch issues early, ensuring your production environment is always stable.

  • Rollback Capabilities: Easily roll back to a previous version of your application if something goes wrong, minimizing downtime and disruption.

  • Secure Deployments: Built with security in mind, CodeDeploy integrates seamlessly with GitHub, providing a secure deployment pipeline for your web projects.

  • User-Friendly Interface: Manage your deployments with an intuitive and easy-to-use interface designed to simplify the deployment process for developers of all skill levels.

  • Who It's For:

    CodeDeploy is ideal for web developers, DevOps teams, and software development companies looking to automate and optimize their deployment processes. Whether you're working on a small personal project or a large-scale web application, CodeDeploy provides the tools you need to deploy with confidence.

    Why Choose CodeDeploy?

    CodeDeploy takes the complexity out of web deployment. By integrating directly with GitHub, it offers a seamless, automated solution that saves time, reduces errors, and ensures your web applications are always up to date. As an open-source project, CodeDeploy is continuously evolving with contributions from a vibrant community of developers. With its powerful features, user-friendly design, and the flexibility of open-source, CodeDeploy is the go-to choice for developers who want to focus on coding, not deploying.

    Disk : 20GB

  • OS : Ubuntu 24.04

  • After creating the VPS, you need to install cloudpanel. Follow this instructionarrow-up-right to install it.

    ngrokarrow-up-right
    php artisan shield:install
    http://127.0.0.1:8000/app/loginarrow-up-right
    hashtag
    Set Vars

    change MONIKER="Moniker" with your own moniker and change SYMPHONY_PORT="14" to your own port

    hashtag
    Install Binary

    hashtag
    Initialize Node

    hashtag
    Download Genesis and Addrbook

    sudo apt update && sudo apt upgrade -y 
    sudo apt install -y git gcc make unzip jq
    nano .ssh/authorized_keys
    ver="1.22.2"
    cd $HOME
    wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz"
    sudo rm -rf /usr/local/go
    sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz"
    rm "go$ver.linux-amd64.tar.gz"
    echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.bash_profile
    source ~/.bash_profile
    go version
    echo "export WALLET="wallet"" >> $HOME/.bash_profile
    echo "export MONIKER="Moniker"" >> $HOME/.bash_profile
    echo "export EMPED_CHAIN_ID="empe-testnet-2"" >> $HOME/.bash_profile
    echo "export EMPED_PORT="14"" >> $HOME/.bash_profile
    source $HOME/.bash_profile
    cd $HOME
    curl -LO https://github.com/empe-io/empe-chain-releases/raw/master/v0.1.0/emped_linux_amd64.tar.gz
    tar -xvf emped_linux_amd64.tar.gz 
    mv emped ~/go/bin
    emped init $MONIKER --chain-id empe-testnet-2
    emped config chain-id $EMPED_CHAIN_ID
    emped config keyring-backend test
    wget -O $HOME/.empe

    Remote Database Backup

    arrow-up-right

    RDB is a web application built using FilamentPHP v3arrow-up-right.

    This tool offers a seamless and secure way to manage and back up your databases remotely. With an intuitive user interface, it allows you to schedule backups, and monitor backup with ease.

    Designed for efficiency and reliability, RDB is the perfect solution for businesses and developers looking to safeguard their critical data effortlessly.

    hashtag
    Prerequisites

    You must install mysql-client and postgresql-client since this project uses mysqldump and pg_dump.

    hashtag
    Installation

    Clone the repository

    Update your local environment

    Run artisan app:install

    Default user

    email : [email protected]

    password : 12345678

    hashtag
    Supervisor

    This project must use supervisorctl to manage database queues. Make sure you configure it itself.

    hashtag
    Database Backup Runner

    Currently, we support two runners to back up mysql and postgresql databases.

    You can easly adding your custom runner by extends class AbstractBackupRunner and register it on AppServiceProvider

    hashtag
    Code of Conduct

    In order to ensure that the Laravel community is welcoming to all, please review and abide by the .

    hashtag
    Security Vulnerabilities

    If you discover a security vulnerability within this project, please send an e-mail to Rupadana via . All security vulnerabilities will be promptly addressed.

    hashtag
    License

    The Remote Database Backup is open-sourced software licensed under the .

    Adding site

    This step i assuming you already setup your site, if you using cloudpanel follow this to add the site first.

    Of course you can use your favorite panel too.

    hashtag
    Let's get started

    Navigate to server list and click Site

    Add discord notification

    Monitor failed or success deployment using discord notification, create your own notification bot webhook.

    And then add it to Notification at Server detail.

    Now you will get updated for every Quick Deployment!

    button.

    Next step, add your site information. And then click create.

    After created, then click Manage site.

    You will see this page

    Now lets check if the site is installed successfully, navigate to Deployment Page. And add php artisan about to see if it working. Then, click deploy now.

    Click Enable Quick Deploy If you want to activate Push to Deploy.

    Next step, Let's navigate to Repository page.

    Section
    Description

    Repository

    If your GitHub account is connected with CodeDeploy, you will see a list of your repositories.

    You can leave this empty if the account is not connected.

    Branch

    CodeDeploy uses this branch to gather details of the latest commit when you deploy your application.

    Site detail

    CodeDeploy uses this data to deploy your application

    Deploy Webhook URL

    Let's change the branch to the main & generate webhook url

    Copy the webhook url, and then add it to github.

    circle-info

    You can skip this step if you did'nt enabled the Quick Deploy

    instructionarrow-up-right
    Code of Conductarrow-up-right
    [email protected]envelope
    MIT licensearrow-up-right

    Filament Swiper

    The Most Modern Mobile Touch Slider now on FilamentPHP

    arrow-up-right arrow-up-right

    This is a Swiper Component for filament, using SwiperJSarrow-up-right.

    hashtag
    Installation

    You can install the package via composer:

    hashtag
    Usage

    Available API

    hashtag
    Widget

    Create a class whatever u want. example App\Livewire\Widgets\Swipget and extends Rupadana\FilamentSwiper\Widgets\SwiperWidget,

    and register it to your Filament Provider

    hashtag
    Bugs

    There is a bug. we need contributor to fix it.

    hashtag
    Features

    There is module has been implemented in this project.

    hashtag
    Changelog

    Please see CHANGELOG for more information on what has changed recently.

    hashtag
    Contributing

    Please see CONTRIBUTING for details.

    hashtag
    Security Vulnerabilities

    Please review our security policy on how to report security vulnerabilities.

    hashtag
    Credits

    • All Contributors

    hashtag
    License

    The MIT License (MIT). Please see License File for more information.

    Chasm Network

    Inference Scout is a tool that runs inference tasks given by Chasm's Orchestrator. It allows you to leverage powerful language models and contribute to Chasm Network.

    hashtag
    Prerequisites

    hashtag
    API Keys

    • Obtain a Groq API key from the

    • (Optional) Obtain an Openrouter API key from Openrouter

    • Obtain SCOUT_UID and WEBHOOK_API_KEY from the Chasm Website

    hashtag
    Server Specifications

    • 1 vCPU

    • 1GB RAM

    • 20GB Disk

    • Static IP

    hashtag
    Suggested Requirements:

    • 2 vCPU

    • 4GB RAM

    • 50GB SSD

    • Static IP

    hashtag
    Obtaining your SCOUT_UID and WEBHOOK_API_KEY

    • Go to

    • Click _mint(scout)

    • Log in to the website and retrieve your webhook API key and UID as the first step.

    hashtag
    Software Requirements

    1. Install Docker: Follow the

    2. Set up the environment file: Use nano .env or vim .env to create a file with the following content:

    💡Do not use single quotes (') or double quotes (") in your .env file, as Docker has issues with them.

    hashtag
    Setup Guide

    1. Get Required Credentials from Chasm

    2. Prepare the .env File (as shown above)

    3. Verify Scout Ranking: Check your scout ranking at the . Note: The node status may take up to an hour to update.

    Monitor Scout Performance:Copy

    Restart Docker Container (if needed):Copy

    Test LLM Functionality:Copy

    Test Server Response:Copy

    Expected response: OK

    Verify Server Status:Copy

    Run the Docker Container:Copy

    Pull the Docker Image:Copy

    hashtag
    Troubleshooting

    Environment Variables

    Double-check that all required environment variables are correctly set in the .env file.

    Additional Resources

    • Optimization Guide: Follow the for performance improvements.

    • Update Guide: Follow the for updating your scout.

    This guide should help you set up and run the Chasm Scout server effectively. For more detailed instructions and troubleshooting, refer to the original repository and additional resources provided.

    composer create-project rupadana/remote-database-backup
    php artisan app:install
    \App\Filament\Resources\DatabaseResource\Services\Backup\BackupRunner::register(CustomBackupRunner::class);
    composer require rupadana/filament-swiper
    Total Downloads

    You can use this URL to trigger deployments remotely, You can send a "post" request to this URL.

  • Rupadanaarrow-up-right
    Groq Consolearrow-up-right
    https://scout.chasm.net/private-mintarrow-up-right
    Docker Installation Guidearrow-up-right
    Leaderboardarrow-up-right
    optimization guidearrow-up-right
    update guidearrow-up-right

    Filament Announce

    The easiest way to shout announcements in filament!

    hashtag

    hashtag

    public function infolists(Infolists $infolists) {
        return $infolists
        ->schema([
            \Rupadana\FilamentSwiper\Infolists\Components\SwiperImageEntry::make('attachment')
                ->navigation(false)
                ->pagination()
                ->paginationType(SwiperImageEntry::BULLETS)
                ->paginationClickable()
                ->paginationDynamicBullets()
                ->paginationHideOnClick()
                ->paginationDynamicMainBullets(2)
                ->scrollbar()
                ->scrollbarDragSize(100)
                ->scrollbarDraggable()
                ->scrollbarSnapOnRelease()
                ->scrollbarHide(false)
                ->height(300)
                ->autoplay()
                ->effect(SwiperImageEntry::CARDS_EFFECT)
                ->cardsPerSlideOffset(2)
                ->autoplayDelay(500)
                ->centeredSlides()
                ->slidesPerView(2)
        ])
    } 
    <?php
    
    namespace App\Livewire\Widgets;
    
    use App\Livewire\Components\Feature;
    use Rupadana\FilamentSwiper\Widgets\SwiperWidget;
    
    class Swipget extends SwiperWidget
    {
    
        public function getComponents(): array
        {
            return [
                // Your livewire component
            ];
        }
    }
    
    PORT=3001
    LOGGER_LEVEL=debug
    
    # Chasm
    ORCHESTRATOR_URL=https://orchestrator.chasm.net
    SCOUT_NAME=
    SCOUT_UID=
    WEBHOOK_API_KEY=
    # Scout Webhook Url, update based on your server's IP and Port
    # e.g. http://123.123.123.123:3001/
    WEBHOOK_URL=
    
    # Chosen Provider (groq, openai)
    PROVIDERS=groq
    MODEL=gemma2-9b-it
    GROQ_API_KEY=
    
    # Optional
    OPENROUTER_API_KEY=
    OPENAI_API_KEY=
    docker stats scout
    docker stop scout
    docker rm scout
    docker run -d --restart=always --env-file ./.env -p 3001:3001 --name scout johnsonchasm/chasm-scout
    source ./.env
    curl -X POST \
         -H "Content-Type: application/json" \
         -H "Authorization: Bearer $WEBHOOK_API_KEY" \
         -d '{"body":"{\"model\":\"gemma2-9b-it\",\"messages\":[{\"role\":\"system\",\"content\":\"You are a helpful assistant.\"}]}"}' \
         $WEBHOOK_URL
    curl localhost:3001
    docker logs scout
    docker run -d --restart=always --env-file ./.env -p 3001:3001 --name scout chasmtech/chasm-scout
    docker pull chasmtech/chasm-scout:latest
    Installation

    You can install the package via composer:

    Run migration

    Optionally, you can publish the views using

    publish config

    hashtag
    Usage

    You must enable Announce by adding FilamentAnnouncePlugin class to your Filament Panel's plugin() or plugins([]) method:

    To override the plugins announcementResource with your own custom resource, you should append usingResource method when registering the plugin:

    Now you can announce whatever to users:

    hashtag
    Title and Body Alignment

    By default, the alignments will be start and you might want to adjust them:

    You can also use alignStart(), alignCenter(), alignEnd(), alignJustify(), alignBetween(), alignLeft() and alignRight() for your convenience.

    hashtag
    Add Actions to Announce

    Since Announce extends Filament Notification, you can add Filament Notification Actions to your announcements:

    Read more about Notification Actionarrow-up-right.

    hashtag
    Announcement Resource

    hashtag
    Todo

    hashtag
    Testing

    hashtag
    Changelog

    Please see CHANGELOG for more information on what has changed recently.

    hashtag
    Contributing

    Please see CONTRIBUTING for details.

    hashtag
    Security Vulnerabilities

    Please review our security policy on how to report security vulnerabilities.

    hashtag
    Credits

    • Rupadanaarrow-up-right

    • margarizaldiarrow-up-right

    • All Contributors

    hashtag
    License

    The MIT License (MIT). Please see License File for more information.

    arrow-up-right
    arrow-up-right
    arrow-up-right
    Latest Version on Packagist
    Total Downloads

    Filament API Service

    A simple API service for supporting FilamentPHP

    hashtag
    Installation

    You can install the package via composer:

    Register it to your filament Provider

    composer require rupadana/filament-announce
    # Laravel 11 and higher
    php artisan make:notifications-table
    
    # Laravel 10
    php artisan notifications:table
    php artisan migrate
    php artisan vendor:publish --tag="filament-announce-views"
    php artisan vendor:publish --tag="filament-announce-config"
    return [
        'navigation' => [
            'group' => '',
            'sort' => 1
        ],
        'can_access' => [
            'role' => ['super_admin']
        ]
    ];
    use Rupadana\FilamentAnnounce\FilamentAnnouncePlugin;
    use Filament\Support\Colors\Color;
    class CustomersPanelProvider extends PanelProvider
    {
        public function panel(Panel $panel): Panel
        {
            return $panel
                ...
                ->plugin(
                    FilamentAnnouncePlugin::make()
                        ->pollingInterval('30s') // optional, by default it is set to null
                        ->defaultColor(Color::Blue) // optional, by default it is set to "primary"
    
                )
        }
    }
    
    use Rupadana\FilamentAnnounce\FilamentAnnouncePlugin;
    use Filament\Support\Colors\Color;
    class CustomersPanelProvider extends PanelProvider
    {
        public function panel(Panel $panel): Panel
        {
            return $panel
                ...
                ->plugin(
                    FilamentAnnouncePlugin::make()
                        ->usingResource(MyCustomAnnouncementResource::class)
                        ->pollingInterval('30s') // optional, by default it is set to null
                        ->defaultColor(Color::Blue) // optional, by default it is set to "primary"
    
                )
        }
    }
    
    use App\Models\User;
    use Rupadana\FilamentAnnounce\Announce;
    
    Announce::make()
        ->title('Big News!')
        ->icon('heroicon-o-megaphone')
        ->body('Filament can now show very important message to specific users!')
        ->disableCloseButton() // Optional, if you want ur announcement discloseable
        ->announceTo(User::all());
    use App\Models\User;
    use Filament\Support\Enums\Alignment;
    use Rupadana\FilamentAnnounce\Announce;
    
    Announce::make()
        ->title('Big News!')
        ->icon('heroicon-o-megaphone')
        ->body('Filament can now show very important message to specific users!')
        ->alignment(Alignment::Center) // this will set both title and body alignments (common alignment)
        ->titleAlignment(Alignment::Start) // this will set title alignment and take precedence over common alignment methods
        ->bodyAlignment(Alignment::Start) // this will set body alignment and take precedence over common alignment methods
        ->actions([
            Action::make('view')
                ->button(),
            Action::make('undo')
                ->color('gray'),
        ])
        ->announceTo(User::all());
    use App\Models\User;
    use Rupadana\FilamentAnnounce\Announce;
    
    Announce::make()
        ->title('Big News!')
        ->icon('heroicon-o-megaphone')
        ->body('Filament can now show very important message to specific users!')
        ->actions([
            Action::make('view')
                ->button(),
            Action::make('undo')
                ->color('gray'),
        ])
        ->announceTo(User::all());
    composer test
    hashtag
    Config

    hashtag
    Usage

    Since version 3.0, routes automatically registered. it will grouped as '/api/admin'. admin is panelId. to disable panelId prefix, please set route.panel_prefix to false

    So, You don't need to register the routes manually.

    The routes will be :

    Method
    Endpoint
    Description

    GET

    /api/admin/blogs

    Return LengthAwarePaginator

    GET

    /api/admin/blogs/1

    Return single resource

    On CreateHandler, you need to be create your custom request validation.

    hashtag
    Token Resource

    By default, Token resource only show on super_admin role. you can modify give permission to other permission too.

    Token Resource is protected by TokenPolicy. You can disable it by publishing the config and change this line.

    [!IMPORTANT] If you use Laravel 11, don't forget to run php artisan install:api to publish the personal_access_tokens migration after that run php artisan migrate to migrate the migration, but as default if you run the php artisan install:api it will ask you to migrate your migration.

    hashtag
    Filtering & Allowed Field

    We used "spatie/laravel-query-builder": "^5.3" to handle query selecting, sorting and filtering. Check out the spatie/laravel-query-builder documentationarrow-up-right for more information. You can specified allowedFilters and allowedFields in your model. For example:

    hashtag
    Create a Handler

    To create a handler you can use this command. By default, i'm using CreateHandler

    or

    hashtag
    Transform API Response

    it will be create BlogTransformer in App\Filament\Resources\BlogResource\Api\Transformers

    next step you need to edit & add it to your Resource

    hashtag
    Group Name & Prefix

    You can edit prefix & group route name as you want, default this plugin use model singular label;

    hashtag
    Middlewares

    You can add or override middlewares at two specific places. Via the Filament Panel Provider and/or via the Resources $routeMiddleware.

    If you set route.use_resource_middlewares to true, the package will register the middlewares for that specific resource as defined in:

    Then your API resource endpoint will go through these middlewares first.

    Another method of adding/overriding middlewares is via the initialization of the plugin in your Panel Provider by adding the middleware() method like so:

    hashtag
    Tenancy

    When you want to enable Tenancy on this package you can enable this by setting the config tenancy.enabled to true. This makes sure that your api responses only retreive the data which that user has access to. So if you have configured 5 tenants and an user has access to 2 tenants. Then, enabling this feature will return only the data of those 2 tenants.

    If you have enabled tenancy on this package but on a specific Resource you have defined protected static bool $isScopedToTenant = false;, then the API will honour this for that specific resource and will return all records.

    If you want to make api routes tenant aware. you can set tenancy.awareness to true in your published api-service.php. This way this package will register extra API routes which will return only the specific tenant data in the API response.

    Now your API endpoints will have URI prefix of {tenant} in the API routes when tenancy.awareness is true.

    It will look like this:

    Overriding tenancy ownership relationship name by adding this property to the Handlers protected static ?string $tenantOwnershipRelationshipName = null;

    hashtag
    How to secure it?

    Since version 3.0, it will automatically detect routes and secure it using sanctum.

    To Generate Token, you just need create it from admin panel. It will be Token Resource there.

    Image

    hashtag
    Public API

    Set API to public by overriding this property on your API Handler. Assume we have a PaginationHandler

    hashtag
    License

    The MIT License (MIT).

    hashtag
    Supported By

    arrow-up-right
    Latest Version on Packagist
    GitHub Tests Action Status
    Total Downloads
    composer require rupadana/filament-api-service
    use Rupadana\ApiService\ApiServicePlugin;
    
    $panel->plugins([
        ApiServicePlugin::make()
    ])
    php artisan vendor:publish --tag=api-service-config
    
    return [
        'navigation' => [
            'token' => [
                'cluster' => null,
                'group' => 'User',
                'sort' => -1,
                'icon' => 'heroicon-o-key'
            ]
        ],
        'models' => [
            'token' => [
                'enable_policy' => true,
            ],
        ],
        'route' => [
            'panel_prefix' => true,
            'use_resource_middlewares' => false,
        ],
        'tenancy' => [
            'enabled' => false,
            'awareness' => false,
        ]
    ];
    php artisan make:filament-api-service BlogResource
    'models' => [
            'token' => [
                'enable_policy' => false // default: true
            ]
        ],
    class User extends Model {
        // Which fields can be selected from the database through the query string
        public static array $allowedFields = [
            'name'
        ];
    
        // Which fields can be used to sort the results through the query string
        public static array $allowedSorts = [
            'name',
            'created_at'
        ];
    
        // Which fields can be used to filter the results through the query string
        public static array $allowedFilters = [
            'name'
        ];
    }
    php artisan make:filament-api-handler BlogResource
    php artisan make:filament-api-handler Blog
    php artisan make:filament-api-transformer Blog
    <?php
    namespace App\Filament\Resources\BlogResource\Api\Transformers;
    
    use Illuminate\Http\Resources\Json\JsonResource;
    
    class BlogTransformer extends JsonResource
    {
    
        /**
         * Transform the resource into an array.
         *
         * @param  \Illuminate\Http\Request  $request
         * @return array
         */
        public function toArray($request)
        {
            return $this->resource->toArray();
    
            // or
    
            return md5(json_encode($this->resource->toArray()));
        }
    }
        use App\Filament\Resources\BlogResource\Api\Transformers\BlogTransformer;
    
        class BlogResource extends Resource
        {
            ...
            public static function getApiTransformer()
            {
                return BlogTransformer::class;
            }
            ...
        }
        class BlogApiService extends ApiService
        {
            ...
            protected static string | null $groupRouteName = 'myblog';
            ...
        }
    class BlogResource extends Resource
        {
            ...
            protected static string | array $routeMiddleware = []; // <-- your specific resource middlewares
            ...
        }
    use Rupadana\ApiService\ApiServicePlugin;
    
    $panel->plugins([
        ApiServicePlugin::make()
            ->middleware([
            // ... add your middlewares
            ])
    ])
      POST      api/admin/{tenant}/blog
      GET|HEAD  api/admin/{tenant}/blog
      PUT       api/admin/{tenant}/blog/{id}
      DELETE    api/admin/{tenant}/blog/{id}
      GET|HEAD  api/admin/{tenant}/blog/{id}
    class PaginationHandler extends Handlers {
        public static bool $public = true;
    }

    PUT

    /api/admin/blogs/1

    Update resource

    POST

    /api/admin/blogs

    Create resource

    DELETE

    /api/admin/blogs/1

    Delete resource

    Run Test
    Total Downloads