本文整理汇总了PHP中Banner::show方法的典型用法代码示例。如果您正苦于以下问题:PHP Banner::show方法的具体用法?PHP Banner::show怎么用?PHP Banner::show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Banner
的用法示例。
在下文中一共展示了Banner::show方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($alias = null)
{
$data = ['pages' => Page::show()->fetch(false)];
if ($alias !== null) {
$page = Page::show(['alias' => $alias])->fetchOne();
if (!$page) {
return $this->app->show404();
}
$data['heading'] = $page->judul;
$data['content'] = $page->konten;
return $this->render('page', $data);
} else {
$data['heading'] = 'Selamat datang di website resmi ' . conf('app.title');
$data['products'] = Product::show()->fetch(5);
$data['slides'] = Banner::show(['tipe' => 'slide', 'aktif' => 1])->fetch(3);
return $this->render('home', $data);
}
}
示例2: banners
public function banners($do = '', $id = '')
{
$this->data['heading'] = 'Administrasi: Banner';
switch ($do) {
case 'form':
if (post('submit')) {
$data = [User::primary() => 1, 'tgl_input' => date('Y-m-d'), 'judul' => post('judul'), 'keterangan' => post('keterangan'), 'url' => post('url'), 'gambar' => post('gambar'), 'tgl_mulai' => formatTanggal(post('tgl_mulai'), 'Y-m-d'), 'tgl_akhir' => formatTanggal(post('tgl_akhir'), 'Y-m-d'), 'aktif' => post('aktif'), 'tipe' => post('tipe')];
try {
$upload = new Upload('gambar');
$data['gambar'] = $upload->doUpload();
} catch (Exception $e) {
setAlert('error', $e->getMessage());
}
if (Banner::save($data, $id)) {
if ($id) {
setAlert('success', 'Berhasil memperbarui data banner <b>' . $data['judul'] . '</b>');
} else {
setAlert('success', 'Berhasil menambahkan banner <b>' . $data['judul'] . '</b>');
}
return redirect('admin-shop/banners');
}
setAlert('error', 'Terjadi kesalahan dalam penyimpanan banner <b>' . $data['judul'] . '</b>');
return redirect($this->uri->path());
} else {
if ($id) {
$this->data['data'] = Banner::show([Banner::primary() => $id])->fetchOne();
}
return $this->render('banner-form', $this->data);
}
break;
case 'delete':
if (Banner::del([Banner::primary() => $id])) {
setAlert('success', 'Banner berhasil terhapus');
} else {
setAlert('error', 'Terjadi kesalahan dalam penghapusan banner');
}
return redirect('admin-shop/banners');
break;
default:
$this->data['data'] = Banner::show();
return $this->render('banner-table', $this->data);
break;
}
}