예제 #1
0
 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);
     }
 }
 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
0
 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
0
 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);
 }
 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
0
 /**
  * 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
0
 <?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">
 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();
         }
     }
 }
 /**
  * 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
0
 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
0
 /**
  * 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
0
파일: Photo.php 프로젝트: rituzy/iblog
 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');
 }
 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;
     }
 }
 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
0
    }
});
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'));
예제 #16
0
 public static function returnExtFormElements()
 {
     $mod_tpl = static::returnTpl();
     $class = __CLASS__;
     ##
     ## EXTFORM GALLERY
     ##
     /*
     ################################################
     ## Process gallery
     ################################################
     if (Allow::action('admin_galleries', 'edit')) {
         ExtForm::process('gallery', array(
             'module'  => self::$name,
             'unit_id' => $id,
             'gallery' => Input::get('gallery'),
         ));
     }
     ################################################
     */
     ExtForm::add("gallery", function ($name = 'gallery', $value = '', $params = null) use($mod_tpl, $class) {
         ## default template
         $tpl = "extform_gallery";
         ## custom template
         if (@$params['tpl']) {
             $tpl = $params['tpl'];
             unset($params['tpl']);
         }
         #Helper::dd($value);
         #Helper::dd($params);
         if (!is_object($value)) {
             $gallery = NULL;
         }
         if ($value === false || $value === null) {
             $val = Form::text($name);
             preg_match("~value=['\"]([^'\"]+?)['\"]~is", $val, $matches);
             #Helper::d($matches);
             $val = (int) @$matches[1];
             #Helper::tad($val);
             if ($val > 0) {
                 $gallery = Gallery::where('id', $val)->with('photos')->first();
                 #Helper::tad($gallery);
             }
         } elseif (is_numeric($value)) {
             $gallery = Gallery::where('id', $value)->with('photos')->first();
         }
         #Helper::tad($gallery);
         ## return view with form element
         return View::make($mod_tpl . $tpl, compact('name', 'value', 'gallery', 'params'))->render();
     }, function ($params) use($mod_tpl, $class) {
         #dd($params);
         $module = isset($params['module']) ? $params['module'] : false;
         $unit_id = isset($params['unit_id']) ? $params['unit_id'] : false;
         $gallery = isset($params['gallery']) ? $params['gallery'] : false;
         $gallery_id = isset($gallery['gallery_id']) ? $gallery['gallery_id'] : 0;
         $uploaded_images = isset($gallery['uploaded_images']) ? $gallery['uploaded_images'] : array();
         $module = (string) trim($module);
         $unit_id = (string) trim($unit_id);
         if (@$params['single']) {
             $gallery_id = $class::moveImagesToGallery($uploaded_images, $gallery_id);
             if ($gallery_id) {
                 $class::renameGallery($gallery_id, $module . " - " . $unit_id);
             }
         } else {
             ## Perform all actions for adding photos to the gallery & bind gallery to the unit_id of module
             $gallery_id = $class::imagesToUnit($uploaded_images, $module, $unit_id, $gallery_id);
         }
         #Helper::dd($gallery_id);
         return $gallery_id;
     });
     ##
     ## EXTFORM IMAGE
     ##
     /*
     ################################################
     ## Process image
     ################################################
     if (Allow::action('admin_galleries', 'edit')) {
         $input['image_id'] = ExtForm::process('image', array(
                                 'image' => Input::get('image'),
                                 'return' => 'id',
                             ));
     }
     ################################################
     */
     ExtForm::add("image", function ($name = 'image', $value = '', $params = null) use($mod_tpl, $class) {
         ## default template
         $tpl = "extform_image";
         ## custom template
         if (@$params['tpl']) {
             $tpl = $params['tpl'];
             unset($params['tpl']);
         }
         #dd($value);
         #Helper::dd($params);
         if (!is_object($value)) {
             $photo = NULL;
         }
         if ($value === false || $value === null) {
             $val = Form::text($name);
             preg_match("~value=['\"]([^'\"]+?)['\"]~is", $val, $matches);
             #Helper::d($matches);
             $val = (int) @$matches[1];
             #Helper::tad($val);
             if ($val > 0) {
                 #$photo = Photo::firstOrNew(array('id' => $val));
                 $photo = Photo::find($val);
                 #Helper::tad($photo);
             }
         } elseif (is_numeric($value)) {
             $photo = Photo::find($value);
         }
         #Helper::tad($value);
         #Helper::tad($photo);
         ## return view with form element
         return View::make($mod_tpl . $tpl, compact('name', 'value', 'photo', 'params'));
     }, function ($params) use($mod_tpl, $class) {
         #Helper::dd($params);
         ## Array with POST-data
         $image = @$params['image'] ?: false;
         ## Return format
         $return = @$params['return'] ?: false;
         ## ID of uploaded image
         #$uploaded_image = isset($image['uploaded_image']) ? (int)$image['uploaded_image'] : false;
         $uploaded_image = $image;
         #Helper::dd($uploaded_image);
         if (!$uploaded_image) {
             return false;
         }
         ## Find photo by ID
         $photo = Photo::where('id', $uploaded_image)->first();
         ## If photo don't exists - return false
         if (is_null($photo)) {
             return false;
         }
         ## Mark photo as "single used image"
         $photo->gallery_id = 0;
         $photo->save();
         ## Return needable property or full object
         return $return ? @$photo->{$return} : $photo;
     });
 }
 public function delete($id)
 {
     $album = Album::find($id);
     if ($album === null) {
         $error = 'Invalid album.';
         return View::make('errors.error', array('errorMsg' => $error));
     }
     if ($album->owner_id !== Auth::user()->id) {
         $error = 'You don\'t have permission to delete this album. You are not it\'s owner.';
         return View::make('errors.error', array('errorMsg' => $error));
     }
     //delete all photos
     Photo::where('album_id', '=', $album->id)->delete();
     //delete album
     $album->delete();
     return Redirect::to('/albums/own');
 }