定制 bnhashem/file 二次开发

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

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

bnhashem/file

Composer 安装命令:

composer require bnhashem/file

包简介

CRUD File From Any Section

README 文档

README

Issues

Forks

Stars

License

Twitter

Installing File Package

The recommended way to install File Package is through Composer.

composer require bnhashem/file

Storage Link

Creating Shourtcut of storage folder , you will found shortcut by following this path your-project/public

php artisan storage:link

Updating your Provider Array

you should Go to config\app.php , in Provider array you should put this Line:

'providers' => [
        /*
         * Laravel Framework Service Providers...
         */
         Bnhashem\File\FileServiceProvider::class,
    ],

Store File

    use Bnhashem\File\Traits\File;


    public function store(Request $request)
    {
        $post = new Post([
            'image'     => File::store('posts' , 'image'),
            'banner'    => File::store('posts' , 'banner'),
        ]);
        $post->save();

        // posts is the parent Folder 
        // image and banner are the childs Folders
        // image and banner also request name , that mean image or banner is required.
    }

Update File

In update Model function:

  • If $request->image or $request->banner is Equal null , that mean Nothing Will Not happen
  • If $request->image or $request->banner is Not Equal null , that mean image or banner will removed from Database and Server and store New image that will comming From request
    use Bnhashem\File\Traits\File;


    public function update(Request $request , Post $post)
    {
        $post->update([
            'image'  = File::update('posts' , 'image' , $post),
            'banner' = File::update('posts' , 'banner' , $post),
        ]);

        // posts are the parent Folder 
        // image and banner are the childs Folders
        // image and banner also request name , that mean image or banner is required.
        // You should pass Row to function
    }

Destroy File

In destroy Model function: File will removed From Database and also will Removed from server.

    use Bnhashem\File\Traits\File;


    public function destroy(Request $request , Post $post)
    {
        File::destroy('image' , $post);
        File::destroy('banner' , $post);

        // You should pass Row to function
    }

How to get file

For Example if you upload photo , you will find it According to this path :

    <img src="{{ url('storage/'.$post->image) }}" >

    <img src="{{ url('storage/'.$post->banner) }}" >

统计信息

  • 总下载量: 69
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固