PHP code example of abdulsalamemesh / what-to-do-api-client

1. Go to this page and download the library: Download abdulsalamemesh/what-to-do-api-client 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/ */

    

abdulsalamemesh / what-to-do-api-client example snippets


use AbdulsalamEmesh\WhatToDo\Facades\WhatToDo;

WhatToDo::getTask();

$task = WhatToDo::category('fun')->person(1)->cost('$')->language('en')->identifier('1sdre5')->getTask();

$data = [
    'language' => 'en',
    'task'     => 'play football',
    'category' => 'fun',
    'person'   => 4,
    'cost'     => '$',
    'links'    => [
      'en' => 'https://www.google.com/'
      'de' => 'https://www.google.com/?hl=de'
    ],
];

$task = WhatToDo::create($data);

dd($task);
// return a collection of the following data:
[
    "identifier" => "8892a2"
    "task" =>  [
      "en-US" => "play football"
      "de" => "Fußball spielen"
      "es" => "jugar al fútbol"
      "fr" => "jouer au football"
      "it" => "giocare a calcio"
      "tr" => "futbol oynamak"
      "uk" => "грати у футбол"
    ]
    "category" => "fun"
    "person" => 4
    "cost" => "$"
    "links" => [
      "en" => "https://www.google.com/"
      "de" => "https://www.google.com/?hl=de"
      "es" => ""
      "fr" => ""
      "it" => ""
      "tr" => ""
      "uk" => ""
    ]
  ]


$supportedLanguages = [
        'en-US' => 'english',
        'de'    => 'german',
        'es'    => 'spanish',
        'fr'    => 'french',
        'it'    => 'italian',
        'tr'    => 'turkish',
        'uk'    => 'ukrainian',
];


$supportedCosts = ['free', '$', '$$', '$$$'];