Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Cycle Orm Adapter Laravel Package

wayofdev/laravel-cycle-orm-adapter

View on GitHub
Deep Wiki
Context7

import ExternalLink from "../../components/external-link";

Validation

Laravel provides several different approaches to validate your application's incoming data. As we plan to use this package in larger projects, better approach would be to use Laravel <ExternalLink href="https://laravel.com/docs/10.x/validation#form-request-validation">Form Request Validation</ExternalLink>. This way we can keep our controllers clean and our code more readable.

Both unique and exists validation rules, require the database to be queried. This packages provides this integration.

⚡️ Unique

The field under validation must be unique for a given Entity. If the column option is not specified, the field name will be used.

To accomplish this, we can use WayOfDev\Cycle\Bridge\Laravel\Rules\Unique rule class.

Example Form Request

This example shows how to use Unique rule class in a form request.

<?php

declare(strict_types=1);

namespace Bridge\Laravel\Admin\Product\Requests;

use Cycle\Database\DatabaseInterface;
use WayOfDev\Cycle\Bridge\Laravel\Rules\Unique;

final class StoreFormRequest
{
    public function rules(DatabaseInterface $database): array
    {
        return [
            'name' => ['required'], // ... just a simple required rule
            // ... other rules
            'category.id' => [
                'bail',
                'required',
                'uuid',
                new Unique($database, 'categories', 'id')
            ],
        ];
    }
}

⚡️ Exists

The field under validation must exist on a given Entity. If the column option is not specified, the field name will be used.

To accomplish this, we can use WayOfDev\Cycle\Bridge\Laravel\Rules\Exists rule class.

Example Form Request

This example shows how to use Exists rule class in a form request.

<?php

declare(strict_types=1);

namespace Bridge\Laravel\Admin\Product\Requests;

use Cycle\Database\DatabaseInterface;
use WayOfDev\Cycle\Bridge\Laravel\Rules\Exists;

final class UpdateFormRequest
{
    public function rules(DatabaseInterface $database): array
    {
        return [
            'name' => ['required'], // ... just a simple required rule
            // ... other rules
            'category.id' => [
                'bail',
                'required',
                'uuid',
                new Exists($database, 'categories', 'id')
            ],
        ];
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity