id stringlengths 6 6 | text stringlengths 20 17.2k | title stringclasses 1
value |
|---|---|---|
238691 | <?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.json-encode" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>json_encode</refname>
<refpurpose>Returns the JSON representation of a value</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.descri... | |
238692 | <refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>json_encode</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
?>
]]>
</programlisting>
&example.outputs;... | |
240707 | <?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="wincache.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.setup;
<section xml:id="wincache.requirements">
&reftitle.required;
<para>
The extension is currently supported only on the f... | |
240975 | <?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<section xml:id="sodium.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.install;
<para>
Use <option role="configure">--with-sodium[=DIR]</option> when compiling PHP.
</para>
<para>
Windows use... | |
240976 | <?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="sodium.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.setup;
<section xml:id="sodium.requirements">
&reftitle.required;
<para>
This extension requires <link xlink:href="&url.libsodi... | |
242788 | # Eloquent: Serialization
- [Introduction](#introduction)
- [Serializing Models and Collections](#serializing-models-and-collections)
- [Serializing to Arrays](#serializing-to-arrays)
- [Serializing to JSON](#serializing-to-json)
- [Hiding Attributes From JSON](#hiding-attributes-from-json)
- [Appending Values... | |
242790 | ### Ecosystem Overview
Laravel offers several packages related to authentication. Before continuing, we'll review the general authentication ecosystem in Laravel and discuss each package's intended purpose.
First, consider how authentication works. When using a web browser, a user will provide their username and pass... | |
242791 | ## Authentication Quickstart
> [!WARNING]
> This portion of the documentation discusses authenticating users via the [Laravel application starter kits](/docs/{{version}}/starter-kits), which includes UI scaffolding to help you get started quickly. If you would like to integrate with Laravel's authentication systems ... | |
242792 | ## Manually Authenticating Users
You are not required to use the authentication scaffolding included with Laravel's [application starter kits](/docs/{{version}}/starter-kits). If you choose not to use this scaffolding, you will need to manage user authentication using the Laravel authentication classes directly. Don't... | |
242793 | ## HTTP Basic Authentication
[HTTP Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) provides a quick way to authenticate users of your application without setting up a dedicated "login" page. To get started, attach the `auth.basic` [middleware](/docs/{{version}}/middleware) to a route. ... | |
242796 | # Laravel Dusk
- [Introduction](#introduction)
- [Installation](#installation)
- [Managing ChromeDriver Installations](#managing-chromedriver-installations)
- [Using Other Browsers](#using-other-browsers)
- [Getting Started](#getting-started)
- [Generating Tests](#generating-tests)
- [Resetting the Dat... | |
242807 | tinuous Integration
> [!WARNING]
> Most Dusk continuous integration configurations expect your Laravel application to be served using the built-in PHP development server on port 8000. Therefore, before continuing, you should ensure that your continuous integration environment has an `APP_URL` environment variable va... | |
242809 | ## Basic Routing
The most basic Laravel routes accept a URI and a closure, providing a very simple and expressive method of defining routes and behavior without complicated routing configuration files:
use Illuminate\Support\Facades\Route;
Route::get('/greeting', function () {
return 'Hello World';
... | |
242810 | ## Route Parameters
<a name="required-parameters"></a>
### Required Parameters
Sometimes you will need to capture segments of the URI within your route. For example, you may need to capture a user's ID from the URL. You may do so by defining route parameters:
Route::get('/user/{id}', function (string $id) {
... | |
242811 | ## Route Groups
Route groups allow you to share route attributes, such as middleware, across a large number of routes without needing to define those attributes on each individual route.
Nested groups attempt to intelligently "merge" attributes with their parent group. Middleware and `where` conditions are merged whi... | |
242812 | ## Route Model Binding
When injecting a model ID to a route or controller action, you will often query the database to retrieve the model that corresponds to that ID. Laravel route model binding provides a convenient way to automatically inject the model instances directly into your routes. For example, instead of inj... | |
242813 | ### Explicit Binding
You are not required to use Laravel's implicit, convention based model resolution in order to use model binding. You can also explicitly define how route parameters correspond to models. To register an explicit binding, use the router's `model` method to specify the class for a given parameter. Yo... | |
242814 | ## Rate Limiting
<a name="defining-rate-limiters"></a>
### Defining Rate Limiters
Laravel includes powerful and customizable rate limiting services that you may utilize to restrict the amount of traffic for a given route or group of routes. To get started, you should define rate limiter configurations that meet your ... | |
242815 | # Facades
- [Introduction](#introduction)
- [When to Utilize Facades](#when-to-use-facades)
- [Facades vs. Dependency Injection](#facades-vs-dependency-injection)
- [Facades vs. Helper Functions](#facades-vs-helper-functions)
- [How Facades Work](#how-facades-work)
- [Real-Time Facades](#real-time-facades)
- [... | |
242817 | ## Facade Class Reference
Below you will find every facade and its underlying class. This is a useful tool for quickly digging into the API documentation for a given facade root. The [service container binding](/docs/{{version}}/container) key is also included where applicable.
<div class="overflow-auto">
| Facade |... | |
242818 | # Request Lifecycle
- [Introduction](#introduction)
- [Lifecycle Overview](#lifecycle-overview)
- [First Steps](#first-steps)
- [HTTP / Console Kernels](#http-console-kernels)
- [Service Providers](#service-providers)
- [Routing](#routing)
- [Finishing Up](#finishing-up)
- [Focus on Service Provide... | |
242824 | # Eloquent: Factories
- [Introduction](#introduction)
- [Defining Model Factories](#defining-model-factories)
- [Generating Factories](#generating-factories)
- [Factory States](#factory-states)
- [Factory Callbacks](#factory-callbacks)
- [Creating Models Using Factories](#creating-models-using-factories)
... | |
242826 | ## Factory Relationships
<a name="has-many-relationships"></a>
### Has Many Relationships
Next, let's explore building Eloquent model relationships using Laravel's fluent factory methods. First, let's assume our application has an `App\Models\User` model and an `App\Models\Post` model. Also, let's assume that the `Us... | |
242830 | ## Mail Notifications
<a name="formatting-mail-messages"></a>
### Formatting Mail Messages
If a notification supports being sent as an email, you should define a `toMail` method on the notification class. This method will receive a `$notifiable` entity and should return an `Illuminate\Notifications\Messages\MailMessa... | |
242832 | ## Markdown Mail Notifications
Markdown mail notifications allow you to take advantage of the pre-built templates of mail notifications, while giving you more freedom to write longer, customized messages. Since the messages are written in Markdown, Laravel is able to render beautiful, responsive HTML templates for the... | |
242836 | ### Routing Slack Notifications
To direct Slack notifications to the appropriate Slack team and channel, define a `routeNotificationForSlack` method on your notifiable model. This method can return one of three values:
- `null` - which defers routing to the channel configured in the notification itself. You may use t... | |
242841 | # Database: Query Builder
- [Introduction](#introduction)
- [Running Database Queries](#running-database-queries)
- [Chunking Results](#chunking-results)
- [Streaming Results Lazily](#streaming-results-lazily)
- [Aggregates](#aggregates)
- [Select Statements](#select-statements)
- [Raw Expressions](#raw-ex... | |
242842 | ## Running Database Queries
<a name="retrieving-all-rows-from-a-table"></a>
#### Retrieving All Rows From a Table
You may use the `table` method provided by the `DB` facade to begin a query. The `table` method returns a fluent query builder instance for the given table, allowing you to chain more constraints onto the... | |
242843 | ## Raw Expressions
Sometimes you may need to insert an arbitrary string into a query. To create a raw string expression, you may use the `raw` method provided by the `DB` facade:
$users = DB::table('users')
->select(DB::raw('count(*) as user_count, status'))
->where('status', '<>... | |
242844 | ## Basic Where Clauses
<a name="where-clauses"></a>
### Where Clauses
You may use the query builder's `where` method to add "where" clauses to the query. The most basic call to the `where` method requires three arguments. The first argument is the name of the column. The second argument is an operator, which can be a... | |
242845 | ### Additional Where Clauses
**whereLike / orWhereLike / whereNotLike / orWhereNotLike**
The `whereLike` method allows you to add "LIKE" clauses to your query for pattern matching. These methods provide a database-agnostic way of performing string matching queries, with the ability to toggle case-sensitivity. By defa... | |
242846 | ### Subquery Where Clauses
Sometimes you may need to construct a "where" clause that compares the results of a subquery to a given value. You may accomplish this by passing a closure and a value to the `where` method. For example, the following query will retrieve all users who have a recent "membership" of a given ty... | |
242852 | # Database: Migrations
- [Introduction](#introduction)
- [Generating Migrations](#generating-migrations)
- [Squashing Migrations](#squashing-migrations)
- [Migration Structure](#migration-structure)
- [Running Migrations](#running-migrations)
- [Rolling Back Migrations](#rolling-back-migrations)
- [Tables](#ta... | |
242854 | ## Tables
<a name="creating-tables"></a>
### Creating Tables
To create a new database table, use the `create` method on the `Schema` facade. The `create` method accepts two arguments: the first is the name of the table, while the second is a closure which receives a `Blueprint` object that may be used to define the n... | |
242857 | #### `timestamp()` {.collection-method}
The `timestamp` method creates a `TIMESTAMP` equivalent column with an optional fractional seconds precision:
$table->timestamp('added_at', precision: 0);
<a name="column-method-timestampsTz"></a>
#### `timestampsTz()` {.collection-method}
The `timestampsTz` method create... | |
242858 | ### Modifying Columns
The `change` method allows you to modify the type and attributes of existing columns. For example, you may wish to increase the size of a `string` column. To see the `change` method in action, let's increase the size of the `name` column from 25 to 50. To accomplish this, we simply define the new... | |
242859 | ## Indexes
<a name="creating-indexes"></a>
### Creating Indexes
The Laravel schema builder supports several types of indexes. The following example creates a new `email` column and specifies that its values should be unique. To create the index, we can chain the `unique` method onto the column definition:
use Il... | |
242863 | # Eloquent: Relationships
- [Introduction](#introduction)
- [Defining Relationships](#defining-relationships)
- [One to One / Has One](#one-to-one)
- [One to Many / Has Many](#one-to-many)
- [One to Many (Inverse) / Belongs To](#one-to-many-inverse)
- [Has One of Many](#has-one-of-many)
- [Has One ... | |
242864 | ## Defining Relationships
Eloquent relationships are defined as methods on your Eloquent model classes. Since relationships also serve as powerful [query builders](/docs/{{version}}/queries), defining relationships as methods provides powerful method chaining and querying capabilities. For example, we may chain additi... | |
242865 | ### One to Many (Inverse) / Belongs To
Now that we can access all of a post's comments, let's define a relationship to allow a comment to access its parent post. To define the inverse of a `hasMany` relationship, define a relationship method on the child model which calls the `belongsTo` method:
<?php
namesp... | |
242867 | ## Many to Many Relationships
Many-to-many relations are slightly more complicated than `hasOne` and `hasMany` relationships. An example of a many-to-many relationship is a user that has many roles and those roles are also shared by other users in the application. For example, a user may be assigned the role of "Autho... | |
242868 | ### Defining Custom Intermediate Table Models
If you would like to define a custom model to represent the intermediate table of your many-to-many relationship, you may call the `using` method when defining the relationship. Custom pivot models give you the opportunity to define additional behavior on the pivot model, ... | |
242869 | ### One to Many (Polymorphic)
<a name="one-to-many-polymorphic-table-structure"></a>
#### Table Structure
A one-to-many polymorphic relation is similar to a typical one-to-many relation; however, the child model can belong to more than one type of model using a single association. For example, imagine users of your a... | |
242870 | ### Many to Many (Polymorphic)
<a name="many-to-many-polymorphic-table-structure"></a>
#### Table Structure
Many-to-many polymorphic relations are slightly more complicated than "morph one" and "morph many" relationships. For example, a `Post` model and `Video` model could share a polymorphic relation to a `Tag` mode... | |
242871 | ## Querying Relations
Since all Eloquent relationships are defined via methods, you may call those methods to obtain an instance of the relationship without actually executing a query to load the related models. In addition, all types of Eloquent relationships also serve as [query builders](/docs/{{version}}/queries),... | |
242873 | ## Eager Loading
When accessing Eloquent relationships as properties, the related models are "lazy loaded". This means the relationship data is not actually loaded until you first access the property. However, Eloquent can "eager load" relationships at the time you query the parent model. Eager loading alleviates the ... | |
242874 | ### Lazy Eager Loading
Sometimes you may need to eager load a relationship after the parent model has already been retrieved. For example, this may be useful if you need to dynamically decide whether to load related models:
use App\Models\Book;
$books = Book::all();
if ($someCondition) {
$books-... | |
242875 | ## Inserting and Updating Related Models
<a name="the-save-method"></a>
### The `save` Method
Eloquent provides convenient methods for adding new models to relationships. For example, perhaps you need to add a new comment to a post. Instead of manually setting the `post_id` attribute on the `Comment` model you may in... | |
242877 | # Directory Structure
- [Introduction](#introduction)
- [The Root Directory](#the-root-directory)
- [The `app` Directory](#the-root-app-directory)
- [The `bootstrap` Directory](#the-bootstrap-directory)
- [The `config` Directory](#the-config-directory)
- [The `database` Directory](#the-database-directo... | |
242881 | ## Client Side Installation
<a name="client-reverb"></a>
### Reverb
[Laravel Echo](https://github.com/laravel/echo) is a JavaScript library that makes it painless to subscribe to channels and listen for events broadcast by your server-side broadcasting driver. You may install Echo via the NPM package manager. In this... | |
242883 | ## Defining Broadcast Events
To inform Laravel that a given event should be broadcast, you must implement the `Illuminate\Contracts\Broadcasting\ShouldBroadcast` interface on the event class. This interface is already imported into all event classes generated by the framework so you may easily add it to any of your ev... | |
242885 | ## Broadcasting Events
Once you have defined an event and marked it with the `ShouldBroadcast` interface, you only need to fire the event using the event's dispatch method. The event dispatcher will notice that the event is marked with the `ShouldBroadcast` interface and will queue the event for broadcasting:
use... | |
242891 | ## Laravel 11
Laravel 11 continues the improvements made in Laravel 10.x by introducing a streamlined application structure, per-second rate limiting, health routing, graceful encryption key rotation, queue testing improvements, [Resend](https://resend.com) mail transport, Prompt validator integration, new Artisan com... | |
242896 | # Service Providers
- [Introduction](#introduction)
- [Writing Service Providers](#writing-service-providers)
- [The Register Method](#the-register-method)
- [The Boot Method](#the-boot-method)
- [Registering Providers](#registering-providers)
- [Deferred Providers](#deferred-providers)
<a name="introduction"... | |
242897 | # Localization
- [Introduction](#introduction)
- [Publishing the Language Files](#publishing-the-language-files)
- [Configuring the Locale](#configuring-the-locale)
- [Pluralization Language](#pluralization-language)
- [Defining Translation Strings](#defining-translation-strings)
- [Using Short Keys](#... | |
242899 | # Service Container
- [Introduction](#introduction)
- [Zero Configuration Resolution](#zero-configuration-resolution)
- [When to Utilize the Container](#when-to-use-the-container)
- [Binding](#binding)
- [Binding Basics](#binding-basics)
- [Binding Interfaces to Implementations](#binding-interfaces-to-... | |
242900 | ## Binding
<a name="binding-basics"></a>
### Binding Basics
<a name="simple-bindings"></a>
#### Simple Bindings
Almost all of your service container bindings will be registered within [service providers](/docs/{{version}}/providers), so most of these examples will demonstrate using the container in that context.
Wi... | |
242901 | ### Contextual Attributes
Since contextual binding is often used to inject implementations of drivers or configuration values, Laravel offers a variety of contextual binding attributes that allow to inject these types of values without manually defining the contextual bindings in your service providers.
For example, ... | |
242902 | ## Resolving
<a name="the-make-method"></a>
### The `make` Method
You may use the `make` method to resolve a class instance from the container. The `make` method accepts the name of the class or interface you wish to resolve:
use App\Services\Transistor;
$transistor = $this->app->make(Transistor::class);
I... | |
242903 | # Mocking
- [Introduction](#introduction)
- [Mocking Objects](#mocking-objects)
- [Mocking Facades](#mocking-facades)
- [Facade Spies](#facade-spies)
- [Interacting With Time](#interacting-with-time)
<a name="introduction"></a>
## Introduction
When testing Laravel applications, you may wish to "mock" certain asp... | |
242906 | ## Available Methods
For the majority of the remaining collection documentation, we'll discuss each method available on the `Collection` class. Remember, all of these methods may be chained to fluently manipulate the underlying array. Furthermore, almost every method returns a new `Collection` instance, allowing you t... | |
242909 | #### `dump()` {.collection-method}
The `dump` method dumps the collection's items:
$collection = collect(['John Doe', 'Jane Doe']);
$collection->dump();
/*
Collection {
#items: array:2 [
0 => "John Doe"
1 => "Jane Doe"
]
}
*/
I... | |
242910 | #### `flatten()` {.collection-method}
The `flatten` method flattens a multi-dimensional collection into a single dimension:
$collection = collect([
'name' => 'taylor',
'languages' => [
'php', 'javascript'
]
]);
$flattened = $collection->flatten();
$flattened->all(... | |
242911 | #### `implode()` {.collection-method}
The `implode` method joins items in a collection. Its arguments depend on the type of items in the collection. If the collection contains arrays or objects, you should pass the key of the attributes you wish to join, and the "glue" string you wish to place between the values:
... | |
242917 | #### `splitIn()` {.collection-method}
The `splitIn` method breaks a collection into the given number of groups, filling non-terminal groups completely before allocating the remainder to the final group:
$collection = collect([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
$groups = $collection->splitIn(3);
$groups->a... | |
242918 | #### `unique()` {.collection-method}
The `unique` method returns all of the unique items in the collection. The returned collection keeps the original array keys, so in the following example we will use the [`values`](#method-values) method to reset the keys to consecutively numbered indexes:
$collection = collec... | |
242919 | #### `whenNotEmpty()` {.collection-method}
The `whenNotEmpty` method will execute the given callback when the collection is not empty:
$collection = collect(['michael', 'tom']);
$collection->whenNotEmpty(function (Collection $collection) {
return $collection->push('adam');
});
$collection->a... | |
242920 | #### `whereNull()` {.collection-method}
The `whereNull` method returns items from the collection where the given key is `null`:
$collection = collect([
['name' => 'Desk'],
['name' => null],
['name' => 'Bookcase'],
]);
$filtered = $collection->whereNull('name');
$filtered->all... | |
242921 | ## Lazy Collections
<a name="lazy-collection-introduction"></a>
### Introduction
> [!WARNING]
> Before learning more about Laravel's lazy collections, take some time to familiarize yourself with [PHP generators](https://www.php.net/manual/en/language.generators.overview.php).
To supplement the already powerful `Co... | |
242928 | # Authorization
- [Introduction](#introduction)
- [Gates](#gates)
- [Writing Gates](#writing-gates)
- [Authorizing Actions](#authorizing-actions-via-gates)
- [Gate Responses](#gate-responses)
- [Intercepting Gate Checks](#intercepting-gate-checks)
- [Inline Authorization](#inline-authorization)
- [... | |
242929 | ## Gates
<a name="writing-gates"></a>
### Writing Gates
> [!WARNING]
> Gates are a great way to learn the basics of Laravel's authorization features; however, when building robust Laravel applications you should consider using [policies](#creating-policies) to organize your authorization rules.
Gates are simply cl... | |
242930 | ## Creating Policies
<a name="generating-policies"></a>
### Generating Policies
Policies are classes that organize authorization logic around a particular model or resource. For example, if your application is a blog, you may have an `App\Models\Post` model and a corresponding `App\Policies\PostPolicy` to authorize u... | |
242931 | ## Writing Policies
<a name="policy-methods"></a>
### Policy Methods
Once the policy class has been registered, you may add methods for each action it authorizes. For example, let's define an `update` method on our `PostPolicy` which determines if a given `App\Models\User` can update a given `App\Models\Post` instanc... | |
242932 | ## Authorizing Actions Using Policies
<a name="via-the-user-model"></a>
### Via the User Model
The `App\Models\User` model that is included with your Laravel application includes two helpful methods for authorizing actions: `can` and `cannot`. The `can` and `cannot` methods receive the name of the action you wish to ... | |
242933 | ### Supplying Additional Context
When authorizing actions using policies, you may pass an array as the second argument to the various authorization functions and helpers. The first element in the array will be used to determine which policy should be invoked, while the rest of the array elements are passed as paramete... | |
242935 | ## Eloquent Model Conventions
Models generated by the `make:model` command will be placed in the `app/Models` directory. Let's examine a basic model class and discuss some of Eloquent's key conventions:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Flight extends Model
... | |
242937 | ## Retrieving Models
Once you have created a model and [its associated database table](/docs/{{version}}/migrations#generating-migrations), you are ready to start retrieving data from your database. You can think of each Eloquent model as a powerful [query builder](/docs/{{version}}/queries) allowing you to fluently q... | |
242938 | ### Advanced Subqueries
<a name="subquery-selects"></a>
#### Subquery Selects
Eloquent also offers advanced subquery support, which allows you to pull information from related tables in a single query. For example, let's imagine that we have a table of flight `destinations` and a table of `flights` to destinations. T... | |
242939 | ## Inserting and Updating Models
<a name="inserts"></a>
### Inserts
Of course, when using Eloquent, we don't only need to retrieve models from the database. We also need to insert new records. Thankfully, Eloquent makes it simple. To insert a new record into the database, you should instantiate a new model instance a... | |
242940 | ### Mass Assignment
You may use the `create` method to "save" a new model using a single PHP statement. The inserted model instance will be returned to you by the method:
use App\Models\Flight;
$flight = Flight::create([
'name' => 'London to Paris',
]);
However, before using the `create` method,... | |
242941 | ## Deleting Models
To delete a model, you may call the `delete` method on the model instance:
use App\Models\Flight;
$flight = Flight::find(1);
$flight->delete();
You may call the `truncate` method to delete all of the model's associated database records. The `truncate` operation will also reset any au... | |
242943 | ## Query Scopes
<a name="global-scopes"></a>
### Global Scopes
Global scopes allow you to add constraints to all queries for a given model. Laravel's own [soft delete](#soft-deleting) functionality utilizes global scopes to only retrieve "non-deleted" models from the database. Writing your own global scopes can provi... | |
242945 | # HTTP Redirects
- [Creating Redirects](#creating-redirects)
- [Redirecting To Named Routes](#redirecting-named-routes)
- [Redirecting To Controller Actions](#redirecting-controller-actions)
- [Redirecting With Flashed Session Data](#redirecting-with-flashed-session-data)
<a name="creating-redirects"></a>
## Creating... | |
242961 | ## Arrays & Objects
<a name="method-array-accessible"></a>
#### `Arr::accessible()` {.collection-method .first-collection-method}
The `Arr::accessible` method determines if the given value is array accessible:
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
$isAccessible = Arr::accessible... | |
242966 | aths
<a name="method-app-path"></a>
#### `app_path()` {.collection-method}
The `app_path` function returns the fully qualified path to your application's `app` directory. You may also use the `app_path` function to generate a fully qualified path to a file relative to the application directory:
$path = app_path(... | |
242967 | iscellaneous
<a name="method-abort"></a>
#### `abort()` {.collection-method}
The `abort` function throws [an HTTP exception](/docs/{{version}}/errors#http-exceptions) which will be rendered by the [exception handler](/docs/{{version}}/errors#handling-exceptions):
abort(403);
You may also provide the exception's... | |
242970 | `when()` {.collection-method}
The `when` function returns the value it is given if a given condition evaluates to `true`. Otherwise, `null` is returned. If a closure is passed as the second argument to the function, the closure will be executed and its returned value will be returned:
$value = when(true, 'Hello W... | |
242972 | # Validation
- [Introduction](#introduction)
- [Validation Quickstart](#validation-quickstart)
- [Defining the Routes](#quick-defining-the-routes)
- [Creating the Controller](#quick-creating-the-controller)
- [Writing the Validation Logic](#quick-writing-the-validation-logic)
- [Displaying the Validati... | |
242973 | ## Validation Quickstart
To learn about Laravel's powerful validation features, let's look at a complete example of validating a form and displaying the error messages back to the user. By reading this high-level overview, you'll be able to gain a good general understanding of how to validate incoming request data usi... | |
242975 | ## Form Request Validation
<a name="creating-form-requests"></a>
### Creating Form Requests
For more complex validation scenarios, you may wish to create a "form request". Form requests are custom request classes that encapsulate their own validation and authorization logic. To create a form request class, you may us... | |
242976 | ## Manually Creating Validators
If you do not want to use the `validate` method on the request, you may create a validator instance manually using the `Validator` [facade](/docs/{{version}}/facades). The `make` method on the facade generates a new validator instance:
<?php
namespace App\Http\Controllers;
... | |
242979 | #### alpha_num
The field under validation must be entirely Unicode alpha-numeric characters contained in [`\p{L}`](https://util.unicode.org/UnicodeJsps/list-unicodeset.jsp?a=%5B%3AL%3A%5D&g=&i=), [`\p{M}`](https://util.unicode.org/UnicodeJsps/list-unicodeset.jsp?a=%5B%3AM%3A%5D&g=&i=), and [`\p{N}`](https://util.unico... | |
242982 | #### prohibited
The field under validation must be missing or empty. A field is "empty" if it meets one of the following criteria:
<div class="content-list" markdown="1">
- The value is `null`.
- The value is an empty string.
- The value is an empty array or empty `Countable` object.
- The value is an uploaded file ... | |
242983 | #### unique:_table_,_column_
The field under validation must not exist within the given database table.
**Specifying a Custom Table / Column Name:**
Instead of specifying the table name directly, you may specify the Eloquent model which should be used to determine the table name:
'email' => 'unique:App\Models\U... | |
242986 | # Asset Bundling (Vite)
- [Introduction](#introduction)
- [Installation & Setup](#installation)
- [Installing Node](#installing-node)
- [Installing Vite and the Laravel Plugin](#installing-vite-and-laravel-plugin)
- [Configuring Vite](#configuring-vite)
- [Loading Your Scripts and Styles](#loading-your-scripts... | |
242987 | ## Installation & Setup
> [!NOTE]
> The following documentation discusses how to manually install and configure the Laravel Vite plugin. However, Laravel's [starter kits](/docs/{{version}}/starter-kits) already include all of this scaffolding and are the fastest way to get started with Laravel and Vite.
<a name="in... | |
242988 | ## Working With JavaScript
<a name="aliases"></a>
### Aliases
By default, The Laravel plugin provides a common alias to help you hit the ground running and conveniently import your application's assets:
```js
{
'@' => '/resources/js'
}
```
You may overwrite the `'@'` alias by adding your own to the `vite.config... | |
242989 | ## Working With Blade and Routes
<a name="blade-processing-static-assets"></a>
### Processing Static Assets With Vite
When referencing assets in your JavaScript or CSS, Vite automatically processes and versions them. In addition, when building Blade based applications, Vite can also process and version static assets ... | |
243000 | ## Handling Paddle Webhooks
Paddle can notify your application of a variety of events via webhooks. By default, a route that points to Cashier's webhook controller is registered by the Cashier service provider. This controller will handle all incoming webhook requests.
By default, this controller will automatically h... | |
243001 | ## Transactions
You may easily retrieve an array of a billable model's transactions via the `transactions` property:
use App\Models\User;
$user = User::find(1);
$transactions = $user->transactions;
Transactions represent payments for your products and purchases and are accompanied by invoices. Only com... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.