本文整理汇总了PHP中Photo::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::where方法的具体用法?PHP Photo::where怎么用?PHP Photo::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photo
的用法示例。
在下文中一共展示了Photo::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_index
public function get_index($city = null)
{
$inputs = array('pmin' => Input::get('pmin'), 'pmax' => Input::get('pmax'), 'smin' => Input::get('smin'), 'smax' => Input::get('smax'), 'smoking' => Input::get('smoking'), 'pets' => Input::get('pets'), 'toilet' => Input::get('toilet'), 'shower' => Input::get('shower'), 'kitchen' => Input::get('kitchen'), 'order' => Input::get('order'));
if (!is_null($city)) {
$inputs['city'] = str_replace('-', ' ', $city);
} else {
$inputs['city'] = Input::get('city');
}
$rules = array('city' => 'exists:photos, city');
$v = Validator::make($inputs['city'], $rules);
$query = Room::where('status', '=', 'publish');
if (!empty($inputs['city'])) {
$city = $inputs['city'];
$query->where(function ($query) use($city) {
$query->where('city', 'LIKE', '%' . $city . '%');
$query->or_where('description', 'LIKE', '%' . $city . '%');
$query->or_where('title', 'LIKE', '%' . $city . '%');
});
}
if (!empty($inputs['pmin']) && !empty($inputs['pmax'])) {
$query->where('price', '>', $inputs['pmin']);
$query->where('price', '<', $inputs['pmax']);
}
if (!empty($inputs['smin']) && !empty($inputs['smax'])) {
$query->where('surface', '>', $inputs['smin']);
$query->where('surface', '<', $inputs['smax']);
}
if (!empty($inputs['smoking'])) {
$query->where('smoking', '=', $inputs['smoking']);
}
if (!empty($inputs['pets'])) {
$query->where('pets', '=', $inputs['pets']);
}
if (!empty($inputs['toilet'])) {
$query->where('toilet', '=', $inputs['toilet']);
}
if (!empty($inputs['shower'])) {
$query->where('shower', '=', $inputs['shower']);
}
if (!empty($inputs['kitchen'])) {
$query->where('kitchen', '=', $inputs['kitchen']);
}
if (!empty($inputs['order']) && $inputs['order'] == 'price' || $inputs['order'] == 'created_at') {
$query->order_by($inputs['order'], 'desc');
} else {
$query->order_by("created_at", 'desc');
}
$total = $query->get();
$rooms = $query->paginate(Room::$per_page);
Input::flash();
if (!$v->fails()) {
$bgphoto = Photo::where('city', '=', $inputs['city'])->first();
return View::make('home.search')->with('total', $total)->with('bgphoto', $bgphoto)->with('city', $city)->with('rooms', $rooms);
} else {
return View::make('home.search')->with('total', $total)->with('rooms', $rooms);
}
}
示例2: getSession
public function getSession($id)
{
$data = array();
$social_actions = SocialAction::with('socialTarget', 'user')->where('id', $id)->first();
if ($social_actions == false) {
return App::abort('404');
}
$photos = Photo::where('type_name', '=', 'social_actions')->where('type_id', '=', $social_actions->id)->where('status', '=', 1)->get();
$donations = Donation::with(array('user'))->where('type_name', '=', 'social_actions')->where('type_id', '=', $social_actions->id)->where('status', '=', 1)->orderBy('id', 'desc')->get();
$user = User::getUserId($social_actions->user_id);
$social_target_id = SocialTarget::getAll();
$social_action_category_id = SocialActionCategory::getAll();
$city_id = City::getAll();
$data = array('social_action' => $social_actions, 'photos' => $photos, 'donations' => $donations, 'user' => $user, 'social_target_id' => $social_target_id, 'social_action_category_id' => $social_action_category_id, 'city_id' => $city_id);
Session::put('type_name', 'SocialAction');
Session::put('type_id', $social_actions->social_target_id);
return Redirect::route('buat-aksi-sosial');
}
示例3: getSession
public function getSession($id)
{
// init
$data = array();
$event = Events::where('id', $id)->first();
if ($event == false) {
return App::abort('404');
}
$data['view'] = $event;
// // get photos
$data['photos'] = Photo::where('type_name', '=', 'events')->where('type_id', '=', $event->id)->where('status', '=', 1)->get();
$data['social_actions'] = SocialAction::with(array('city', 'category'))->join('social_action_events', 'social_action_events.social_action_id', '=', 'social_actions.id')->where('event_id', '=', $event->id)->where('social_actions.status', '=', 1)->orderBy('social_actions.id', 'desc')->get();
$data['social_target_id'] = SocialTarget::getAll();
$data['social_action_category_id'] = SocialActionCategory::getAll();
$data['city_id'] = City::getAll();
Session::put('type_name', 'Events');
Session::forget('type_id');
Session::put('event_id', $event['id']);
return Redirect::route('buat-aksi-sosial');
}
示例4: show
public function show($id)
{
// get social target
$user = User::with('city')->find($id);
if ($user == null) {
return App::abort('404');
}
// init
$data = array('menu' => $this->_menu, 'title' => 'Nama pengguna - ' . $user->firstname . ' ' . $user->lastname, 'description' => '', 'breadcrumb' => array('Pengguna Bagikasih' => route('admin.user'), $user->firstname => route('admin.user.show', $user->id)));
$data['users'] = $user;
$social_target = SocialTarget::with(array('city', 'category', 'user'))->where('user_id', $user->id)->get();
// Get Social Target
$data['social_target'] = $social_target;
// Get Social Actions that related with this
$data['social_actions'] = SocialAction::with(array('city', 'category', 'user'))->where('user_id', '=', $user->id)->orderBy('id', 'desc')->get();
// Get Donations that related with this
$data['donations'] = Donation::with(array('user'))->where('type_name', '=', 'users')->where('type_id', '=', $user->id)->orderBy('id', 'desc')->get();
// Get Photos that related with this
$data['photos'] = Photo::where('type_name', '=', 'users')->where('type_id', '=', $user->id)->orderBy('id', 'desc')->get();
return View::make('admin.pages.user.show')->with($data);
}
示例5: getSession
public function getSession($id)
{
// init
$data = array();
// get social target data - with slug
$social_target = SocialTarget::with(array('city', 'category'))->where('id', '=', $id)->where('status', '=', 1)->first();
if ($social_target == null) {
return App::abort('404');
}
// get photos
$photos = Photo::where('type_name', '=', 'social_targets')->where('type_id', '=', $social_target->id)->where('status', '=', 1)->get();
// get social actions
$social_actions = SocialAction::with(array('city', 'category'))->where('social_target_id', '=', $social_target->id)->where('status', '=', 1)->orderBy('id', 'desc')->get();
// set data
$data = array('social_target' => $social_target, 'photos' => $photos, 'social_actions' => $social_actions);
$data['social_target_id'] = SocialTarget::getAll();
$data['social_action_category_id'] = SocialActionCategory::getAll();
$data['city_id'] = City::getAll();
Session::put('type_name', 'SocialTarget');
Session::put('type_id', $social_target->id);
return Redirect::route('buat-aksi-sosial');
}
示例6: remove
/**
* undocumented function
*
* @return void
* @author
**/
public static function remove($id)
{
$lokasi = public_path() . '/photos/';
$data = Photo::where('id', $id)->first();
if (is_null($data) === false) {
$data->delete();
if (file_exists($lokasi . $id . '.jpg')) {
unlink($lokasi . $id . '.jpg');
}
if (file_exists($lokasi . 'thumb_' . $id . '.jpg')) {
unlink($lokasi . 'thumb_' . $id . '.jpg');
}
}
}
示例7: foreach
<?php
if ($sliders = Dictionary::valuesBySlug('main_baners', function ($query) {
$query->orderBy('lft', 'ASC');
}, 'all', TRUE)) {
foreach ($sliders as $index => $slider) {
if ($slider['photo']) {
$sliders[$index]['photo_name'] = Photo::where('id', $slider['photo'])->pluck('name');
}
}
}
if ($communications = Dictionary::valuesBySlug('communications_units', function ($query) {
$query->orderBy('lft', 'ASC');
}, 'all', TRUE)) {
foreach ($communications as $index => $communication) {
if ($communication['photo']) {
$communications[$index]['photo_name'] = Photo::where('id', $communication['photo'])->pluck('name');
}
}
}
$gallery = array();
if (Gallery::where('name', 'Галерея на главной')->exists()) {
$gallery = Gallery::where('name', 'Галерея на главной')->first()->photos;
}
?>
@extends(Helper::layout())
@section('style')
@stop
@section('content')
@if(count($sliders))
<div class="index-slider js-index-slider">
<div class="slider__list">
示例8: updatePost
public function updatePost()
{
if (Request::isMethod('post')) {
$input = Input::all();
$updateEvent = SocialTarget::UpdateSocialTarget($input);
$CountPhoto = Photo::where('tmp', Session::get('time'))->count();
if ($CountPhoto > 0) {
Photo::updatePhotos('social_targets', $input['id']);
Photo::roolback();
}
if ($updateEvent != 'ok') {
// get session validation
Session::put('validasi', 'social_targets');
Session::flash('validasi', $updateEvent);
return Redirect::route('admin.social-target.update', $input['id'])->withInput();
} else {
Session::flash('sukses', 'Target Sosial Berhasil di Update');
return Redirect::route('admin.social-target')->withInput();
}
}
}
示例9: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$photo = Photo::where('id', $id);
$photo->delete();
return Response::json(array('error' => false, 'message' => 'photo deleted'), 200);
}
示例10: updatePost
public function updatePost()
{
if (Request::isMethod('post')) {
$input = Input::all();
$updateEvent = Events::UpdateEvent($input);
// check if any mutliple upload photo
$CountPhoto = Photo::where('user_id', Auth::user()->id)->where('tmp', Session::get('time'))->count();
if ($CountPhoto > 0) {
// update photo
Photo::updatePhotos('events', $input['id']);
Photo::rollback();
}
if ($updateEvent != 'ok') {
// get session validation
Session::put('validasi', 'event');
Session::flash('validasi', $updateEvent);
return Redirect::route('admin.event.update', $input['id'])->withInput();
} else {
Session::flash('sukses', 'Events Berhasil di Update');
return Redirect::route('admin.event')->withInput();
}
}
}
示例11: update
/**
* Update the specified resource in storage.
* PUT /articles/{slug}
*
* @param int $slug
* @return Response
*/
public function update($slug)
{
$thumbPath = Input::get('thumbPath');
$thumbId = Input::get('thumbId');
$image = Input::file('image');
$article = Article::where('slug', $slug)->first();
$article->title = Input::get('title');
$article->body = Input::get('body');
$article->category_id = Input::get('category_id');
$article->save();
if ($image) {
File::delete($thumbPath);
$file = Photo::where('id', $thumbId)->delete();
$thumb = new Photo();
$image = Input::file('image');
$filename = time() . '-' . $image->getClientOriginalName();
$destinationPath = public_path('thumbs/' . $filename);
$a = Image::make($image->getRealPath())->fit(1280, 720)->save($destinationPath, 50);
// SAVE TO DB
$thumb->image = 'thumbs/' . $filename;
$thumb->article_id = $article->id;
$thumb->save();
return Redirect::to('/dashboard')->with('message', 'Thumbnail updated successfully');
} else {
return Redirect::to('/dashboard')->with('message', 'Article Updated successfully');
}
// return View::make('admin.home')->withMessage('Article Saved!');
}
示例12: getAlbumIdYoungerThanDay
public static function getAlbumIdYoungerThanDay($year, $month, $day, $pagination = 30)
{
$day = Photo::checkDay($year, $month, $day);
return Photo::where(function ($query) use($year, $month, $day) {
$query->where(DB::raw('YEAR(created_at)'), '>', $year)->orWhere(function ($iq) use($year, $month, $day) {
$iq->where(DB::raw('YEAR(created_at)'), '=', $year)->where(DB::raw('MONTH(created_at)'), '>', $month)->orWhere(function ($iiq) use($year, $month, $day) {
$iiq->where(DB::raw('YEAR(created_at)'), '=', $year)->where(DB::raw('MONTH(created_at)'), '=', $month)->where(DB::raw('DAYOFMONTH(created_at)'), '>=', $day);
});
});
})->lists('album_id');
}
示例13: deleteUploadedImageFile
public static function deleteUploadedImageFile($image_id)
{
if ($image_id) {
$photo = Photo::where('id', $image_id)->first();
if (File::exists(Config::get('site.galleries_photo_dir') . '/' . $photo->name)) {
File::delete(Config::get('site.galleries_photo_dir') . '/' . $photo->name);
}
$photo->delete();
return TRUE;
} else {
return FALSE;
}
}
示例14: updatePost
public function updatePost()
{
if (Request::isMethod('post')) {
$input = Input::all();
$updateSocialAction = SocialAction::UpdateSocialAction($input);
// check if any mutliple upload photo
$CountPhoto = Photo::where('tmp', Session::get('time'))->count();
if ($CountPhoto > 0) {
Photo::updatePhotos('social_actions', $input['id']);
Photo::roolback();
}
if ($updateSocialAction != 'ok') {
Session::flash('validasi', $updateSocialAction);
return Redirect::route('admin.social-action.update', array($input['id']))->withInput();
} else {
// get session validation
Session::put('validasi', 'social_actions');
Session::flash('sukses', 'Aksi Sosial Berhasil di Update');
return Redirect::route('admin.social-action')->withInput();
}
}
}
示例15: function
}
});
Route::get('users', function () {
$users = User::all();
return Response::json(array('error' => false, 'users' => $users), 200);
});
Route::get('passwords', function () {
$users = User::all();
foreach ($users as $user) {
echo $user->password;
}
});
//index for list
Route::get('api/v1/photos', array('uses' => 'PhotoController@showPhotosIndex'));
Route::get('api/v1/photos/{user_id}', function ($user_id) {
$photos = Photo::where('user_id', $user_id)->get();
if ($user_id == Auth::user()->id) {
return Response::json(array('error' => false, 'edit' => true, 'photos' => $photos), 200);
} else {
return Response::json(array('error' => false, 'edit' => false, 'photos' => $photos), 200);
}
});
Route::group(array('prefix' => 'api/v1/'), function () {
Route::resource('myphotos', 'PhotoController');
});
Route::get('login', array('uses' => 'HomeController@showLogin'));
// route to process the form
Route::post('login', array('uses' => 'HomeController@doLogin'));
Route::post('register', array('uses' => 'HomeController@doRegister'));
Route::get('logout', array('uses' => 'HomeController@showLogout'));
Route::post('logout', array('uses' => 'HomeController@doLogout'));