Example #1
0
 public function __construct(Request $request, Banner $banners)
 {
     if (Auth::user() && Auth::user()->profile->city_id != null) {
         $model = Banner::where('paid', '1')->where('paid_up', '>=', new \DateTime('today'))->where('city_id', '=', Auth::user()->profile->city_id)->get();
         $blockIndex = 0;
         $bannerIndex = 0;
         foreach ($model as $one) {
             if ($blockIndex == self::BLOCK_COUNT) {
                 $bannerIndex++;
                 $blockIndex = 0;
             }
             $this->blocks[$blockIndex++][$bannerIndex] = $one;
         }
     } else {
         $model = Banner::where('paid', '1')->where('paid_up', '>=', new \DateTime('today'))->get();
         $blockIndex = 0;
         $bannerIndex = 0;
         foreach ($model as $one) {
             if ($blockIndex == self::BLOCK_COUNT) {
                 $bannerIndex++;
                 $blockIndex = 0;
             }
             $this->blocks[$blockIndex++][$bannerIndex] = $one;
         }
     }
 }
Example #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;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function __construct()
 {
     $setting = Models\Setting::first();
     $this->data['menu'] = Models\Menu::with('child')->where('level', 0)->get();
     $this->data['berita'] = Models\Berita::orderBy('id_berita', 'desc')->limit(6)->get();
     $this->data['pengumuman'] = Models\Pengumuman::orderBy('tanggal', 'desc')->limit(10)->get();
     $this->data['agenda'] = Models\Agenda::orderBy('tgl_posting', 'desc')->limit(5)->get();
     $this->data['polling'] = Models\Polling::with('jawaban')->where('status', 'Y')->limit(1)->first();
     $this->data['title'] = $setting->title_web;
     $this->data['desc'] = $setting->desc_web;
     $this->data['key'] = $setting->key_web;
     $this->data['logo'] = $setting->logo;
     $this->data['header_img'] = $setting->bg_header;
     $this->data['icon'] = $setting->favicon;
     $this->data['facebook'] = $setting->facebook;
     $this->data['peta_latitude'] = $setting->peta_latitude;
     $this->data['peta_longitude'] = $setting->peta_longitude;
     $this->data['twitter'] = $setting->twitter;
     $this->data['gplus'] = $setting->gplus;
     $this->data['slider_home'] = Models\Berita::orderBy('tanggal', 'desc')->limit(5)->get();
     $this->data['galeri_home'] = Models\Foto::OrderBy('id_foto', 'desc')->paginate(9);
     $this->data['opini_home'] = Models\Berita::where('kategori_berita', 5)->orderBy('id_berita', 'desc')->limit(6)->get();
     $this->data['banner'] = Models\Banner::where('id', 1)->first();
     $this->data['link'] = Models\Link::orderBy('id', 'desc')->limit(5)->get();
     $this->data['publikasi'] = Models\Publikasi::orderBy('id', 'desc')->limit(3)->get();
     $this->data['setting'] = $setting;
 }
Example #4
0
 public function destroy($id)
 {
     $banner = Banner::find($id);
     $banner->delete();
     flash()->success('操作成功');
     return redirect()->route('dashboard.banner.index');
 }
Example #5
0
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function getIndex()
 {
     $featuredProjects = Project::where('active', '1')->where('live', '1')->where('status', '3')->orderBy('id', 'desc')->take(3)->get();
     $recentlyAddedProjects = Project::where('active', '1')->where('live', '1')->orderBy('created_at', 'desc')->take(3)->get();
     $sliderImgs = Banner::where('active', '1')->orderBy('created_at', 'desc')->get();
     return view('welcome', ['_featuredProducts' => $featuredProjects, '_recently_added' => $recentlyAddedProjects, '_menus' => $this->menuItems, '_sliders' => $sliderImgs, 'login_url' => $this->login_url]);
 }
Example #6
0
 public function loadModel($id)
 {
     $model = \app\models\Banner::findOne($id);
     if ($model === null) {
         throw new \yii\web\HttpException(404, 'Запрашиваемая страница не существует.');
     }
     return $model;
 }
Example #7
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //banner
     $banners = Banner::orderBy('created_at', 'DESC')->take(7)->get();
     //最新
     $last_articles = Article::with('author')->orderBy('created_time', 'DESC')->take(12)->get();
     $hot_articles = Article::orderBy('views', 'DESC')->take(10)->get();
     return view('home', compact('banners', 'last_articles', 'hot_articles'));
 }
Example #8
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     //if(!parent::authorize()) return false;
     if ($this->banner) {
         if ($this->user()->isAdmin()) {
             return true;
         }
         return Banner::where('id', $this->banner)->where('user_id', $this->user()->id)->exists();
     }
     return true;
 }
Example #9
0
 public function decline($bannerId)
 {
     $banner = Banner::findOrFail($bannerId);
     if ($banner->twitcher_id != $this->user->id) {
         return redirect('/user/twitcher');
     }
     if ($banner->is_active == 1 || $banner->status != 'waiting') {
         return redirect('/user/twitcher');
     }
     BannerMapper::declineBanner($banner);
     return Redirect::to('/user/twitcher')->with(['success' => 'You declined banner']);
 }
Example #10
0
 /**
  * Display the home page.
  *
  * @return Response
  */
 public function index()
 {
     $url = config('medias.image-host');
     $film_url = config('medias.film-host');
     //hien thi film hot, sap xep moi nhat len tren
     $filmCondition = ['publish' => 1, 'isHot' => 1];
     $films = $this->film->where($filmCondition)->orderBy('created_at', 'desc')->get();
     //$banners = $this->getBanner();
     $cond = ['publish' => 1, 'sub_cat_id' => 5];
     $banners = Banner::where($cond)->get();
     return view('front.index', compact('films', 'url', 'film_url', 'banners'));
 }
Example #11
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;
 }
Example #12
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;
 }
Example #13
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;
 }
 public function search($input)
 {
     $query = Banner::query();
     $columns = Schema::getColumnListing('banners');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
Example #15
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;
 }
Example #16
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;
 }
 /**
  * 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');
     }
 }
Example #18
0
 public function complainDeclineSave($streamId, $bannerId, Request $request)
 {
     $stream = Stream::findOrFail($streamId);
     $banner = Banner::findOrFail($bannerId);
     if ($stream->user_id != $this->user->id) {
         return Redirect::to('/user/twitcher/streams')->withErrors('You have no rights for this');
     }
     $pivot = StreamMapper::getPivot($banner, $stream);
     if ($pivot->status != 'declining') {
         return Redirect::to('/user/twitcher/stream/' . $stream->id)->withErrors('Stream is not declining');
     }
     $this->validate($request, ['comment' => 'required|min:5']);
     $comment = $request->get('comment');
     $pivot->status = 'complain';
     $pivot->twitcher_comment = $comment;
     $pivot->save();
     LogMapper::log('banner_complained', $banner->id, $stream->id);
     NotificationMapper::bannerPayComplained($banner, $stream, $pivot->amount);
     return Redirect::to('/user/twitcher/stream/' . $stream->id)->with(['success' => 'You complained about banner declined']);
 }
Example #19
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();
 }
Example #20
0
<?php

use app\models\Banner;
use app\assets\DatatableAsset;
$banner = Banner::getBanner();
?>

<div class="panel panel-default">
	<div class="panel-heading"><?php 
echo $menu['label'];
?>
设置</div>
	<div class="panel-body">
	<p><a class="modals" modal="#addbanner">添加导航</a></p>
	<table class="table table-striped" id="bannerlist">
		<tr>
			<th width=20%>名称</th>
			<th width=50%>URL</th>
			<th width=15%>排序</th>
			<th width=15%>操作</th>
		</tr>
<?php 
if ($banner) {
    foreach ($banner as $row) {
        ?>
		<tr>
		<td><?php 
        echo $row['name'];
        ?>
</td>
		<td><a href="<?php 
Example #21
0
 public function getIndex()
 {
     $attach['banners'] = Banner::all();
     return view('home.index', $attach);
 }
Example #22
0
 public function getBannerlist()
 {
     $sliderImgs = Banner::all();
     return $sliderImgs;
 }
Example #23
0
<?php

if (Yii::$app->user->isGuest) {
    $items = [['label' => '登录', 'url' => '/user/login']];
} else {
    $items = [['label' => '<img src="' . Yii::$app->user->identity->avatar . '" width=25 height=25>', 'url' => '/user', 'style' => 'border-radius:2px;'], ['label' => '个人中心', 'url' => '/user'], ['label' => '登出 (' . Yii::$app->user->identity->username . ')', 'url' => '/user/logout']];
}
$banners = \app\models\Banner::getBanner();
?>
		<div class="topbar">
			<div class="container">
				<div class="">
					<ul class="topbar-left">
						<li><a href="/">首页</a></li>
<?php 
foreach ($banners as $banner) {
    if (is_array($banner['child'])) {
        ?>
			<li class="dropdown">
				<a class="dropdown-toggle" data-toggle="dropdown" href="#"><?php 
        echo $banner['name'];
        ?>
<span class="caret"></span></a>
				<ul class="dropdown-menu" role="menu">
<?php 
        foreach ($banner['child'] as $child) {
            ?>
					<li><a href="<?php 
            echo $child['url'];
            ?>
"><?php 
Example #24
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy(Banner $banner)
 {
     $image = Attachment::where('id', $banner->attachment_id);
     $banner->delete();
     $image->delete();
     return redirect()->route('admin.banner.index');
 }
Example #25
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) {
        ?>
 /**
  * Finds the Banner model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Banner the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Banner::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #27
0
 public function actionIndex()
 {
     $bannerList = Banner::bannerList();
     return $this->render('index', ['bannerList' => $bannerList]);
 }
Example #28
0
 public function declineSave($streamId, $bannerId, Request $request)
 {
     $stream = Stream::findOrFail($streamId);
     $banner = Banner::findOrFail($bannerId);
     if (!StreamMapper::checkOwner($this->user, $banner, $stream)) {
         return Redirect::to('/user/client/streams')->withErrors('You have no rights for this');
     }
     if ($stream->time_end == null) {
         return Redirect::to('/user/client/stream/' . $stream->id)->withErrors('Stream is still live');
     }
     $pivot = StreamMapper::getPivot($banner, $stream);
     if ($pivot->status != 'waiting') {
         return Redirect::to('/user/client/stream/' . $stream->id)->withErrors('Stream is not for paying');
     }
     $isFinished = $this->isStreamFinished($stream);
     if (!$isFinished) {
         return Redirect::to('/user/client/stream/' . $stream->id)->withErrors('Stream is still alive');
     }
     $this->validate($request, ['comment' => 'required|min:5']);
     $comment = $request->get('comment');
     $pivot->status = 'declining';
     $pivot->client_comment = $comment;
     $pivot->save();
     LogMapper::log('banner_declining', $banner->id, $stream->id);
     NotificationMapper::bannerPayDeclining($banner, $stream, $pivot->amount);
     return Redirect::to('/user/client/stream/' . $stream->id)->with(['success' => 'You declined to pay the banner in this stream']);
 }
Example #29
0
 public function updateStatus($status, $id)
 {
     try {
         $dado = Banner::findOrFail($id);
         $dado->status = $status;
         $dado->save();
         session()->flash('flash_message', 'Status alterado com sucesso!');
     } catch (\Exception $e) {
         LogR::exception($dado, $e);
         session()->flash('flash_message', 'Ops!! Ocorreu algum problema!. ' . $e->getMessage());
     }
     return Redirect::back();
 }
Example #30
0
<?php

// Home
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'home']);
View::composer('partials.menu', function ($view) {
    $view->with('menuitems', \App\Models\Menu::orderBy('weight')->get());
});
View::composer('partials.categories', function ($view) {
    $view->with('categories', \App\Models\Category::tree());
});
View::composer('banners.index', function ($view) {
    $view->with('banners', \App\Models\Banner::all());
});
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController', 'products' => 'ProductController', 'user' => 'UserController', 'cart' => 'CartController']);
Route::group(['middleware' => ['auth']], function () {
    Route::controllers(['order' => 'OrderController', 'user' => 'UserController']);
});
/* < Admin > */
Route::get('admin', function () {
    return Redirect::to('admin/products');
});
Route::get('/ipn', 'Robokassa\\RobokassaController@getResult');
Route::post('/create_payment', 'Robokassa\\PaymentController@createPayment');
Route::group(['middleware' => ['auth', 'admin']], function () {
    Route::controllers(['admin/orders' => 'Admin\\OrderController', 'admin/order_products' => 'Admin\\OrderProductController', 'admin/categories' => 'Admin\\CategoryController', 'admin/products' => 'Admin\\ProductController', 'admin/productimage' => 'Admin\\ProductImageController', 'admin/users' => 'Admin\\UserController', 'admin/menu' => 'Admin\\MenuController', 'admin/currency' => 'Admin\\CurrencyController', 'admin/slider' => 'Admin\\SliderController', 'admin/blocks_content' => 'Admin\\BlocksContentController', 'admin/blocks_content_products' => 'Admin\\BlocksContentProductsController', 'admin/stat' => 'Admin\\StatisticController', 'admin/banners' => 'Admin\\BannerController']);
});
/* </ Admin > */
Route::any("/{slug}", array("as" => "content", "uses" => "MenuController@content"));