Git Product home page Git Product logo

melifarobookingbundle's Introduction

MelifaroBookingBundle

SensioLabsInsight

Build Status


Booking Bundle for Symfony 2 Applications. Bundle provides some useful functionality for handling bookings on your website.

Installation

1. Download

Prefered way to install this bundle is using composer

Download the bundle:

$ php composer.phar require "melifaro/melifaro-booking-bundle:dev-master"

2. Add it to your Kernel:

<?php

// app/AppKernel.php


public function registerBundles()
{
    $bundles = array(
        // ...

        new Melifaro\BookingBundle\MelifaroBookingBundle(),
    );
}

3. Create your entity

Doctrine ORM

Bundle has all necessary mappings for your entity. Just create your entity class and extend it from Melifaro\BookingBundle\Entity\Booking, create your id field and setup proper relation for item you want to be booked.

<?php

namespace Vendor\Bundle\Entity;

use Melifaro\BookingBundle\Entity\Booking as BaseClass;

/**
 * Booking
 *
 * @ORM\Entity()
 * @ORM\Table(name="booking")
 */
class Booking extends BaseClass
{
    /**
         * @var integer
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        protected $id;

        /**
         * @var \Vendor\Bundle\Entity\BookableItem
         *
         * @ORM\ManyToOne(targetEntity="BookableItem", inversedBy="bookings")
         * @ORM\JoinColumn(name="property_id", referencedColumnName="id")
         */
        protected $item;

        // Don't forget about getters and setters
}

Now we are ready to rock!

Booker Service

Core component of this bundle is booker service. You can get it in your controller by using

<?php

public function bookingAction()
{
    $this->get('booker'); /** @var \Melifaro\BookingBundle\Helper\Booker */
}

Booker Service has following methods:

isAvailableForPeriod($item, \DateTime $start, \DateTime $end) Checks is your item available for period, returns boolean


isAvailableForDate($item, \DateTime $date) Checks is your item available for date, returns boolean


whereAvailableForPeriod(QueryBuilder $queryBuilder, $join, \DateTime $start, \DateTime $end) Updates your QueryBuilder and returns the same QueryBuilder object with added join and where clause.

Note: $join is array('field', 'alias')


whereAvailableForDate(QueryBuilder $queryBuilder, $join, \DateTime $date) Updates your QueryBuilder and returns the same QueryBuilder object with added join and where clause.

Note: $join is array('field', 'alias')


book($item, \DateTime $start, \DateTime $end) Books your item returns Entity | false (Entity on success, false on failure)

Calendar Twig Extension

Bundle also provides cool Twig extension. To use it in your template just try following:

{{ melifaro_booking_calendar(item, "now", 4) }}

Where

item - is object of your bookable item

now - is any date allowed for \DateTime::__construct()

4 - number of months to be rendered after desired date

Overriding template

Template can be overridden as usual in Symfony 2 application. Just create following directory structure:

app/Resources/views/MelifaroBookingBundle/Calendar/month.html.twig

melifarobookingbundle's People

Contributors

ickbinhier avatar itcreator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

melifarobookingbundle's Issues

Child node to configure

I am getting this error, any idea to what it could be related to?

InvalidConfigurationException in ArrayNode.php line 240:
The child node "entity_class" at path "melifaro_booking" must be configured.

Symfony 3

Hi,

I'm trying to install this package on my Symfony 3 project but Composer fails, saying it only supports Symfony 2.
Any chance to fix that?

Thanks

Different Booking Entities

Hi melifaro,

you've developed a gread bundle. But i need the bundle for 2 or evt. more different independent reservation entities. E.G. BikeReservation, CarReservation.
Do you has an idea, how i can solve this problem? Currently i have to set the entity class in app/config.yml

kind regards,
fussl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.