PHP code example of matheushack / ifood
1. Go to this page and download the library: Download matheushack/ifood 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/ */
matheushack / ifood example snippets
MatheusHack\IFood\Categories;
use MatheusHack\IFood\Constants\Availability;
$categories = new Categories();
$categories->create([
'externalCode' => 'CAT001',
'name' => 'Lanches',
'order' => 1,
'status' => Availability::ACTIVE
]);
MatheusHack\IFood\GroupComplements;
$groupComplement = new GroupComplements();
$groupComplement->create([
'externalCode' => 'GRP001',
'name' => 'Bebida',
'sequence' => 1,
'minQuantity' => 1,
'maxQuantity' => 1
]);
MatheusHack\IFood\Items;
use MatheusHack\IFood\Constants\DaysOfWeek;
use MatheusHack\IFood\Constants\Availability;
$items = new Items();
$items->create([
'externalCode' => 'ITP001',
'name' => 'Hack X-burguer',
'order' => 1,
'status' => Availability::ACTIVE,
'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod',
'price' => [
'amount' => 1,
'isPromotional' => false
],
'schedules' => [DaysOfWeek::MON, DaysOfWeek::TUE, DaysOfWeek::WED, DaysOfWeek::THU, DaysOfWeek::FRI]
]);
MatheusHack\IFood\Items;
use MatheusHack\IFood\Constants\Availability;
$items = new Items();
$items->create([
'externalCode' => 'ITS001',
'name' => 'Coca-cola',
'order' => 1,
'status' => Availability::ACTIVE,
'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod',
'price' => [
'amount' => 2,
'isPromotional' => false
],
'schedules' => []
]);
MatheusHack\IFood\Items;
$items = new Items();
$items->joinGroup([
'externalCodeGroup' => 'GRP001',
'externalCodeItem' => 'ITS001',
'sequence' => 1
]);
MatheusHack\IFood\GroupComplements;
$groupComplement = new GroupComplements();
$groupComplement->joinItem([
'externalCodeGroup' => 'GRP001',
'externalCodeItem' => 'ITP001',
'maxQuantity' => 1,
'minQuantity' => 1,
'order' => 1
]);
MatheusHack\IFood\Items;
$items = new Items();
$items->joinCategory([
'externalCode' => 'ITP001',
'externalCodeCategory' => 'CAT001',
'order' => 1
]);
MatheusHack\IFood\Restaurant;
$restaurant = new Restaurant();
$restaurant->available();
MatheusHack\IFood\Restaurant;
$restaurant = new Restaurant();
$restaurant->unavailable('MOTIVO');