Пример #1
0
 public function destroy($id)
 {
     $banner = Banner::find($id);
     $banner->delete();
     flash()->success('操作成功');
     return redirect()->route('dashboard.banner.index');
 }
Пример #2
0
 /**
  * @return mixed
  */
 private static function getRandomBannerByPosition($position_id)
 {
     $banners = Banner::find()->where(['position_id' => $position_id, 'is_active' => 1])->all();
     $count = count($banners);
     $random_banner = rand(0, $count - 1);
     return isset($banners[$random_banner]) ? $banners[$random_banner]->file_name : null;
 }
Пример #3
0
 public function actionIndex()
 {
     $model = \app\models\Banner::find();
     $countModel = clone $model;
     $pagination = new Pagination(['totalCount' => $countModel->count(), 'pageSize' => 10]);
     $banners = \app\models\Banner::find()->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['banners' => $banners, 'count' => $countModel->count(), 'limit' => $pagination->limit, 'offset' => $pagination->offset, 'pagination' => $pagination]);
 }
Пример #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Banner::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'position_id' => $this->position_id, 'is_active' => $this->is_active, 'timestamp' => $this->timestamp]);
     $query->andFilterWhere(['like', 'file_name', $this->file_name]);
     return $dataProvider;
 }
Пример #5
0
 public static function pids()
 {
     $pids = Banner::find()->where(['pid' => 0])->asArray()->all();
     $data = [0 => '无'];
     if (!$pids) {
         return $data;
     }
     foreach ($pids as $pid) {
         $data[$pid['id']] = $pid['name'];
     }
     return $data;
 }
Пример #6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Banner::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'filename', $this->filename])->andFilterWhere(['like', 'caption', $this->caption])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Пример #7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Banner::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'zone', $this->zone])->andFilterWhere(['like', 'link', $this->link]);
     return $dataProvider;
 }
Пример #8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Banner::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['banner_id' => $this->banner_id, 'domestic_ip' => $this->domestic_ip, 'created' => $this->created, 'expiration' => $this->expiration, 'scheduled' => $this->scheduled, 'status_change' => $this->status_change, 'show_in_affilate' => $this->show_in_affilate, 'active' => $this->active, 'sort_order' => $this->sort_order]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'group', $this->group])->andFilterWhere(['like', 'html_text', $this->html_text])->andFilterWhere(['like', 'language', $this->language])->andFilterWhere(['like', 'category_id', $this->category_id])->andFilterWhere(['like', 'bgcolor', $this->bgcolor]);
     return $dataProvider;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $banner = Banner::find(1);
     $cekinputgbr = Input::file('file');
     if (!empty($cekinputgbr)) {
         $oldfile = Banner::where('id', 1)->first();
         File::delete('upload/banner/' . $oldfile->gambar);
         $thefile = Input::file('file');
         $lokasi_simpan = 'upload/banner';
         $filename = str_random(30) . '.' . $thefile->getClientOriginalExtension();
         $upload_gambar = Input::file('file')->move($lokasi_simpan, $filename);
         $banner->gambar = $filename;
     }
     $banner->url = Input::get('url_banner');
     $banner->aktif = Input::get('status');
     if ($banner->save()) {
         return redirect()->to('admin/banner')->with('alert', 'Data berhasil di simpan');
     }
 }
Пример #10
0
 public function postUpdate()
 {
     $id = Input::get('id');
     $banner = Banner::find($id);
     if ($banner) {
         $banner->video_url = Input::get('video_url');
         $banner->title = Input::get('title');
         $image = Input::file('image');
         if ($image) {
             $image_title = $image->getClientOriginalName();
             $filename = date('Y-m-d-H:i:s') . "-" . $image_title;
             $path = public_path('img/banners/' . $filename);
             $path_thumb = public_path('img/banners/thumb/' . $filename);
             Image::make($image->getRealPath())->resize(624, 97)->save($path);
             Image::make($image->getRealPath())->resize(130, 25)->save($path_thumb);
             $banner->image = $filename;
         }
         $banner->save();
     }
     return Redirect::back();
 }
Пример #11
0
<?php

/** @var $zone string */
use app\models\Banner;
/** @var Banner[] $list */
$list = Banner::find()->where(['zone' => $zone, 'active' => 1])->orderBy(['position' => SORT_ASC])->all();
if (count($list) > 1) {
    ?>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
        <?php 
    foreach ($list as $index => $banner) {
        ?>
        <li data-target="#carousel-example-generic" data-slide-to="<?php 
        echo $index;
        ?>
" class="<?php 
        echo $index == 0 ? 'active' : '';
        ?>
"></li>
        <?php 
    }
    ?>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
        <?php 
    foreach ($list as $index => $banner) {
        ?>
Пример #12
0
 public function postBanner(Request $request)
 {
     if ($request->has('file') && $request->has('id')) {
         $banner = Banner::find($request->id);
         $banner->file = $request->file;
         $banner->description = $request->description;
         $banner->save();
     }
     return json_encode(true);
 }
Пример #13
0
 /**
  * Lists all Banner models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Banner::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Пример #14
0
<?php

use yii\helpers\Html;
use yii\bootstrap\Carousel;
use yii\db\Query;
use app\models\Category;
use app\models\Banner;
use app\models\Classroom;
use app\models\News;
$connection = \Yii::$app->db;
/* @var $this yii\web\View */
$this->title = 'ศูนย์ฝึกอบรมคอมพิวเตอร์';
$banners = Banner::find()->where(['status' => 'Y'])->all();
$items = [];
if (!empty($banners)) {
    foreach ($banners as $value) {
        $items[] = ['content' => '<img src="' . Yii::getAlias('@web') . '/uploads/banner/' . $value->filename . '"/>', 'options' => ['interval' => '600']];
    }
}
echo Carousel::widget(['items' => $items, 'options' => ['class' => 'Carousel slide'], 'controls' => ['<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>', '<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>']]);
?>
<!--
<div class="sdu-promo">
    <div class="container">
        <div class="col-sm-9">
            <h3><b>"โปรโมชั่น"</b> นะครับ</h3>
        </div>
        <div class="col-sm-3">
            <a class="btn btn-default" href="#">Donate Now</a>
        </div>
    </div>
Пример #15
0
 public static function getBanner()
 {
     $data = Banner::find()->orderBy(['sortno' => SORT_ASC, 'id' => SORT_DESC])->asArray()->all();
     return self::format($data);
 }