定制 alirezasedghi/laravel-image-faker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alirezasedghi/laravel-image-faker

最新稳定版本:v1.0

Composer 安装命令:

composer require alirezasedghi/laravel-image-faker

包简介

A library to generate fake images for Laravel

README 文档

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

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.

统计信息

  • 总下载量: 17.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 7
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知