本文整理汇总了PHP中Dashboard::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Dashboard::user方法的具体用法?PHP Dashboard::user怎么用?PHP Dashboard::user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dashboard
的用法示例。
在下文中一共展示了Dashboard::user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDashboard
/**
* createDashboard
* --------------------------------------------------
* Creating a dashboard dedicated to braintree widgets.
* --------------------------------------------------
*/
private function createDashboard()
{
/* Creating dashboard. */
$dashboard = new Dashboard(array('name' => 'Braintree dashboard', 'background' => TRUE, 'number' => $this->user->dashboards->max('number') + 1));
$dashboard->user()->associate($this->user);
$dashboard->save();
/* Adding widgets */
$mrrWidget = new BraintreeMrrWidget(array('position' => '{"col":1,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
$arrWidget = new BraintreeArrWidget(array('position' => '{"col":5,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
$arpuWidget = new BraintreeArpuWidget(array('position' => '{"col":9,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
/* Associating dashboard */
$mrrWidget->dashboard()->associate($dashboard);
$arrWidget->dashboard()->associate($dashboard);
$arpuWidget->dashboard()->associate($dashboard);
/* Saving widgets */
$mrrWidget->save();
$arrWidget->save();
$arpuWidget->save();
/* Populating data */
$mrrWidget->collectData();
$arrWidget->collectData();
$arpuWidget->collectData();
}
示例2: createDashboard
/**
* createDashboard
* --------------------------------------------------
* Creating a dashboard dedicated to stripe widgets.
* --------------------------------------------------
*/
private function createDashboard()
{
/* Creating dashboard. */
$dashboard = new Dashboard(array('name' => 'Stripe dashboard', 'background' => TRUE, 'number' => $this->user->dashboards->max('number') + 1));
$dashboard->user()->associate($this->user);
$dashboard->save();
/* Adding widgets */
$mrrWidget = new StripeMrrWidget(array('position' => '{"col":1,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
$arrWidget = new StripeArrWidget(array('position' => '{"col":5,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
$arpuWidget = new StripeArpuWidget(array('position' => '{"col":9,"row":7,"size_x":4,"size_y":4}', 'state' => 'active'));
/* Associating dashboard */
$mrrWidget->dashboard()->associate($dashboard);
$arrWidget->dashboard()->associate($dashboard);
$arpuWidget->dashboard()->associate($dashboard);
/* Saving widgets */
$mrrWidget->save();
$arrWidget->save();
$arpuWidget->save();
/* Creating data for the last 30 days. */
$calculator = new StripeLastMonthCalculator($this->user);
$lastMonthData = $calculator->getLastMonthData();
$mrrWidget->data->raw_value = json_encode($lastMonthData['mrr']);
$arrWidget->data->raw_value = json_encode($lastMonthData['arr']);
$arpuWidget->data->raw_value = json_encode($lastMonthData['arpu']);
$mrrWidget->data->save();
$arrWidget->data->save();
$arpuWidget->data->save();
$mrrWidget->state = 'active';
$arrWidget->state = 'active';
$arpuWidget->state = 'active';
/* Saving widgets */
$mrrWidget->save();
$arrWidget->save();
$arpuWidget->save();
}