alirezasedghi/laravel-image-faker

A library to generate fake images for Laravel

v1.0 2023-05-04 18:30 UTC

This package is auto-updated.

Last update: 2024-10-31 00:20:06 UTC


README

Required PHP Version Total Downloads Latest Stable Version Latest Stable Version License GitHub issues

Description

Laravel Image Faker is an alternative image provider for FakerPHP.

Installation

composer require alirezasedghi/laravel-image-faker

Resources

The following sources are utilized by this project to create random images:

Methods

Usage

/**
 * Define the model's default state.
 *
 * @return array<string, mixed>
 */
public function definition(): array
{
    /**
     * In order to utilize other services, the following substitutes can be used: 
     *  - new ImageFaker(new LoremFlickr()); 
     *  - new ImageFaker(new PlaceDog()); 
     *  - new ImageFaker(new Kittens()); 
     *  - new ImageFaker(new FakePeople()); 
     */
    $imageFaker = new ImageFaker(new Picsum());
    
    return [
        'title' => $this->faker->sentence(),
        'content' => $this->faker->paragraph(),
        'attachments' => $imageFaker->image( storage_path("app/attachments/") )
    ];
}

Contributing

Don't hesitate to send a PR if you're looking for a service that's not available in this package. 😁

License

The MIT License (MIT). Please see License File for more information.