1. Go to this page and download the library: Download binary-cats/coordinator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
binary-cats / coordinator example snippets
use BinaryCats\Coordinator\Eloquent\Booking;
use Spatie\Period\Boundaries;
use Spatie\Period\Precision;
return [
/*
|--------------------------------------------------------------------------
| Coordinator: Booking Model
|--------------------------------------------------------------------------
|
| The default is `BinaryCats\Coordinator\Eloquent\Booking`.
| You are likely to extend the class or replace it with your implementation:
| Model must implement `BinaryCats\Coordinator\Contracts\Booking`
|
*/
'booking_model' => Booking::class,
/*
|--------------------------------------------------------------------------
| Booking Period: Precision
|--------------------------------------------------------------------------
| Date precision is important if you want to reliably compare two periods:
| @see https://stitcher.io/blog/comparing-dates
|
| Valid options are:
| YEAR|DAY|HOUR|MINUTE|SECOND
*/
'precision' => Precision::SECOND(),
/*
|--------------------------------------------------------------------------
| Booking Period: Boundaries
|--------------------------------------------------------------------------
| By default, period comparisons are done with
use BinaryCats\Coordinator\CanBeBooked;
use BinaryCats\Coordinator\Contracts\BookableResource;
use Illuminate\Database\Eloquent\Model;
class Room extends Model implements BookableResource
{
use CanBeBooked;
}
use BinaryCats\Coordinator\BooksResources;
use BinaryCats\Coordinator\Contracts\CanBookResources;
use Illuminate\Database\Eloquent\Model;
class User extends Model implements CanBookResources
{
use BooksResources;
}
use Illuminate\Support\Facades\Gate;
Room::first()->isAvailableFor(User::first(), function($model, $resource) {
// Assuming model is \Illuminate\Contracts\Auth\Access\Authorizable
return Gate::forUser($model)->allows('book', $resource);
});