bhavin-gajjar/laravel-coder-lora-train huggingface dataset:
[Laravel 11] Explain scheduling: Scheduling Artisan Commands

In addition to scheduling closures, you may also schedule Artisan commands and system commands. For example, you may use the command method to schedule an Artisan command using either the command's name or class.

When scheduling Artisan commands using the command's class name, you may pass an array of additional command-line arguments that should be provided to the command when it is invoked:

    use App\Console\Commands\SendEmailsCommand;
    use Illuminate\Support\Facades\Schedule;

    Schedule::command('emails:send Taylor --force')->daily();

    Schedule::command(SendEmailsCommand::class, ['Taylor', '--force'])->daily();

<a name="scheduling-artisan-closure-commands"></a>
[Laravel 11] Explain scheduling: Scheduling Artisan Closure Commands

If you want to schedule an Artisan command defined by a closure, you may chain the scheduling related methods after the command's definition:

    Artisan::command('delete:recent-users', function () {
        DB::table('recent_users')->delete();
    })->purpose('Delete recent users')->daily();

If you need to pass arguments to the closure command, you may provide them to the schedule method:

    Artisan::command('emails:send {user} {--force}', function ($user) {
        // ...
    })->purpose('Send emails to the specified user')->schedule(['Taylor', '--force'])->daily();

<a name="scheduling-queued-jobs"></a>
[Laravel 11] Explain scout: Laravel Scout

- Introduction
- Installation
    - Queueing
- Driver Prerequisites
    - Algolia
    - Meilisearch
    - Typesense
- Configuration
    - Configuring Model Indexes
    - Configuring Searchable Data
    - Configuring the Model ID
    - Configuring Search Engines per Model
    - Identifying Users
- Database / Collection Engines
    - Database Engine
    - Collection Engine
- Indexing
    - Batch Import
    - Adding Records
    - Updating Records
    - Removing Records
    - Pausing Indexing
    - Conditionally Searchable Model Instances
- Searching
    - Where Clauses
    - Pagination
    - Soft Deleting
    - Customizing Engine Searches
- Custom Engines

<a name="introduction"></a>
[Laravel 11] Explain scout: Introduction

Laravel Scout provides a simple, driver based solution for adding full-text search to your Eloquent models. Using model observers, Scout will automatically keep your search indexes in sync with your Eloquent records.

Currently, Scout ships with Algolia, Meilisearch, Typesense, and MySQL / PostgreSQL (database) drivers. In addition, Scout includes a "collection" driver that is designed for local development usage and does not require any external dependencies or third-party services. Furthermore, writing custom drivers is simple and you are free to extend Scout with your own search implementations.

<a name="installation"></a>
[Laravel 11] Explain scout: Installation

First, install Scout via the Composer package manager:

After installing Scout, you should publish the Scout configuration file using the vendor:publish Artisan command. This command will publish the scout.php configuration file to your application's config directory:

Finally, add the Laravel\Scout\Searchable trait to the model you would like to make searchable. This trait will register a model observer that will automatically keep the model in sync with your search driver:

    <?php

    namespace App\Models;

    use Illuminate\Database\Eloquent\Model;
    use Laravel\Scout\Searchable;

    class Post extends Model
    {
        use Searchable;
    }

<a name="queueing"></a>
[Laravel 11] Explain scout: Queueing

While not strictly required to use Scout, you should strongly consider configuring a queue driver before using the library. Running a queue worker will allow Scout to queue all operations that sync your model information to your search indexes, providing much better response times for your application's web interface.

Once you have configured a queue driver, set the value of the queue option in your config/scout.php configuration file to true:

    'queue' => true,

Even when the queue option is set to false, it's important to remember that some Scout drivers like Algolia and Meilisearch always index records asynchronously. Meaning, even though the index operation has completed within your Laravel application, the search engine itself may not reflect the new and updated records immediately.

To specify the connection and queue that your Scout jobs utilize, you may define the queue configuration option as an array:

    'queue' => [
        'connection' => 'redis',
        'queue' => 'scout'
    ],

Of course, if you customize the connection and queue that Scout jobs utilize, you should run a queue worker to process jobs on that connection and queue:

    php artisan queue:work redis --queue=scout

<a name="driver-prerequisites"></a>
[Laravel 11] Explain seeding: Introduction

Laravel includes the ability to seed your database with data using seed classes. All seed classes are stored in the database/seeders directory. By default, a DatabaseSeeder class is defined for you. From this class, you may use the call method to run other seed classes, allowing you to control the seeding order.

> [!NOTE]  
> Mass assignment protection is automatically disabled during database seeding.

<a name="writing-seeders"></a>
[Laravel 11] Explain seeding: Writing Seeders

To generate a seeder, execute the make:seeder Artisan command. All seeders generated by the framework will be placed in the database/seeders directory:

A seeder class only contains one method by default: run. This method is called when the db:seed Artisan command is executed. Within the run method, you may insert data into your database however you wish. You may use the query builder to manually insert data or you may use Eloquent model factories.

As an example, let's modify the default DatabaseSeeder class and add a database insert statement to the run method:

    <?php

    namespace Database\Seeders;

    use Illuminate\Database\Seeder;
    use Illuminate\Support\Facades\DB;
    use Illuminate\Support\Facades\Hash;
    use Illuminate\Support\Str;

    class DatabaseSeeder extends Seeder
    {
        /**
         * Run the database seeders.
         */
        public function run(): void
        {
            DB::table('users')->insert([
                'name' => Str::random(10),
                'email' => Str::random(10).'@example.com',
                'password' => Hash::make('password'),
            ]);
        }
    }

> [!NOTE]  
> You may type-hint any dependencies you need within the run method's signature. They will automatically be resolved via the Laravel service container.

<a name="using-model-factories"></a>
[Laravel 11] Explain seeding: Using Model Factories

Of course, manually specifying the attributes for each model seed is cumbersome. Instead, you can use model factories to conveniently generate large amounts of database records. First, review the model factory documentation to learn how to define your factories.

For example, let's create 50 users that each has one related post:

    use App\Models\User;

    /**
     * Run the database seeders.
     */
    public function run(): void
    {
        User::factory()
            ->count(50)
            ->hasPosts(1)
            ->create();
    }

<a name="calling-additional-seeders"></a>
[Laravel 11] Explain seeding: Calling Additional Seeders

Within the DatabaseSeeder class, you may use the call method to execute additional seed classes. Using the call method allows you to break up your database seeding into multiple files so that no single seeder class becomes too large. The call method accepts an array of seeder classes that should be executed:

    /**
     * Run the database seeders.
     */
    public function run(): void
    {
        $this->call([
            UserSeeder::class,
            PostSeeder::class,
            CommentSeeder::class,
        ]);
    }

<a name="muting-model-events"></a>
[Laravel 11] Explain session: HTTP Session

- Introduction
    - Configuration
    - Driver Prerequisites
- Interacting With the Session
    - Retrieving Data
    - Storing Data
    - Flash Data
    - Deleting Data
    - Regenerating the Session ID
- Session Blocking
- Adding Custom Session Drivers
    - Implementing the Driver
    - Registering the Driver

<a name="introduction"></a>
[Laravel 11] Explain session: Configuration

Your application's session configuration file is stored at config/session.php. Be sure to review the options available to you in this file. By default, Laravel is configured to use the database session driver.

The session driver configuration option defines where session data will be stored for each request. Laravel includes a variety of drivers:

<div class="content-list" markdown="1">

- file - sessions are stored in storage/framework/sessions.
- cookie - sessions are stored in secure, encrypted cookies.
- database - sessions are stored in a relational database.
- memcached / redis - sessions are stored in one of these fast, cache based stores.
- dynamodb - sessions are stored in AWS DynamoDB.
- array - sessions are stored in a PHP array and will not be persisted.

</div>

> [!NOTE]  
> The array driver is primarily used during testing and prevents the data stored in the session from being persisted.

<a name="driver-prerequisites"></a>
[Laravel 11] Explain session: Database

When using the database session driver, you will need to ensure that you have a database table to contain the session data. Typically, this is included in Laravel's default 0001_01_01_000000_create_users_table.php database migration; however, if for any reason you do not have a sessions table, you may use the make:session-table Artisan command to generate this migration:

<a name="redis"></a>
[Laravel 11] Explain session: Redis

Before using Redis sessions with Laravel, you will need to either install the PhpRedis PHP extension via PECL or install the predis/predis package (~1.0) via Composer. For more information on configuring Redis, consult Laravel's Redis documentation.

> [!NOTE]  
> The SESSION_CONNECTION environment variable, or the connection option in the session.php configuration file, may be used to specify which Redis connection is used for session storage.

<a name="interacting-with-the-session"></a>
[Laravel 11] Explain socialite: Introduction

In addition to typical, form based authentication, Laravel also provides a simple, convenient way to authenticate with OAuth providers using Laravel Socialite. Socialite currently supports authentication via Facebook, X, LinkedIn, Google, GitHub, GitLab, Bitbucket, and Slack.

> [!NOTE]  
> Adapters for other platforms are available via the community driven Socialite Providers website.

<a name="installation"></a>
[Laravel 11] Explain socialite: Configuration

Before using Socialite, you will need to add credentials for the OAuth providers your application utilizes. Typically, these credentials may be retrieved by creating a "developer application" within the dashboard of the service you will be authenticating with.

These credentials should be placed in your application's config/services.php configuration file, and should use the key facebook, x, linkedin-openid, google, github, gitlab, bitbucket, slack, or slack-openid, depending on the providers your application requires:

    'github' => [
        'client_id' => env('GITHUB_CLIENT_ID'),
        'client_secret' => env('GITHUB_CLIENT_SECRET'),
        'redirect' => 'http://example.com/callback-url',
    ],

> [!NOTE]  
> If the redirect option contains a relative path, it will automatically be resolved to a fully qualified URL.

<a name="authentication"></a>
[Laravel 11] Explain starter kits: Introduction

To give you a head start building your new Laravel application, we are happy to offer authentication and application starter kits. These kits automatically scaffold your application with the routes, controllers, and views you need to register and authenticate your application's users.

While you are welcome to use these starter kits, they are not required. You are free to build your own application from the ground up by simply installing a fresh copy of Laravel. Either way, we know you will build something great!

<a name="laravel-breeze"></a>
[Laravel 11] Explain starter kits: Laravel Breeze

Laravel Breeze is a minimal, simple implementation of all of Laravel's authentication features, including login, registration, password reset, email verification, and password confirmation. In addition, Breeze includes a simple "profile" page where the user may update their name, email address, and password.

Laravel Breeze's default view layer is made up of simple Blade templates styled with Tailwind CSS. Additionally, Breeze provides scaffolding options based on Livewire or Inertia, with the choice of using Vue or React for the Inertia-based scaffolding.

<img src="https://laravel.com/img/docs/breeze-register.png">
[Laravel 11] Explain starter kits: Installation

First, you should create a new Laravel application. If you create your application using the Laravel installer, you will be prompted to install Laravel Breeze during the installation process. Otherwise, you will need to follow the manual installation instructions below.

If you have already created a new Laravel application without a starter kit, you may manually install Laravel Breeze using Composer:

After Composer has installed the Laravel Breeze package, you should run the breeze:install Artisan command. This command publishes the authentication views, routes, controllers, and other resources to your application. Laravel Breeze publishes all of its code to your application so that you have full control and visibility over its features and implementation.

The breeze:install command will prompt you for your preferred frontend stack and testing framework:

<a name="breeze-and-blade"></a>
[Laravel 11] Explain strings: Available Methods

<style>
    .collection-method-list > p {
        columns: 10.8em 3; -moz-columns: 10.8em 3; -webkit-columns: 10.8em 3;
    }

    .collection-method-list a {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
</style>

<a name="strings-method-list"></a>
[Laravel 11] Explain strings: Strings

<div class="collection-method-list" markdown="1">

\__
class_basename
e
preg_replace_array
Str::after
Str::afterLast
Str::apa
Str::ascii
Str::before
Str::beforeLast
Str::between
Str::betweenFirst
Str::camel
Str::charAt
Str::chopStart
Str::chopEnd
Str::contains
Str::containsAll
Str::doesntContain
Str::deduplicate
Str::endsWith
Str::excerpt
Str::finish
Str::headline
Str::inlineMarkdown
Str::is
Str::isAscii
Str::isJson
Str::isUlid
Str::isUrl
Str::isUuid
Str::kebab
Str::lcfirst
Str::length
Str::limit
Str::lower
Str::markdown
Str::mask
Str::orderedUuid
Str::padBoth
Str::padLeft
Str::padRight
Str::password
Str::plural
Str::pluralStudly
Str::position
Str::random
Str::remove
Str::repeat
Str::replace
Str::replaceArray
Str::replaceFirst
Str::replaceLast
Str::replaceMatches
Str::replaceStart
Str::replaceEnd
Str::reverse
Str::singular
Str::slug
Str::snake
Str::squish
Str::start
Str::startsWith
Str::studly
Str::substr
Str::substrCount
Str::substrReplace
Str::swap
Str::take
Str::title
Str::toBase64
Str::transliterate
Str::trim
Str::ltrim
Str::rtrim
Str::ucfirst
Str::ucsplit
Str::upper
Str::ulid
Str::unwrap
Str::uuid
Str::wordCount
Str::wordWrap
Str::words
Str::wrap
str
trans
trans_choice

</div>

<a name="fluent-strings-method-list"></a>
[Laravel 11] Explain strings: Fluent Strings

<div class="collection-method-list" markdown="1">

after
afterLast
apa
append
ascii
basename
before
beforeLast
between
betweenFirst
camel
charAt
classBasename
chopStart
chopEnd
contains
containsAll
deduplicate
dirname
endsWith
exactly
excerpt
explode
finish
headline
inlineMarkdown
is
isAscii
isEmpty
isNotEmpty
isJson
isUlid
isUrl
isUuid
kebab
lcfirst
length
limit
lower
markdown
mask
match
matchAll
isMatch
newLine
padBoth
padLeft
padRight
pipe
plural
position
prepend
remove
repeat
replace
replaceArray
replaceFirst
replaceLast
replaceMatches
replaceStart
replaceEnd
scan
singular
slug
snake
split
squish
start
startsWith
stripTags
studly
substr
substrReplace
swap
take
tap
test
title
toBase64
toHtmlString
transliterate
trim
ltrim
rtrim
ucfirst
ucsplit
unwrap
upper
when
whenContains
whenContainsAll
whenEmpty
whenNotEmpty
whenStartsWith
whenEndsWith
whenExactly
whenNotExactly
whenIs
whenIsAscii
whenIsUlid
whenIsUuid
whenTest
wordCount
words
wrap

</div>

<a name="strings"></a>
[Laravel 11] Explain strings: `__()` {.collection-method}

The __ function translates the given translation string or translation key using your language files:

    echo __('Welcome to our application');

    echo __('messages.welcome');

If the specified translation string or key does not exist, the __ function will return the given value. So, using the example above, the __ function would return messages.welcome if that translation key does not exist.

<a name="method-class-basename"></a>
[Laravel 11] Explain structure: Directory Structure

- Introduction
- The Root Directory
    - The app Directory
    - The bootstrap Directory
    - The config Directory
    - The database Directory
    - The public Directory
    - The resources Directory
    - The routes Directory
    - The storage Directory
    - The tests Directory
    - The vendor Directory
- The App Directory
    - The Broadcasting Directory
    - The Console Directory
    - The Events Directory
    - The Exceptions Directory
    - The Http Directory
    - The Jobs Directory
    - The Listeners Directory
    - The Mail Directory
    - The Models Directory
    - The Notifications Directory
    - The Policies Directory
    - The Providers Directory
    - The Rules Directory

<a name="introduction"></a>
[Laravel 11] Explain structure: Introduction

The default Laravel application structure is intended to provide a great starting point for both large and small applications. But you are free to organize your application however you like. Laravel imposes almost no restrictions on where any given class is located - as long as Composer can autoload the class.

> [!NOTE]  
> New to Laravel? Check out the Laravel Bootcamp for a hands-on tour of the framework while we walk you through building your first Laravel application.

<a name="the-root-directory"></a>
[Laravel 11] Explain telescope: Laravel Telescope

- Introduction
- Installation
    - Local Only Installation
    - Configuration
    - Data Pruning
    - Dashboard Authorization
- Upgrading Telescope
- Filtering
    - Entries
    - Batches
- Tagging
- Available Watchers
    - Batch Watcher
    - Cache Watcher
    - Command Watcher
    - Dump Watcher
    - Event Watcher
    - Exception Watcher
    - Gate Watcher
    - HTTP Client Watcher
    - Job Watcher
    - Log Watcher
    - Mail Watcher
    - Model Watcher
    - Notification Watcher
    - Query Watcher
    - Redis Watcher
    - Request Watcher
    - Schedule Watcher
    - View Watcher
- Displaying User Avatars

<a name="introduction"></a>
[Laravel 11] Explain telescope: Installation

You may use the Composer package manager to install Telescope into your Laravel project:

After installing Telescope, publish its assets and migrations using the telescope:install Artisan command. After installing Telescope, you should also run the migrate command in order to create the tables needed to store Telescope's data:

Finally, you may access the Telescope dashboard via the /telescope route.

<a name="local-only-installation"></a>
[Laravel 11] Explain telescope: Local Only Installation

If you plan to only use Telescope to assist your local development, you may install Telescope using the --dev flag:

After running telescope:install, you should remove the TelescopeServiceProvider service provider registration from your application's bootstrap/providers.php configuration file. Instead, manually register Telescope's service providers in the register method of your App\Providers\AppServiceProvider class. We will ensure the current environment is local before registering the providers:

    /**
     * Register any application services.
     */
    public function register(): void
    {
        if ($this->app->environment('local') && class_exists(\Laravel\Telescope\TelescopeServiceProvider::class)) {
            $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
            $this->app->register(TelescopeServiceProvider::class);
        }
    }

Finally, you should also prevent the Telescope package from being auto-discovered by adding the following to your composer.json file:

<a name="configuration"></a>
[Laravel 11] Explain telescope: Configuration

After publishing Telescope's assets, its primary configuration file will be located at config/telescope.php. This configuration file allows you to configure your watcher options. Each configuration option includes a description of its purpose, so be sure to thoroughly explore this file.

If desired, you may disable Telescope's data collection entirely using the enabled configuration option:

    'enabled' => env('TELESCOPE_ENABLED', true),

<a name="data-pruning"></a>
[Laravel 11] Explain testing: Introduction

Laravel is built with testing in mind. In fact, support for testing with Pest and PHPUnit is included out of the box and a phpunit.xml file is already set up for your application. The framework also ships with convenient helper methods that allow you to expressively test your applications.

By default, your application's tests directory contains two directories: Feature and Unit. Unit tests are tests that focus on a very small, isolated portion of your code. In fact, most unit tests probably focus on a single method. Tests within your "Unit" test directory do not boot your Laravel application and therefore are unable to access your application's database or other framework services.

Feature tests may test a larger portion of your code, including how several objects interact with each other or even a full HTTP request to a JSON endpoint. **Generally, most of your tests should be feature tests. These types of tests provide the most confidence that your system as a whole is functioning as intended.**

An ExampleTest.php file is provided in both the Feature and Unit test directories. After installing a new Laravel application, execute the vendor/bin/pest, vendor/bin/phpunit, or php artisan test commands to run your tests.

<a name="environment"></a>
[Laravel 11] Explain testing: Environment

When running tests, Laravel will automatically set the configuration environment to testing because of the environment variables defined in the phpunit.xml file. Laravel also automatically configures the session and cache to the array driver so that no session or cache data will be persisted while testing.

You are free to define other testing environment configuration values as necessary. The testing environment variables may be configured in your application's phpunit.xml file, but make sure to clear your configuration cache using the config:clear Artisan command before running your tests!

<a name="the-env-testing-environment-file"></a>
[Laravel 11] Explain testing: Creating Tests

To create a new test case, use the make:test Artisan command. By default, tests will be placed in the tests/Feature directory:

If you would like to create a test within the tests/Unit directory, you may use the --unit option when executing the make:test command:

> [!NOTE]  
> Test stubs may be customized using stub publishing.

Once the test has been generated, you may define test as you normally would using Pest or PHPUnit. To run your tests, execute the vendor/bin/pest, vendor/bin/phpunit, or php artisan test command from your terminal:

> [!WARNING]  
> If you define your own setUp / tearDown methods within a test class, be sure to call the respective parent::setUp() / parent::tearDown() methods on the parent class. Typically, you should invoke parent::setUp() at the start of your own setUp method, and parent::tearDown() at the end of your tearDown method.

<a name="running-tests"></a>