PHP code example of nncodes / laravel-meeting

1. Go to this page and download the library: Download nncodes/laravel-meeting 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/ */

    

nncodes / laravel-meeting example snippets


use Nncodes\Meeting\Models\Meeting;
use Nncodes\Meeting\Models\MeetingRoom;
use App\Models\Event;
use App\Models\Teacher;

$meeting = Meeting::schedule()
  	->withTopic('English class: verb to be')
  	->startingAt(now()->addMinutes(30))
  	->during(40) //in Minutes
  	->scheduledBy(Event::find(1))
  	->presentedBy(Teacher::find(1))
  	->hostedBy(MeetingRoom::find(1))
  	->save();

/**
 * Default Meeting Provider
 * 
 * Here you can specify which meeting provider the package should use by 
 * default. Of course you may use many providers at once using the package.
 */
'default' => env('MEETING_PROVIDER', 'zoom'),

/**
 * Meeting Providers
 * 
 * Here are each of the meetings provider setup for the package.
 */

'providers' => [

    'zoom' => [

         /**
         * Provider class
         **/
        'type' => \Nncodes\Meeting\Providers\Zoom\ZoomProvider::class,

        /**
         * JWT Zoom Token 
         * @see https://marketplace.zoom.us/docs/guides/auth/jwt
         **/
        'jwt_token' => env('ZOOM_TOKEN'),

        /**
         * Zoom Group ID
         * 
         * @see https://marketplace.zoom.us/docs/api-reference/zoom-api/groups/group
         **/
        'group_id' => env('ZOOM_GROUP'),

         /**
         * Share Rooms
         * 
         * Delegate to the package the responsability of handling the allocations of rooms.
         **/
        'share_rooms' => true,

         /**
         * Meeting resource seetings
         * 
         * @see https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meeting
         **/
        'meeting_settings' => [
            "host_video" => false,
            "participant_video" => false,
            "join_before_host" => false,
            "jbh_time" => 0,
            "mute_upon_entry" => true,
            "approval_type" => 0,
            "registration_type" => 1,
            "close_registration" => true,
            "waiting_room" => true,
            "registrants_confirmation_email" => false,
            "registrants_email_notification" => false,
            "meeting_authentication" => false
        ]
    ]
],

/**
 * Allow concurrent Meetings
 */
'allow_concurrent_meetings' => [
    'host' => false,
    'participant' => false,
    'presenter' => false,
    'scheduler' => true,
]

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Nncodes\Meeting\Concerns\SchedulesMeetings;
use Nncodes\Meeting\Contracts\Scheduler;

class Event extends Model implements Scheduler
{
    use SchedulesMeetings;
}

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Nncodes\Meeting\Concerns\PresentsMeetings;
use Nncodes\Meeting\Contracts\Presenter;

class Teacher extends User implements Presenter
{
    use PresentsMeetings;
}

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Nncodes\Meeting\Concerns\HostsMeetings;
use Nncodes\Meeting\Contracts\Host;

class Room extends Model implements Host
{
    use HostsMeetings;
}

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Nncodes\Meeting\Concerns\JoinsMeetings;
use Nncodes\Meeting\Contracts\Participant;

class Student extends User implements Participant
{
    use JoinsMeetings;

    /**
     * Email Address of the participant
     *
     * @return string
     */
    public function getParticipantEmailAddress(): string
    {
        return $this->email;
    }

    /**
     * First name of the participant
     *
     * @return string
     */
    public function getParticipantFirstName(): string
    {
        return $this->first_name;
    }

    /**
     * Last name of the participant
     *
     * @return string
     */
    public function getParticipantLastName(): string
    {
        return $this->last_name;
    }
}

use Nncodes\Meeting\Models\Meeting;
use App\Models\Event;
use App\Models\Teacher;
use App\Models\Room;

$event = Event::find(1);
$teacher = Teacher::find(1);
$room = Room::find(1);

$meeting = Meeting::schedule()
  	->withTopic('English class: verb to be')
  	->startingAt(now()->addMinutes(30))
  	->during(40) //minutes
  	->scheduledBy($event)
  	->presentedBy($teacher)
  	->hostedBy($room)
  	->save();

use Nncodes\Meeting\Models\Meeting;
use App\Models\Event;
use App\Models\Teacher;
use App\Models\Room;

$event->scheduleMeeting()
  	->withTopic('English class: verb to be')
  	->startingAt(now()->addMinutes(30))
  	->during(40) //minutes
  	->presentedBy($teacher)
  	->hostedBy($room)
  	->save()

use Nncodes\Meeting\Models\Meeting;
use App\Models\Event;
use App\Models\Teacher;
use App\Models\Room;

$meeting = Meeting::find(1);

$meeting->updateTopic('English class: Introducing Yourself')
    ->updateDuration(60)
    ->updateStartTime(now())
    ->updateScheduler(Event::find(1))
    ->updatePresenter(Teacher::find(5))
    ->updateHost(Room::find(1))
    ->save();

use Nncodes\Meeting\Models\Meeting;
use App\Models\Student;

$meeting = Meeting::find(1);
$student = Student::find(1);

//By the meeting model
$meeting->addParticipant($student);

//Or by the participant model 
$student->bookMeeting($meeting);

use Nncodes\Meeting\Models\Meeting;

Meeting::find(1)->getPresenterAccess();

use Nncodes\Meeting\Models\Meeting;
use App\Models\Student;

$student = Student::find(1);

Meeting::find(1)>getParticipantAccess($student);

$query = Meeting::query();

$query = Event::find(1)->meetings();

$query = Teacher::find(1)->meetings();

$query = Room::find(1)->meetings();

$query = Student::find(1)->meetings();

$query->byUuid('b33cac3a-c8da-4b33-a296-30a6acff5af6');

$query->byId(1);

$query->provider('zoom');

$query->startsFrom(Carbon::now()->sub('15 days'));

$query->startsUntil(Carbon::now()->add('15 days'));

$query->startsBetween(
    Carbon::now()->sub('15 days'),
    Carbon::now()->add('15 days')
);

$query->live();

$query->past();

$query->scheduled();

$query->late();

$query->exceeded();

$query->next();

$query->last();

$query->scheduler(Event::find(1));

$query->host(Room::find(1));

$query->participant(Student::find(1));

$query->presenter(Teacher::find(1));

use Nncodes\Meeting\Models\Meeting;
use App\Models\Event;
use App\Models\Teacher;

$meeting = Meeting::schedule()
  	->withTopic('English class: verb to be')
  	->startingAt(now()->addMinutes(30))
  	->during(40) //minutes
  	->scheduledBy(Event::find(1))
  	->presentedBy(Teacher::find(1))
  	->save();
 
use Nncodes\Meeting\Models\Meeting;

Meeting::find(1)->start();

Meeting::find(1)->end();

Meeting::find(1)->cancel();

$student = Student::find(1);
Meeting::find(1)->addParticipant($student);

$meeting = Meeting::find(1);
Student::find(1)->bookMeeting($meeting);

$student = Student::find(1);
Meeting::find(1)->cancelParticipation($student);

$meeting = Meeting::find(1);
Student::find(1)->cancelMeetingParticipation($meeting);

$student = Student::find(1);
Meeting::find(1)->joinParticipant($student);

$meeting = Meeting::find(1);
Student::find(1)->joinMeeting($meeting);

$student = Student::find(1);
Meeting::find(1)->leaveParticipant($student);

$meeting = Meeting::find(1);
Student::find(1)->leaveMeeting($meeting);

$student = Student::find(1);
$participant = Meeting::find(1)->participant($student);

$student = Student::find(1);
$bool = Meeting::find(1)->hasParticipant($student);

//Must inform the participant model type
$participants = Meeting::find(1)->participants(App\Models\Student::class)->get();

//Doesn't need to inform participant model type, it gets all types. 
$participants = Meeting::find(1)->participantsPivot;

$participant = Meeting::find(1)->getNextParticipant();

use Nncodes\Meeting\Models\MeetingRoom;

$startTime = Carbon::now()->addMinutes(30);
$duration = 40;
$endTime = (clone $startTime)->addMinutes($duration);
 
MeetingRoom::availableBetween($startTime, $endTime);
 
MeetingRoom::busyBetween($startTime, $endTime);
 
use Nncodes\Meeting\Models\Meeting;

$except = Meeting::find(1);

MeetingRoom::availableBetween($startTime, $endTime, $except);
MeetingRoom::busyBetween($startTime, $endTime, $except);
 
use Nncodes\Meeting\Models\MeetingRoom;

MeetingRoom::find(1)->isAvailableBetween($startTime, $endTime);
MeetingRoom::find(1)->isBusyBetween($startTime, $endTime);
 
use Nncodes\Meeting\Models\MeetingRoom;
use Nncodes\Meeting\Models\Meeting;

$except = Meeting::find(1);

MeetingRoom::find(1)->isAvailableBetween($startTime, $endTime, $except);
MeetingRoom::find(1)->isBusyBetween($startTime, $endTime, $except);
bash
php artisan meeting:install --config
bash
php artisan vendor:publish --provider="Nncodes\Meeting\MeetingServiceProvider" --tag="migrations"
php artisan vendor:publish --provider="Nncodes\MetaAttributes\MetaAttributesServiceProvider" --tag="migrations"
bash
php artisan migrate
bash
php artisan vendor:publish --provider="Nncodes\Meeting\MeetingServiceProvider" --tag="config"