Skip to content

Instantly share code, notes, and snippets.

@VictorFursa
Created October 19, 2017 22:36
Show Gist options
  • Save VictorFursa/a25f22cb766c821b9e76765525705bd8 to your computer and use it in GitHub Desktop.
Save VictorFursa/a25f22cb766c821b9e76765525705bd8 to your computer and use it in GitHub Desktop.
create arrayObject
<?php
class Booked extends \yii\db\ActiveRecord
{
/** @var $sum integer */
public $sum;
/** @var $countBookedRoom integer */
public $countBookedRoom;
/** @var $countPayment integer */
public $countPayment;
/** @var $numberRoom integer */
public $numberRoom;
...
public function foo(): array
{
$arrayObject = [];
foreach ($array as $value) {
// Doing something
...
$reports = new Booked();
$reports->sum = $sum;
$reports->countBookedRoom = $countBookedRoom;
$reports->countPayment = $countPayment;
$reports->numberRoom = $booked->room->number_room;
$arrayObject[] = $reports;
}
return $arrayObject;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment