• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Laravel 8 factory state afterCreating

phplaravellaravel-7laravel-8


PHP Snippet 1:

public function active()
{
    return $this->state(function (array $attributes) {
        return [
            'active' => true,
        ];
    })->afterCreating(function (User $user) {
        // ...
    });
}

PHP Snippet 2:

public function active()
    {
        return $this->state([
            'active' => true,
        ])->afterCreating(function (Article $user) {
            // ...
        });
    }

PHP Snippet 3:

    public function configure()
    {
        return $this->afterCreating(function (User $user) {
            //
        });
    }

Related Snippets

dockerizing Laravel + vue

How can i hide dt if dd got empty value

how to see if database exists with PDO [duplicate]

Cache clear probem in Larave

GuzzleHttp Hangs When Using Localhost

MySQL - Connection failed: No route to host

I need to link Google Sheet with my Laravel

"There is no active transaction" when refreshing database in Laravel 8.0 test

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

Failing validation doesn't stop code execution in livewire component

add uri parameter to Route name in laravel

How to get unique slug to same post-title for other time too?

Check if my GET request has Header: Token

Sum column values from multiple arrays

Can't find vendor/autoload.php for Ratchet

About Contact Privacy policy Terms and conditions