本文整理匯總了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();
}