rentalmanager/photos 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

rentalmanager/photos

Composer 安装命令:

composer require rentalmanager/photos

包简介

Rental Manager Photos package which propels the basic system where you can manage properties for rent.

README 文档

README

A package made for Rentbits for easier maintenance and modularity of managing rental listings. It includes all migrations, models and relations to run the rental system.

This package uses Image Intervention library and league flysystem packages for Rackspace, SFTP and AWS access. So you do not need to install them on your app directly.

Installation, Configuration and Usage

Installation

Via Composer

composer require rentalmanager/photos

Configuration

Once you install the package, it should be automatically discovered by the Laravel. To check this, in your terminal simply run the:

$ php artisan

There you should find the all rm:* commands.

First step after checking is to publish the vendors:

$ php artisan vendor:publish --tag="photos"

You can setup the thumbnail sizes, default disk etc in the config file.

After that it depends on you. If you are a hard learner, run through each commands manually, but then you can just simply run the

$ php artisan rm:setup-photos

Thats it...

Usage

This package is used to store the photos in a separate table. It adds the trait to the property and unit to bind the relation as well.

Storing the photo

You can store the photo in usual way, using Eloquent ORM.

$photo = new Photo([...]);
$photo->save();

When you store the photo with usual way you can associate the property like this

$property->attachPhoto(1, 10); 

Where the first param is the ID of the photo, and the second is the ORDERING number.

or you can easily detach the photo(s) of the property

$property->detachPhoto(1);

// or
$property->detachPhotos([1,2,3]);

Because we added the Trait to the Property and Unit model, you can fetch the photos object via

$photos = $object->getOrderedPhotos();

The above method will return the photos by the order you gave them.

To sync the photos you will need to use the following method

$object->syncPhotos($photos);

The $photos is the array of photo ID's. Please note that the order of id's will eventually be used for ordering. Which generally means if you provide an array [1,3,10,2] - photos will be displayed in this order.

Facade

This package provides great methods for easy photo manipulation.

(First of you need to use the Facade as )

use RentalManager\Photos\Facades\Photos;

in your class.

You can utilize the following methods

Automatic image path recovery

If you are storing the external image, you'll need to get a info for storing the path and whatever. Luckily this package provides an easy wrapper to do exactly this.

$url = 'https://media.equityapartments.com/images/c_crop,x_0,y_0,w_1920,h_1080/c_fill,w_1920,h_1080/q_80/4206-28/the-kelvin-apartments-exterior.jpg';

$photoElements = Photos::parseExternalPhoto($url);

dump( $photoElements);

Of course you can initiate the thumbnail generator as well

$photo = Photo::find(1);

$photo = Photos::generateThumbnails($photo);

Or if you just want to store the original image to the Storage and deal with thumbnails later on:

$photo = Photos::upload($path_to_image);

Or if you want to upload and generate thumbnails automagically

$photo = Photos::upload($path_to_image, false, true); // the last param is thumbnail generator

Also you can provide your path like:

$photo = Photos::upload($path_to_image, 'store/there/instead');

Or you can generate the auto path env/properties/{random}

$path = Photos::generatePath($id = false);

Thats it folks.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2018-08-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固