本文整理汇总了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>