rentalmanager/amenities

租赁管理器设施包,可以推动基本系统,您可以在此管理出租的房产。

v2.0.1 2018-09-11 20:11 UTC

This package is auto-updated.

Last update: 2024-09-12 09:36:56 UTC


README

为Rentbits创建的包,用于简化租赁列表的管理和维护,并确保模块化。它包括所有迁移、模型和关系,以运行租赁系统。

安装、配置和使用

安装

通过Composer

composer require rentalmanager/amenities

配置

一旦安装了该包,它应该会被Laravel自动发现。要检查这一点,请在您的终端中简单地运行

$ php artisan

在那里您应该找到所有的 rm:* 命令。

检查后的第一步是发布供应商

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

之后,这取决于您。如果您是勤奋的学习者,可以手动运行每个命令,但之后您只需简单地运行

$ php artisan rm:setup-amenities

就是这样...

$ composer dump-autoload

您可以在DB seeder中添加seeder类,如下所示

$this->call(RentalManagerAmenitiesSeeder::class);

或者通过直接调用运行seeder

$ php artisan db:seed --class=RentalManagerAmenitiesSeeder 

使用方法

以下是该包的示例用法

将单个设施附加到单元或房产(同样适用)

$object->attachAmenity(1);

附加多个设施

$object->attachAmenities([1,2,3]);

还有通用的同步方法

$object->syncAmenities([1,2,3]);

不分离

$object->syncAmenitiesWithoutDetaching([1,2,3]);

作用域

此包为amenitable对象提供可用的作用域

// get all objects where amenities are
$result = $object->whereAmenitiesAre([1,2,3]);

并为设施模型本身提供一些作用域

$amenities = Amenity::byGroup('notable');

$amenities = Amenity::byType('unit');

// disctinct by groups
$groups = Amenity::groups();

$types = Amenity::types();