Skip to content

Latest commit

 

History

History
65 lines (55 loc) · 3.06 KB

readme.md

File metadata and controls

65 lines (55 loc) · 3.06 KB

Laravel Image Faker

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

Code Description
(new ImageFaker(new Service()))->imageUrl() Return a random image url from the specified service
(new ImageFaker(new Service()))->image() Download a random image from the specified service

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.