Download the PHP package bytegourmet/laravel-conditional-expressions without Composer

On this page you can find all versions of the php package bytegourmet/laravel-conditional-expressions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-conditional-expressions

Laravel Conditional Expressions

A fluent CASE WHEN expression builder for Laravel that makes it easy to write complex conditional SQL expressions in your queries.

Features

Requirements

Installation

Standard Installation

Install the package via Composer:

The package will automatically register its service provider.

Quick Start

Basic Usage

Usage

Simple CASE Expression

A simple CASE expression compares a column against multiple values:

Searched CASE Expression

A searched CASE expression evaluates conditions (no column comparison):

Using in Queries

With Eloquent Models

With Query Builder

Nested CASE Expressions

You can nest CASE expressions for complex logic:

Complex Conditions with CaseBuilder

For complex WHERE conditions in your CASE expressions, use CaseBuilder:

Advanced CaseBuilder Usage

Using the selectCase Macro

The package provides a convenient selectCase macro for cleaner syntax:

Multiple CASE Expressions

You can use multiple CASE expressions in a single query:

Real-World Examples

Example 1: User Status with Multiple Conditions

Example 2: Order Priority Based on Amount and Date

Example 3: Dynamic Pricing Tiers

API Reference

CaseExpr

The main facade class for creating CASE expressions.

Methods

CaseExpr::make(?string $column = null)

Creates a new searched CASE expression (or simple CASE if column is provided).

CaseExpr::simple(string $column)

Creates a simple CASE expression for the given column.

CaseExpr::builder()

Creates a new CaseBuilder instance for complex conditions.

CaseExpression

The expression class that builds the CASE statement.

Methods

when(string|CaseBuilder|Expression $column, ?string $operator = null, mixed $value = null)

Adds a WHEN clause to the CASE expression.

then(mixed $result)

Sets the THEN value for the last WHEN clause. Accepts scalar values or nested CaseExpression.

else(mixed $result)

Sets the ELSE value. Accepts scalar values or nested CaseExpression.

as(string $alias)

Sets an alias for the CASE expression.

toSql()

Returns the generated SQL string.

getBindings()

Returns the parameter bindings array.

CaseBuilder

Extends Laravel's Query Builder for building complex WHERE conditions.

Methods

CaseBuilder::query()

Creates a new CaseBuilder instance.

getConditions()

Returns the compiled WHERE conditions as a string.

All standard Laravel Query Builder methods are available (where, orWhere, whereNull, etc.).

Debugging

You can debug your CASE expressions using the provided helper methods:

Testing

Run the test suite:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This package is open-sourced software licensed under the MIT license.

Credits


All versions of laravel-conditional-expressions with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bytegourmet/laravel-conditional-expressions contains the following files

Loading the files please wait ...