mindtwo/appointable

This package helps you to manage appointments within yout Laravel application.

0.1.2 2024-11-06 14:19 UTC

This package is auto-updated.

Last update: 2024-11-06 15:03:16 UTC


README

Introduction

Appointable is a Laravel package by mindtwo that provides an appointment management system with configurable routes and controllers. It allows developers to manage appointments, handle invitations, and provide easy-to-use RESTful endpoints for various appointment-related actions. This package comes with built-in routes, a service provider, and configuration options for quick integration.

Features

  • Create and auto-manage appointments for Eloquent models
  • Registerable routes for managing appointments.
  • RESTful controllers for creating, updating, canceling, and managing invitations.
  • Middleware support for secure appointment routes.

Installation

  1. Install the package via Composer:

    composer require mindtwo/appointable
  2. (Optional) Publish the configuration and migration files:

    php artisan vendor:publish --provider="mindtwo\Appointable\Providers\AppointableServiceProvider" --tag="appointable-config"
    php artisan vendor:publish --provider="mindtwo\Appointable\Providers\AppointableServiceProvider" --tag="appointable-migrations"
  3. Run the migrations:

    php artisan migrate

Usage

Register Routes

To register the default appointment management routes, simply call the Appointable::routes() method in your web.php routes file.

use mindtwo\Appointable\Facades\Appointable;

// Register the default appointment routes
Appointable::routes();

By default, the routes will be registered under the /appointments prefix. You can customize the prefix and middleware by passing options to the routes() method:

Appointable::routes('my-appointments', ['auth']);

This will register the routes under /my-appointments and apply the auth middleware.

Available Routes

The following routes are registered when using Appointable::routes():

  • GET /appointments – List all appointments (Index).
  • POST /appointments – Create a new appointment.
  • PUT|PATCH /appointments/{uuidOrUid} – Update an appointment.
  • DELETE /appointments/{uuidOrUid} – Cancel an appointment.
  • POST /appointments/{uuidOrUid}/confirm – Confirm an appointment invitation.
  • POST /appointments/{uuidOrUid}/decline – Decline an appointment invitation.

Middleware

By default, no middleware is applied to the routes. You can specify custom middleware in the routes() method:

Appointable::routes('appointments', ['auth', 'verified']);

Configurations

You can customize the behavior of the package through its configuration file. After publishing the configuration, modify the config/appointable.php file as needed.

return [
    'middleware' => ['web'],
];

Migrations

The package provides a migration file to create the appointments table. You can publish the migration with:

php artisan vendor:publish --provider="mindtwo\Appointable\Providers\AppointableServiceProvider" --tag="appointable-migrations"

After publishing, run the migration:

php artisan migrate

License

This package is open-sourced software licensed under the MIT license.