本文整理汇总了PHP中Banner::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Banner::find方法的具体用法?PHP Banner::find怎么用?PHP Banner::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Banner
的用法示例。
在下文中一共展示了Banner::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sort
public function sort($id, $sort)
{
if (!in_array($sort, array('up', 'down'))) {
return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '排序失敗!'));
}
$total = Banner::count();
switch ($sort) {
case 'up':
$sort = $this->banner->sort;
$this->banner->sort = $this->banner->sort + 1 >= $total ? 0 : $this->banner->sort + 1;
break;
case 'down':
$sort = $this->banner->sort;
$this->banner->sort = $this->banner->sort - 1 < 0 ? $total - 1 : $this->banner->sort - 1;
break;
}
Banner::addConditions($conditions, 'sort = ?', $this->banner->sort);
$banner = $this->banner;
$update = Banner::transaction(function () use($conditions, $banner, $sort) {
if (($next = Banner::find('one', array('conditions' => $conditions))) && (($next->sort = $sort) || true)) {
if (!$next->save()) {
return false;
}
}
if (!$banner->save()) {
return false;
}
return true;
});
if (!$update) {
return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '排序失敗!', 'posts' => $posts));
}
return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '排序成功!'));
}
示例2: Edit
public function Edit()
{
$input = Input::all();
$banner_id = $input['id'];
$banner = Banner::find($banner_id);
return View::make('admin.banner.add')->with('banner', $banner);
}
示例3: click_action
/**
* Administration view for banner
*/
function click_action($id)
{
$banner = Banner::find($id);
$banner->clicks += 1;
$banner->store();
$this->redirect($banner->getLink());
}
示例4: delete
public function delete($id)
{
$banner = Banner::find($id);
$banner->delete();
Session::flash('success', 'Banner deleted');
return Redirect::to('admin/banners');
}
示例5: createModel
public function createModel()
{
$model = new Banner();
$criteria = new CDbCriteria();
$criteria->select = new CDbExpression('MAX(sort) as sort');
$max = $model->find($criteria);
$model->sort = $max->sort + 10;
return $model;
}
示例6: imprimir
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function imprimir($posicion)
{
$banner = DB::table('banners')->where('posicion', '=', $posicion)->orderBy('visitas', 'asc')->first();
$id = $banner->id;
$banner = Banner::find($id);
$banner->visitas++;
$banner->save();
$url = '/publicidades/' . $banner->file;
$devolver = array($url, $banner->link);
return $devolver;
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @param MenuRequest $request
* @return \Illuminate\Http\Response
*/
public function store(MenuRequest $request)
{
// content input
$menu['title'] = \Input::get('title');
$menu['eng_title'] = \Input::get('eng_title');
$menu['subtitle'] = \Input::get('subtitle');
$menu['eng_subtitle'] = \Input::get('eng_subtitle');
$menu['slug'] = '/' . \trslug::trslug($menu['title']);
$menu['eng_slug'] = '/eng/' . \trslug::trslug($menu['eng_title']);
$menu['header'] = \Input::get('header');
$menu['active'] = \Input::get('active') === "1";
$menu['body'] = \Input::get('body');
$menu['eng_body'] = \Input::get('eng_body');
$menu['line'] = 999;
$menu = Menu::create($menu);
$this->rebuild();
// content polymorphic relations
//banner relations
if (\Input::get('banner')) {
foreach (\Input::get('banner') as $banner) {
Banner::find($banner)->menus()->save($menu);
}
}
//gallery relations
if (\Input::get('gallery')) {
foreach (\Input::get('gallery') as $gallery) {
Gallery::find($gallery)->menus()->save($menu);
}
}
//linkTitles relations
if (\Input::get('linkTitle')) {
foreach (\Input::get('linkTitle') as $linkTitle) {
LinkTitle::find($linkTitle)->menus()->save($menu);
}
}
return \Redirect::back()->with('message', 'Kaydedildi');
}
示例8: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
$validation = Validate::BannerValidation(Input::all());
if ($validation->fails()) {
return Redirect::to('banner/create')->withErrors($validation)->withInput();
} else {
$banner = Banner::find($id);
if ($banner->image != "") {
unlink($banner->image);
}
$banner->title = Input::get('title');
$destinationPath = 'img/banners/' . $banner->id . "/";
$filename = $banner->id . "." . Input::file('image')->getClientOriginalExtension();
Input::file('image')->move($destinationPath, $filename);
$banner->image = $destinationPath . $filename;
$banner->save();
return Redirect::to('admin/banner');
}
}
示例9: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$input = Input::all();
$banner = Banner::find($id)->delete();
return Redirect::to('/banners');
}
示例10: getBanner
public static function getBanner($id)
{
$ban = \Banner::find($id);
['img_src' => $ban->img->url('medium'), 'url' => $ban->url];
}
示例11: aceptarcobro
public function aceptarcobro()
{
$cobropid = Input::get('pagodpid');
$cobrop = CobroPendiente::find($cobropid);
$cobrot = $cobrop->cobro->tipo;
$cobro = $cobrop->cobro;
$usuario = $cobrop->cobro->usuario;
$date_now = new DateTime();
//Copiar datos a un nuevo row de CobroHistorial
$cobroH = new CobroHistorial();
$cobroH->cobro_id = $cobrop->cobro_id;
$cobroH->fechaPago = $date_now;
//Mejorar: Aqui mas bien seria la fecha en la que se registro el pago
$cobroH->metodoPago = $cobrop->metodoPago;
$cobroH->referenciaPago = $cobrop->referenciaPago;
$cobroH->cobro_concepto = $cobrop->cobro_concepto;
$cobroH->cobro_tipo = $cobrot->tipo;
$cobroH->usuario_email = $usuario->email;
$cobroH->cobro_datosAdicionales = $cobro->datosAdicionales;
$cobroH->save();
//Actualizar Cobro
//=> Si es el primer cobro (fechaExpiracion ==null y estado=='pendiente'
if ($cobro->fechaExpiracion == null) {
$expdatetime = $date_now->add(new DateInterval('P' . $cobrot->diasVigencia . 'D'));
$cobro->fechaExpiracion = $expdatetime;
} else {
//Si es un cobro para extender el servicio premium
$fechaEDT = new DateTime($cobro->fechaExpiracion);
if ($fechaEDT < $date_now) {
//si servicio ya estaba expirado
$expdatetime = $date_now->add(new DateInterval('P' . $cobrot->diasVigencia . 'D'));
//Agregar los dias a partir de la fecha actual
} else {
//si servicio todavia no expira
$expdatetime = $fechaEDT->add(new DateInterval('P' . $cobrot->diasVigencia . 'D'));
//Agregar los dias a la fecha de expiracion actual
}
$cobro->fechaExpiracion = $expdatetime;
}
$cobro->estado = 'pagado';
//TODO: Falta ver seria un estado diferente cuando se paga por primera vez o las demas veces
$cobro->save();
//Borrar row de cobroPendiente
$cobrop->delete();
//Aqui ya depende del tipo de cobro
if ($cobrot->tipo == 'ser_proveedor') {
//regresar campo 'solicitar_premium' de 1 a 0 y poner habilitar a 1
$prov = Proveedor::find($cobro->datosAdicionales);
$prov->solicitar_premium = 0;
$prov->habilitar = 1;
$prov->no_primer_cobro = 1;
$prov->save();
}
if ($cobrot->tipo == 'clasificado_premium') {
//regresar campo 'solicitar_premium' de 1 a 0 y poner campo premium a 1
$clas = Clasificado::find($cobro->datosAdicionales);
$clas->solicitar_premium = 0;
$clas->premium = 1;
$clas->no_primer_cobro = 1;
$clas->save();
}
if ($cobrot->tipo == 'imagen_proveedor') {
//poner campo 'premium' 1 a 2
$provimg = ProveedorGaleria::find($cobro->datosAdicionales);
$provimg->premium = 2;
$provimg->no_primer_cobro = 1;
$provimg->save();
}
$cobrotipoprefix = substr($cobrot->tipo, 0, 7);
if ($cobrotipoprefix == 'BANNER-') {
//poner solicitar_habilitar a 0 y habilitar a 1
$banner = Banner::find($cobro->datosAdicionales);
$banner->solicitar_habilitar = 0;
$banner->habilitar = 1;
$banner->no_primer_cobro = 1;
$banner->save();
}
return Redirect::to('/administracion/pagospendientes');
}
示例12: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$banner = Banner::find($id);
if ($banner->foto) {
$fotolama = $banner->foto;
$filepath = public_path() . DIRECTORY_SEPARATOR . 'uploads/banner' . DIRECTORY_SEPARATOR . $banner->foto;
try {
File::delete($filepath);
} catch (FileNotFoundException $e) {
}
}
$banner->delete();
return Redirect::to('admin/banner')->with('pesan', "<hr><div class='alert alert-info'>Data Berhasil dihapus</div>");
}
示例13: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
$authuser = Auth::user();
$banner = Banner::find($id);
//return $clasificado;
$img = $banner->imagen;
File::delete('images/banners/' . $img);
//TODO: Borrar cobro asociado
$banner->delete();
// redirect
Session::flash('message', 'El banner ha sido eliminado exitosamente!');
return Redirect::to('vistausuario/banners')->with(array('usuarioimg' => $authuser->imagen, 'usuarionombre' => $authuser->nombre, 'usuarioid' => $authuser->id));
}
示例14: edit
/**
* Show the form for editing the specified resource.
* GET /banners/{id}/edit
*
* @param int $id
* @return Response
*/
public function edit($id = NULL)
{
parent::show();
$banner = Banner::find($id);
$path = $this->banner_path;
return View::make('banners.edit', compact('banner', 'path'));
}
示例15: delete_action
/**
*
* @param type $banner_id
*/
public function delete_action($banner_id)
{
if (Request::int('delete') == 1) {
Banner::find($banner_id)->delete();
PageLayout::postMessage(MessageBox::success(_('Das Banner wurde erfolgreich gelöscht!')));
} elseif (!Request::get('back')) {
$this->flash['delete'] = compact('banner_id');
}
$this->redirect('admin/banner');
}