PHP code example of telkins / laravel-inquiry

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

    

telkins / laravel-inquiry example snippets


$isAllowed = CanChildPlayPS4::ask()
    ->child($junior)
    ->onDateTime(now())
    ->answer();

$isAllowed = CanChildPlayPS4::ask()
    ->child($junior)
    ->onDateTime(now())
    ->answer();

$inquiryDetails = CanChildPlayPS4::ask();

$canGregPlay = $inquiryDetails
    ->child($greg)
    ->onDateTime(now())
    ->answer();

$canPeterPlay = $inquiryDetails
    ->child($peter)
    ->answer();
 php
use Telkins\LaravelInquiry\Inquiry;
use Telkins\LaravelInquiry\Contracts\Details;

class CanChildPlayPS4 extends Inquiry
{
    public function provideAnswer(Details $details)
    {
        if (! $details->child->areChoresDone()) {
            return false;
        }

        if ($details->child->isGrounded()) {
            return false;
        }

        if (! $details->child->isDoneWithHomework()) {
            return false;
        }

        return $this->isItAGoodTimeToPlay($details->dateTime);
    }

    // supporting methods, if needed...
}
 php
use App\Child;
use Carbon\CarbonImmutable;
use Telkins\LaravelInquiry\Details;

class CanChildPlayPS4Details extends Details
{
    public $child;
    public $dateTime;

    public function child(Child $child): self
    {
        $this->child = $child;

        return $this;
    }

    public function onDateTime(CarbonImmutable $dateTime): self
    {
        $this->dateTime = $dateTime;

        return $this;
    }
}