本文整理汇总了PHP中Package::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::first方法的具体用法?PHP Package::first怎么用?PHP Package::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::first方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editPackage
/**
* @before _secure, _vendor
*/
public function editPackage($package_id)
{
$this->seo(array("title" => "Edit Packages", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$package = Package::first(array("id = ?" => $package_id, "organization_id = ?" => $this->organization->id));
if (!$package) {
$this->redirect("/vendor");
}
$tests = Test::all(array(), array("id", "title"));
$items = Item::all(array("package_id = ?" => $package->id));
$sorted = array();
foreach ($items as $i) {
$sorted[$i->test_id] = $i;
}
$fields = $package->render();
$errors = array();
$view->set("fields", $fields);
if (RequestMethods::post("action") == "savePackage") {
foreach ($fields as $f) {
$package->{$f}['name'] = RequestMethods::post($f['name']);
}
if ($package->validate()) {
$package->save();
$view->set("message", "Package Saved Successfully");
} else {
$errors = $package->errors;
}
$sorted = $this->_saveTests($package, $sorted);
}
$view->set("package", $package)->set("items", $sorted)->set("tests", $tests)->set("errors", $errors);
}
示例2: booking_form
public function booking_form($package_id)
{
$view = $this->getActionView();
$package = Package::first(array('id = ?' => $package_id));
$view->set('package', $package);
/* if($this->user){
if(RequestMethods::){
}
}else{
echo "<script> alert('login first') </script>";
}
*/
}
示例3: editPackage
/**
* @before _secure, _admin
*/
public function editPackage($package_id)
{
$package = Package::first(array("id = ?" => $package_id));
if (!$package) {
$this->redirect("/admin");
}
$this->seo(array("title" => "Create Package", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$errors = array();
if (RequestMethods::post("action") == "submitPackage") {
$response = $this->_savePackage($package);
if ($response["success"]) {
$view->set("success", "Package is Updated");
} else {
$errors = $response["errors"];
}
}
$items = Item::all(array(), array("id", "name"));
$view->set("items", $items)->set("package", $package)->set("errors", $errors);
}
示例4: addSubscription
protected function addSubscription($transaction)
{
$package = Package::first(array("id = ?" => $transaction->property_id));
$items = json_decode($package->item);
$user = User::first(array("id = ?" => $transaction->user_id));
$user->live = 1;
$user->save();
$days = (int) $package->period;
foreach ($items as $key => $value) {
$s = new Subscription(array("user_id" => $user->id, "item_id" => $value, "period" => $days, "expiry" => strftime("%Y-%m-%d", strtotime("+" . ($days + 1) . " Day")), "is_promo" => false));
$s->save();
}
$this->session($user);
$this->redirect('/member/index.html');
}