本文整理匯總了PHP中Phone::getPhoneById方法的典型用法代碼示例。如果您正苦於以下問題:PHP Phone::getPhoneById方法的具體用法?PHP Phone::getPhoneById怎麽用?PHP Phone::getPhoneById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phone
的用法示例。
在下文中一共展示了Phone::getPhoneById方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
}
if ($member) {
?>
<div class="col-md-8">
<div class="page-header">
<h1>Éditer une promotion</h1>
</div>
<form action="index.php?page=admin/promotion-edit&id=<?php
echo $id;
?>
" method="POST">
<div class="form-group">
<label for="phone">Téléphone</label>
<p><?php
echo Phone::getPhoneById($promotion->phone)->name;
?>
</p>
</div>
<div class="form-group">
<label for="promotion-percent">Pourcentage</label>
<input type="text" class="form-control" id="promotion-percent" value="<?php
echo $promotion->percent;
?>
" name="percent" placeholder="Pourcentage">
</div>
<button type="submit" class="btn btn-lg btn-primary" name="edit">Éditer</button>
</form>
</div>
示例2: array
<?php
if (isset($_POST['action'])) {
if ($_POST['action'] == 'add') {
$phone = Phone::getPhoneById($_POST['id']);
// Si la session existe, alors on initialise la valeur dans une variable
if (isset($_SESSION['cart']) && !empty($_SESSION['cart'])) {
$cart = $_SESSION['cart'];
} else {
$cart = array('phones' => array(), 'phone_total' => (int) 0, 'price_total' => (int) 0);
}
// Lorsqu'on ajoute un téléphone, on le stocke dans un tableau
array_push($cart['phones'], array('id' => (int) $phone->id, 'name' => $phone->name, 'price' => (int) $_POST['price'], 'amount' => (int) $_POST['amount'], 'capacity' => (int) $_POST['capacity'], 'color' => (int) $_POST['color']));
// On précise que les données entrés précédement correspondent à la variable $cart pour les ajouter dans la session
$_SESSION['cart'] = $cart;
$_SESSION['cart']['phone_total'] = $_SESSION['cart']['phone_total'] + $_POST['amount'];
$_SESSION['cart']['price_total'] = $_SESSION['cart']['price_total'] + $phone->price;
$msg->success('Le téléphone a bien été ajouté au panier.', 'index.php?page=cart');
} elseif ($_POST['action'] == 'remove') {
$_SESSION['cart']['phone_total'] = $_SESSION['cart']['phone_total'] - $_SESSION['cart']['phones'][$_POST['id']]['amount'];
$_SESSION['cart']['price_total'] = $_SESSION['cart']['price_total'] - $_SESSION['cart']['phones'][$_POST['id']]['price'] * $_SESSION['cart']['phones'][$_POST['id']]['amount'];
unset($_SESSION['cart']['phones'][$_POST['id']]);
// App::dd($_SESSION['cart']['phones']);
$msg->success('Le produit a bie été supprimé de votre panier', 'index.php?page=cart');
} else {
echo 'Erreur';
}
} else {
$empty = true;
$phonesTotal = 0;
if (isset($_SESSION['cart']['phones']) && !empty($_SESSION['cart']['phones'])) {
示例3: getNewPrice
public static function getNewPrice($promotionId)
{
$promotion = self::getPromotionByPhoneId($promotionId);
$phone = Phone::getPhoneById($promotion->phone);
return $phone->price - $promotion->percent * 0.01 * $phone->price;
}
示例4:
<div class="container">
<div class="row">
<?php
if (!isset($_GET['id']) || empty($_GET['id'])) {
App::redirect('index.php?page=list');
} else {
$id = $_GET['id'];
$phone = Phone::getPhoneById($id);
$promotion = Promotion::getPromotionByPhoneId($phone->id);
$brand = Brand::getBrandById($phone->brand);
?>
<div class="col-sm-12" style="margin-bottom: 30px;">
<h1 style="margin-bottom: 0;"><?php
echo $phone->name;
?>
</h1>
<span style="color: #bfbfbf; display: block; font-size: 18px;"><?php
echo $brand->name;
?>
</span>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<a href="index.php?page=product&id=<?php
echo $phone->id;
?>
" style="display: inline-block; padding: 15px; border: 1px solid #ededed;">
<img id="phone_img" src="<?php
echo Phone::getPhoneThumbnail($phone->id);
?>
" alt="<?php
echo $phone->name;
示例5: foreach
?>
<table class="table table-striped">
<thead>
<th>Téléphone</th>
<th>Pourcentage</th>
<th>Prix de base</th>
<th>Prix réduit</th>
<th></th>
<th></th>
</thead>
<?php
foreach (Promotion::getPromotionsList() as $promotion) {
echo '<tr data-id="' . $promotion->id . '">';
echo '<td><a href="index.php?page=admin/promotion-edit&id=' . $promotion->id . '">' . Phone::getPhoneById($promotion->phone)->name . '</a></td>';
echo '<td>' . $promotion->percent . ' %</td>';
echo '<td>' . Phone::getPhoneById($promotion->phone)->price . ' €</td>';
echo '<td>' . Promotion::getNewPrice($promotion->phone) . ' €</td>';
echo '<td><a href="index.php?page=admin/promotion-edit&id=' . $promotion->id . '"><i class="fa fa-pencil" data-toggle="tooltip" title="Modifier"></i></a></td>';
echo '<td><a href="#" title="Supprimer" data-toggle="tooltip" data-action="delete" title="Supprimer"><i class="fa fa-trash"></i></a></td>';
echo '</tr>';
}
?>
</table>
<a href="index.php?page=admin/add-promotion" class="btn btn-primary">Ajouter une promotion</a>
<?php
} else {
echo '<p>Aucune promotion n\'a été ajouté.</p>';
}
?>
</div>
<script>