Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.0.1'
Browse files Browse the repository at this point in the history
* release/v0.0.1: (26 commits)
  Commit first tagged release
  Rename package rinvex/bookings from rinvex/bookable
  Fix wrong table name (close #6)
  Update composer dependencies
  Update composer dependencies
  Disable travis email notifications
  Update composer dependencies
  Override ValidatingTrait & HasTranslations Trait
  Fix wrong booking availability database table name
  Program to an interface not implementation for flexible model swapping
  Update models docblock
  Tweak service provider and enforce consistency
  Apply fixes from StyleCI
  Bind model alias into IoC container
  Apply fixes from StyleCI
  Use IoC bound model instead of the explicitly hardcoded
  Add configurable model names
  Add migration command and simplify installation steps
  Add composer minimum stability option
  Enforce consistant morph table schema
  ...
  • Loading branch information
Omranic committed Sep 8, 2017
2 parents 1de4c1e + de1891f commit 75befcf
Show file tree
Hide file tree
Showing 22 changed files with 497 additions and 155 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -21,6 +21,7 @@ after_script:
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

notifications:
email: false
slack:
rooms:
- secure: Hg2CC8CZg61cdG6ue+2BbhlTjwdYPkZT4//xLWfyy1hsQWbhSV3OfcbxWDCFgPWfYvkXSthXn6BloJG/+H5QSbH9ByLIRKGe7VsNhsI0YNE2uLc9dh9sDgS8hdNPcUiOq7wBn0A4/54+NOT4KOFccR9yEXxONoOKykeH8XZMJjRjcQtTc30JjyqBDIJgi74oKhwXOIz09C5fGMJ7iurQFq5IXfIAgYlrukjRSHnOMa1/7xpMzU6a5SYGzrQ84wOtrAzA7+Ia6NDWatRXYLQ2EyBk14lDkSvwPPsZ2IyAf7hCT+FP2Yp+kZA30yr3l5cA/ZPsBB26BzhlaQ8x3BaD/UiKKaieNQC+RHZ9DnQXzqOGf17WvPnuLPLyClygrjd7yrv8MN0JEuXRFBbZjYzaI5ORqOSottCC5znWHofmxk2kpORV5SFhR1F+Oab+q9rW0L9O5YpPv5mW1mUj5ngz013xjtoffY3lCzZ61n2zhq3MBVpYV8vDk2cV9ek5clBzp8AZx45LO6YWuAHqfIrhcDyx42ivo3kzRrzf6jYJbJcn0wyVEUykS5K2K1HgazGpOi8Pc0NzpkitGN418qqSsWPJwOTeoJfOMW06XUlx95fsBnj4B9eaXpDzyWbBN/o4aeVyouJv/+D3EdCCAjzMW0IXKAVr9DEBRC8+ZHSgm/Y=
6 changes: 3 additions & 3 deletions CHANGELOG.md
@@ -1,9 +1,9 @@
# Rinvex Bookable Change Log
# Rinvex Bookings Change Log

All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](CONTRIBUTING.md).


## v0.0.1 - 2017-07-07
- Commit first draft
## v0.0.1 - 2017-09-08
- Commit first tagged release
55 changes: 20 additions & 35 deletions README.md
@@ -1,64 +1,49 @@
# Rinvex Bookable
# Rinvex Bookings

**Rinvex Bookable** is a generic resource booking system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
**Rinvex Bookings** is a generic resource booking system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.

[![Packagist](https://img.shields.io/packagist/v/rinvex/bookable.svg?label=Packagist&style=flat-square)](https://packagist.org/packages/rinvex/bookable)
[![VersionEye Dependencies](https://img.shields.io/versioneye/d/php/rinvex:bookable.svg?label=Dependencies&style=flat-square)](https://www.versioneye.com/php/rinvex:bookable/)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/rinvex/bookable.svg?label=Scrutinizer&style=flat-square)](https://scrutinizer-ci.com/g/rinvex/bookable/)
[![Code Climate](https://img.shields.io/codeclimate/github/rinvex/bookable.svg?label=CodeClimate&style=flat-square)](https://codeclimate.com/github/rinvex/bookable)
[![Travis](https://img.shields.io/travis/rinvex/bookable.svg?label=TravisCI&style=flat-square)](https://travis-ci.org/rinvex/bookable)
[![Packagist](https://img.shields.io/packagist/v/rinvex/bookings.svg?label=Packagist&style=flat-square)](https://packagist.org/packages/rinvex/bookings)
[![VersionEye Dependencies](https://img.shields.io/versioneye/d/php/rinvex:bookings.svg?label=Dependencies&style=flat-square)](https://www.versioneye.com/php/rinvex:bookings/)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/rinvex/bookings.svg?label=Scrutinizer&style=flat-square)](https://scrutinizer-ci.com/g/rinvex/bookings/)
[![Code Climate](https://img.shields.io/codeclimate/github/rinvex/bookings.svg?label=CodeClimate&style=flat-square)](https://codeclimate.com/github/rinvex/bookings)
[![Travis](https://img.shields.io/travis/rinvex/bookings.svg?label=TravisCI&style=flat-square)](https://travis-ci.org/rinvex/bookings)
[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/1592b83c-f836-4b30-aef3-d997accf9de4.svg?label=SensioLabs&style=flat-square)](https://insight.sensiolabs.com/projects/1592b83c-f836-4b30-aef3-d997accf9de4)
[![StyleCI](https://styleci.io/repos/96481479/shield)](https://styleci.io/repos/96481479)
[![License](https://img.shields.io/packagist/l/rinvex/bookable.svg?label=License&style=flat-square)](https://github.com/rinvex/bookable/blob/develop/LICENSE)
[![License](https://img.shields.io/packagist/l/rinvex/bookings.svg?label=License&style=flat-square)](https://github.com/rinvex/bookings/blob/develop/LICENSE)


## Considerations

- Payments are out of scope for this package.
- This package is for bookable resources, and has nothing to do with price plans and subscriptions. If you're looking for subscription management system, you may have to look at **[rinvex/subscribable](https://github.com/rinvex/subscribable).**
- This package assumes that you've a bookable model that has at least `price` as a decimal field, and `unit` as a char field which accepts one of (h,d,w,m,y,u) representing (hour, day, week, month, year, use) respectively. But anyway even if you don't have these fields, **Rinvex Bookable** behaves agnostically since you've to define such behaviour and functionality yourself. You can extend package's functionality to add features like: minimum and maximum booking length, early and late booking limit, and many more, but this is out of scope for the package and up to your implementation actually.
- This package is for bookable resources, and has nothing to do with price plans and subscriptions. If you're looking for subscription management system, you may have to look at **[rinvex/subscriptions](https://github.com/rinvex/subscriptions).**
- This package assumes that you've a bookable model that has at least `price` as a decimal field, and `unit` as a char field which accepts one of (h,d,w,m,y,u) representing (hour, day, week, month, year, use) respectively. But anyway even if you don't have these fields, **Rinvex Bookings** behaves agnostically since you've to define such behaviour and functionality yourself. You can extend package's functionality to add features like: minimum and maximum booking length, early and late booking limit, and many more, but this is out of scope for the package and up to your implementation actually.


## Installation

1. Install the package via composer:
```shell
composer require rinvex/bookable
composer require rinvex/bookings
```

2. Execute migrations via the following command:
```shell
php artisan migrate --path="vendor/rinvex/bookable/database/migrations"
php artisan rinvex:migrate:bookings
```

3. Add the following service provider to the `'providers'` array inside `app/config/app.php`:
```php
Rinvex\Bookable\Providers\BookableServiceProvider::class
```

And then you can publish the migrations by running the following command:
```shell
php artisan vendor:publish --tag="migrations" --provider="Rinvex\Bookable\Providers\BookableServiceProvider"
```

And also you can publish the config by running the following command:
```shell
php artisan vendor:publish --tag="config" --provider="Rinvex\Bookable\Providers\BookableServiceProvider"
```

4. Done!
3. Done!


## Usage

### Add Bookable to your RESOURCE model
### Add Bookings to your RESOURCE model

**Rinvex Bookable** has been specially made for Eloquent and simplicity has been taken very serious as in any other Laravel related aspect. To add Bookable functionality to your model just use the `\Rinvex\Bookable\Traits\Bookable` trait like this:
**Rinvex Bookings** has been specially made for Eloquent and simplicity has been taken very serious as in any other Laravel related aspect. To add Bookings functionality to your model just use the `\Rinvex\Bookings\Traits\Bookable` trait like this:

```php
namespace App\Models;

use Rinvex\Bookable\Traits\Bookable;
use Rinvex\Bookings\Traits\Bookable;
use Illuminate\Database\Eloquent\Model;

class Event extends Model
Expand All @@ -69,16 +54,16 @@ class Event extends Model

That's it, we only have to use that trait in our Event model! Now your events will be bookable.

### Add Bookable to your USER model
### Add Bookings to your USER model

Bookings could be made by customers themeselves, or by agents on behalf of customers; **Rinvex Bookable** could handle both situations intelligently. To add Bookable support for your `Customer` and `Agent` models, follow these simple steps:
Bookings could be made by customers themeselves, or by agents on behalf of customers; **Rinvex Bookings** could handle both situations intelligently. To add Bookings support for your `Customer` and `Agent` models, follow these simple steps:

```php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Rinvex\Bookable\Traits\IsBookingAgent;
use Rinvex\Bookable\Traits\IsBookingCustomer;
use Rinvex\Bookings\Traits\IsBookingAgent;
use Rinvex\Bookings\Traits\IsBookingCustomer;

class User extends Model
{
Expand Down
32 changes: 17 additions & 15 deletions composer.json
@@ -1,6 +1,6 @@
{
"name": "rinvex/bookable",
"description": "Rinvex Bookable is a generic resource booking system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.",
"name": "rinvex/bookings",
"description": "Rinvex Bookings is a generic resource booking system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.",
"keywords": [
"usage",
"rinvex",
Expand All @@ -16,9 +16,9 @@
"homepage": "https://rinvex.com",
"support": {
"email": "help@rinvex.com",
"issues": "https://github.com/rinvex/bookable/issues",
"source": "https://github.com/rinvex/bookable",
"docs": "https://github.com/rinvex/bookable/blob/master/README.md"
"issues": "https://github.com/rinvex/bookings/issues",
"source": "https://github.com/rinvex/bookings",
"docs": "https://github.com/rinvex/bookings/blob/master/README.md"
},
"authors": [
{
Expand All @@ -34,30 +34,30 @@
},
{
"name": "The Generous Laravel Community",
"homepage": "https://github.com/rinvex/bookable/contributors"
"homepage": "https://github.com/rinvex/bookings/contributors"
}
],
"require": {
"php": "^7.0.0",
"illuminate/support": "~5.4.0|~5.5.0",
"illuminate/database": "~5.4.0|~5.5.0",
"spatie/laravel-sluggable": "^1.5.0",
"spatie/eloquent-sortable": "^3.3.0",
"spatie/laravel-translatable": "^1.3.0",
"illuminate/support": "~5.5.0",
"illuminate/database": "~5.5.0",
"spatie/laravel-sluggable": "^2.0.0",
"spatie/eloquent-sortable": "^3.4.0",
"spatie/laravel-translatable": "^2.0.0",
"rinvex/cacheable": "dev-develop",
"watson/validating": "^3.0.1",
"nesbot/carbon": "~1.22"
},
"require-dev": {
"phpunit/phpunit": "^6.0.0",
"illuminate/container": "~5.4.0|~5.5.0"
"illuminate/container": "~5.5.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"Rinvex\\Bookable\\": "src"
"Rinvex\\Bookings\\": "src"
}
},
"config": {
Expand All @@ -71,8 +71,10 @@
},
"laravel": {
"providers": [
"Rinvex\\Bookable\\Providers\\BookableServiceProvider"
"Rinvex\\Bookings\\Providers\\BookingsServiceProvider"
]
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
10 changes: 10 additions & 0 deletions config/config.php
Expand Up @@ -4,6 +4,7 @@

return [

// Bookings Database Tables
'tables' => [

'bookings' => 'bookings',
Expand All @@ -13,4 +14,13 @@

],

// Bookings Models
'models' => [

'booking' => \Rinvex\Bookings\Models\Booking::class,
'booking_rate' => \Rinvex\Bookings\Models\BookingRate::class,
'booking_availability' => \Rinvex\Bookings\Models\BookingAvailability::class,

],

];
Expand Up @@ -18,11 +18,10 @@ public function up()
// Get users model
$userModel = config('auth.providers.'.config('auth.guards.'.config('auth.defaults.guard').'.provider').'.model');

Schema::create(config('rinvex.bookable.tables.bookings'), function (Blueprint $table) use ($userModel) {
Schema::create(config('rinvex.bookings.tables.bookings'), function (Blueprint $table) use ($userModel) {
// Columns
$table->increments('id');
$table->integer('bookable_id')->unsigned();
$table->string('bookable_type');
$table->morphs('bookable');
$table->integer('customer_id')->unsigned();
$table->integer('agent_id')->unsigned();
$table->timestamp('starts_at')->nullable();
Expand All @@ -48,7 +47,7 @@ public function up()
*/
public function down()
{
Schema::dropIfExists(config('rinvex.bookable.tables.resource_bookings'));
Schema::dropIfExists(config('rinvex.bookings.tables.bookings'));
}

/**
Expand Down
Expand Up @@ -15,11 +15,10 @@ class CreateBookingRatesTable extends Migration
*/
public function up()
{
Schema::create(config('rinvex.bookable.tables.booking_rates'), function (Blueprint $table) {
Schema::create(config('rinvex.bookings.tables.booking_rates'), function (Blueprint $table) {
// Columns
$table->increments('id');
$table->integer('bookable_id')->unsigned();
$table->string('bookable_type');
$table->morphs('bookable');
$table->tinyInteger('percentage');
$table->char('operator', 1);
$table->integer('amount')->unsigned();
Expand All @@ -34,6 +33,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists(config('rinvex.bookable.tables.booking_rates'));
Schema::dropIfExists(config('rinvex.bookings.tables.booking_rates'));
}
}
Expand Up @@ -15,15 +15,14 @@ class CreateBookingAvailabilityTable extends Migration
*/
public function up()
{
Schema::create(config('rinvex.bookable.tables.booking_availability'), function (Blueprint $table) {
Schema::create(config('rinvex.bookings.tables.booking_availability'), function (Blueprint $table) {
// Columns
$table->increments('id');
$table->integer('bookable_id')->unsigned();
$table->string('bookable_type');
$table->morphs('bookable');
$table->char('day', 3);
$table->time('starts_at')->nullable();
$table->time('ends_at')->nullable();
$table->decimal('price')->default('0.00');
$table->decimal('price')->nullable();
$table->timestamps();
});
}
Expand All @@ -35,6 +34,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists(config('rinvex.bookable.tables.booking_availability'));
Schema::dropIfExists(config('rinvex.bookings.tables.booking_availability'));
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Expand Up @@ -13,7 +13,7 @@
beStrictAboutChangesToGlobalState="true"
beStrictAboutCoversAnnotation="true">
<testsuites>
<testsuite name="Rinvex Bookable Unit Test Suite">
<testsuite name="Rinvex Bookings Unit Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
35 changes: 35 additions & 0 deletions src/Console/Commands/MigrateCommand.php
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Rinvex\Bookings\Console\Commands;

use Illuminate\Console\Command;

class MigrateCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'rinvex:migrate:bookings';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Migrate Rinvex Bookings Tables.';

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->warn('Migrate rinvex/bookings:');
$this->call('migrate', ['--step' => true, '--path' => 'vendor/rinvex/bookings/database/migrations']);
}
}
35 changes: 35 additions & 0 deletions src/Contracts/BookingAvailabilityContract.php
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Rinvex\Bookings\Contracts;

/**
* Rinvex\Bookings\Contracts\BookingAvailabilityContract.
*
* @property int $id
* @property int $bookable_id
* @property string $bookable_type
* @property string $day
* @property \Carbon\Carbon $starts_at
* @property \Carbon\Carbon $ends_at
* @property float $price
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $bookable
*
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Bookings\Models\BookingAvailability whereBookableId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Bookings\Models\BookingAvailability whereBookableType($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Bookings\Models\BookingAvailability whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Bookings\Models\BookingAvailability whereDay($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Bookings\Models\BookingAvailability whereEndsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Bookings\Models\BookingAvailability whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Bookings\Models\BookingAvailability wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Bookings\Models\BookingAvailability whereStartsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Bookings\Models\BookingAvailability whereUpdatedAt($value)
* @mixin \Eloquent
*/
interface BookingAvailabilityContract
{
//
}

0 comments on commit 75befcf

Please sign in to comment.