public function save_settings()
 {
     $input = Input::all();
     $settings = Setting::first();
     $demo_mode = Input::get('demo_mode');
     $enable_https = Input::get('enable_https');
     if (empty($demo_mode)) {
         $input['demo_mode'] = 0;
     }
     if (empty($enable_https)) {
         $input['enable_https'] = 0;
     }
     if (Input::hasFile('logo')) {
         $input['logo'] = ImageHandler::uploadImage(Input::file('logo'), 'settings');
     } else {
         $input['logo'] = $settings->logo;
     }
     if (Input::hasFile('favicon')) {
         $input['favicon'] = ImageHandler::uploadImage(Input::file('favicon'), 'settings');
     } else {
         $input['favicon'] = $settings->favicon;
     }
     $settings->update($input);
     return Redirect::to('admin/settings')->with(array('note' => 'Successfully Updated Site Settings!', 'note_type' => 'success'));
 }
Exemple #2
0
 public function __construct(Setting $settings = null, Portfolio $portfolio = null, Filesystem $filesystem = null)
 {
     $this->settings = $settings == null ? Setting::first() : $settings;
     $this->portfolio = $portfolio == null ? Portfolio::all() : $portfolio;
     $this->filesystem = $filesystem == null ? new Filesystem() : $filesystem;
     \View::share('settings', $this->settings);
 }
 public function login()
 {
     // get login POST data
     $email_login = array('email' => Input::get('email'), 'password' => Input::get('password'));
     $username_login = array('username' => Input::get('email'), 'password' => Input::get('password'));
     if (Auth::attempt($email_login) || Auth::attempt($username_login)) {
         //dd(Auth::user());
         if (Auth::user()->subscribed() || (Auth::user()->role == 'admin' || Auth::user()->role == 'demo')) {
             $redirect = Input::get('redirect', 'false') ? Input::get('redirect') : '/';
             if (Auth::user()->role == 'demo' && Setting::first()->demo_mode != 1) {
                 Auth::logout();
                 return Redirect::to($redirect)->with(array('note' => 'Sorry, Demo Mode has been disabled', 'note_type' => 'error'));
             } else {
                 return Redirect::to($redirect)->with(array('note' => 'You have been successfully logged in.', 'note_type' => 'success'));
             }
         } else {
             $username = Auth::user()->username;
             return Redirect::to('user/' . $username . '/renew_subscription')->with(array('note' => 'Uh oh, looks like you don\'t have an active subscription, please renew to gain access to all content', 'note_type' => 'error'));
         }
     } else {
         $redirect = Input::get('redirect', false) ? '?redirect=' . Input::get('redirect') : '';
         // auth failure! redirect to login with errors
         return Redirect::to('login' . $redirect)->with(array('note' => 'Invalid login, please try again.', 'note_type' => 'error'));
     }
 }
Exemple #4
0
 private function __construct()
 {
     $setting = Setting::first();
     if ($setting) {
         self::$google_api_key = $setting->api_key;
     }
 }
 public function settings_form()
 {
     $settings = Setting::first();
     $user = Auth::user();
     $data = array('settings' => $settings, 'admin_user' => $user);
     return View::make('admin.settings.index', $data);
 }
 public function simpan_jadwal()
 {
     if (Request::ajax()) {
         $setting = Setting::first();
         $hari = Input::get('hari');
         $guru = Input::get('guru');
         $rombel = Input::get('rombel');
         $jam = Input::get('jam');
         $mapel = Input::get('mapel');
         $cek = DB::table('jadwal')->where('kd_rombel', '=', $rombel)->where('hari', '=', $hari)->where('jam_ke', '=', $jam)->count();
         if ($cek > 0) {
             echo "error";
         } else {
             //cek apakah guru ini sudah mengajar ditempat lain atau belum
             $cekguru = DB::table('jadwal')->where('kd_rombel', 'like', $setting->dari_tahun . '-' . $setting->sampai_tahun . "%")->where('id_guru', '=', $guru)->where('hari', '=', $hari)->where('jam_ke', '=', $jam)->where('kd_mapel', '=', $mapel)->count();
             if ($cekguru > 0) {
                 echo "error2";
             } else {
                 $jadwal = new Jadwal();
                 $jadwal->kd_rombel = Input::get('rombel');
                 $jadwal->hari = Input::get('hari');
                 $jadwal->jam_ke = Input::get('jam');
                 $jadwal->id_guru = Input::get('guru');
                 $jadwal->kd_mapel = Input::get('mapel');
                 $jadwal->save();
                 echo "sukses";
             }
         }
     }
 }
 public function subscribers()
 {
     $user = Sentry::getUser();
     $subscribers = Subscriber::orderBy('first_name', 'asc')->get();
     $sitename = Setting::first()->pluck('sitename');
     return View::make('dashboard.subscribers', array('user' => $user, 'subscribers' => $subscribers, 'sitename' => $sitename));
 }
 public function activate($slug)
 {
     $settings = Setting::first();
     $settings->theme = $slug;
     $settings->save();
     return Redirect::to('admin/themes')->with(array('note' => 'Successfully Activated ' . ucfirst($slug) . ' Theme', 'note_type' => 'success'));
 }
Exemple #9
0
 public function add_db_data()
 {
     if (Request::ajax()) {
         try {
             $settings = Setting::first();
             if ($settings) {
                 return Redirect::to('/');
             } else {
                 throw new Exception('settings not set, first install the script');
             }
         } catch (Exception $e) {
             try {
                 $this->add_all_tables();
                 $this->insert_settings();
                 $this->insert_categories();
                 if (Input::get('preloaded_data') == 'true') {
                     $this->insert_media();
                 }
                 $this->upgrade();
                 echo true;
             } catch (Exception $e) {
                 echo false;
             }
         }
     } else {
         echo false;
     }
 }
 public function settings()
 {
     $user = Sentry::getUser();
     if (Input::get('email') == $user->email) {
         $rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50');
     } else {
         $rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50');
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json($validator->messages());
     } else {
         $setting = Setting::first();
         $setting->sitename = Input::get('sitename');
         $setting->save();
         $user = User::find($user->id);
         $user->first_name = Input::get('first_name');
         $user->last_name = Input::get('last_name');
         $user->email = Input::get('email');
         $user->password = Input::get('password');
         $user->save();
         $feedback = array('success' => 'Settings successfully saved.');
         return Response::json($feedback);
     }
 }
 function create()
 {
     if ($_POST) {
         unset($_POST['send']);
         $_POST['datetime'] = time();
         $_POST = array_map('htmlspecialchars', $_POST);
         unset($_POST['files']);
         $project = Project::create($_POST);
         $new_project_reference = $_POST['reference'] + 1;
         $project_reference = Setting::first();
         $project_reference->update_attributes(array('project_reference' => $new_project_reference));
         if (!$project) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_project_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_project_success'));
             $project_last = Project::last();
             $sql = "INSERT INTO `project_has_workers` (`project_id`, `user_id`) VALUES (" . $project_last->id . ", " . $this->user->id . ")";
             $query = $this->db->query($sql);
         }
         redirect('projects');
     } else {
         $this->view_data['companies'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['next_reference'] = Project::last();
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_create_project');
         $this->view_data['form_action'] = 'projects/create';
         $this->content_view = 'projects/_project';
     }
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $mengajar = Mengajar::find($id);
     $guru = Guru::all();
     $mapel = Mapel::all();
     $setting = Setting::first();
     return View::make('mengajar.edit')->with('mengajar', $mengajar)->with('guru', $guru)->with('mapel', $mapel)->with('setting', $setting);
 }
 function __construct()
 {
     parent::__construct();
     $this->view_data['core_settings'] = Setting::first();
     if ($this->input->cookie('language') != "") {
         $language = $this->input->cookie('language');
     } else {
         if (isset($this->view_data['language'])) {
             $language = $this->view_data['language'];
         } else {
             if (!empty($this->view_data['core_settings']->language)) {
                 $language = $this->view_data['core_settings']->language;
             } else {
                 $language = "english";
             }
         }
     }
     $this->lang->load('application', $language);
     $this->lang->load('messages', $language);
     $this->lang->load('event', $language);
     $this->user = $this->session->userdata('user_id') ? User::find_by_id($this->session->userdata('user_id')) : FALSE;
     $this->client = $this->session->userdata('client_id') ? Client::find_by_id($this->session->userdata('client_id')) : FALSE;
     if ($this->client) {
         $this->theme_view = 'application_client';
     }
     $this->view_data['datetime'] = date('Y-m-d H:i', time());
     $this->view_data['sticky'] = Project::all(array('conditions' => 'sticky = 1'));
     $this->view_data['quotations_new'] = Quote::find_by_sql("select count(id) as amount from quotations where status='New'");
     if ($this->user || $this->client) {
         $access = $this->user ? $this->user->access : $this->client->access;
         $access = explode(",", $access);
         if ($this->user) {
             $this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'main')));
             $this->view_data['widgets'] = Module::find('all', array('conditions' => array('id in (?) AND type = ?', $access, 'widget')));
         } else {
             $this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'client')));
         }
         if ($this->user) {
             $update = User::find($this->user->id);
         } else {
             $update = Client::find($this->client->id);
         }
         $update->last_active = time();
         $update->save();
         if ($this->user) {
             $this->view_data['user_online'] = User::all(array('conditions' => array('last_active+(30 * 60) > ? AND status = ?', time(), "active")));
             $this->view_data['client_online'] = Client::all(array('conditions' => array('last_active+(30 * 60) > ? AND inactive = ?', time(), "0")));
         }
         $email = $this->user ? 'u' . $this->user->id : 'c' . $this->client->id;
         $this->view_data['messages_new'] = Privatemessage::find_by_sql("select count(id) as amount from privatemessages where `status`='New' AND recipient = '" . $email . "'");
         $this->view_data['tickets_new'] = Ticket::find_by_sql("select count(id) as amount from tickets where `status`='New'");
     }
     /*$this->load->database();
     		$sql = "select * FROM templates WHERE type='notes'";
     		$query = $this->db->query($sql); */
     $this->view_data["note_templates"] = "";
     //$query->result();
 }
Exemple #14
0
 function create()
 {
     if ($_POST) {
         $config['upload_path'] = './files/media/';
         $config['encrypt_name'] = TRUE;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         $this->load->helper('notification');
         unset($_POST['userfile']);
         unset($_POST['file-name']);
         unset($_POST['send']);
         unset($_POST['_wysihtml5_mode']);
         unset($_POST['files']);
         $settings = Setting::first();
         $client = Client::find_by_id($this->client->id);
         $user = User::find_by_id($settings->ticket_default_owner);
         $_POST['from'] = $client->firstname . ' ' . $client->lastname . ' - ' . $client->email;
         $_POST['company_id'] = $client->company->id;
         $_POST['client_id'] = $client->id;
         $_POST['user_id'] = $settings->ticket_default_owner;
         $_POST['queue_id'] = $settings->ticket_default_queue;
         $_POST['type_id'] = $settings->ticket_default_type;
         $_POST['status'] = $settings->ticket_default_status;
         $_POST['created'] = time();
         $_POST['subject'] = htmlspecialchars($_POST['subject']);
         $ticket_reference = Setting::first();
         $_POST['reference'] = $ticket_reference->ticket_reference;
         $ticket = Ticket::create($_POST);
         $new_ticket_reference = $_POST['reference'] + 1;
         $ticket_reference->update_attributes(array('ticket_reference' => $new_ticket_reference));
         if (!$this->upload->do_upload()) {
             $error = $this->upload->display_errors('', ' ');
             $this->session->set_flashdata('message', 'error:' . $error);
         } else {
             $data = array('upload_data' => $this->upload->data());
             $attributes = array('ticket_id' => $ticket->id, 'filename' => $data['upload_data']['orig_name'], 'savename' => $data['upload_data']['file_name']);
             $attachment = TicketHasAttachment::create($attributes);
         }
         if (!$ticket) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_ticket_error'));
             redirect('ctickets');
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_ticket_success'));
             if (isset($user->email) && isset($ticket->reference)) {
                 send_ticket_notification($user->email, '[Ticket#' . $ticket->reference . '] - ' . $_POST['subject'], $_POST['text'], $ticket->id);
             }
             if (isset($client->email) && isset($ticket->reference)) {
                 send_ticket_notification($client->email, '[Ticket#' . $ticket->reference . '] - ' . $_POST['subject'], $_POST['text'], $ticket->id);
             }
             redirect('ctickets/view/' . $ticket->id);
         }
     } else {
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_create_ticket');
         $this->view_data['form_action'] = 'ctickets/create';
         $this->content_view = 'tickets/client_views/_ticket';
     }
 }
Exemple #15
0
 public function getSettings()
 {
     $settings = Setting::first($this->public_settings);
     // Include the Uploads URL
     $settings['uploads_dir'] = Config::get('site.uploads_dir');
     // Include Site URL
     $settings['url'] = URL::to('/');
     return Response::json($settings);
 }
 public function index()
 {
     $user = Sentry::getUser();
     $lists = Addressbook::with(array('subscribers' => function ($query) {
         $query->orderBy('first_name', 'asc');
     }))->orderBy('id', 'asc')->get();
     $sitename = Setting::first()->pluck('sitename');
     return View::make('dashboard.lists', array('user' => $user, 'lists' => $lists, 'sitename' => $sitename));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     $input = Input::all();
     $settings = Setting::first();
     $settings->fill($input);
     if ($settings->save()) {
         $returnedSettings = array('answer_time' => $settings->answer_time, 'daily_bonus' => $settings->daily_bonus, 'general_cost' => $settings->general_cost, 'top_bonus' => $settings->top_bonus, 'word_cost' => $settings->word_cost, 'life_cost' => $settings->life_cost, 'words_for_the_next_bonus' => $settings->words_for_the_next_bonus, 'word_id' => $settings->word_id);
         return $this->respond($returnedSettings);
     }
 }
 public function indexthn()
 {
     $date = \Carbon\Carbon::now();
     $thn = Input::get('tahun');
     $menu = Menu::where('tipe', Sentry::getUser()->last_name)->get();
     $announcement = Setting::first();
     // $officers = Officer::all();
     $officers = Officer::where('user_id', Sentry::getUser()->id)->where(DB::raw('YEAR(created_at)'), '=', $thn)->get();
     return View::make('officers.index', compact('officers'))->withTitle('Petugas')->with('menu', $menu)->with('thn', $thn)->with('announcement', $announcement);
 }
 public function update_theme_settings()
 {
     // Get the Active Theme
     $active_theme = Setting::first()->theme;
     $input = Input::all();
     foreach ($input as $key => $value) {
         $this->createOrUpdateThemeSetting($active_theme, $key, $value);
     }
     return Redirect::to('/admin/theme_settings');
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($category_slug)
 {
     $categories = Category::all();
     $cat_id = 0;
     foreach ($categories as $category) {
         if ($category->name == $category_slug || strtolower($category->name) == $category_slug) {
             $cat_id = $category->id;
             break;
         }
     }
     $data = array('media' => Media::where('active', '=', 1)->where('category_id', '=', $cat_id)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page')), 'categories' => Category::all(), 'pages' => Page::all(), 'settings' => Setting::first());
     return View::make('Theme::home', $data);
 }
Exemple #21
0
 public function get_mutasi_siswa_rombel()
 {
     if (Request::ajax()) {
         $setting = Setting::first();
         $awal = Input::get('tahun') . '-' . Input::get('awal');
         $siswa = DB::table('siswa_rombel')->where('kd_rombel', '=', $awal)->join('siswa', 'siswa.nis', '=', 'siswa_rombel.nis');
         $kode = Input::get('awal');
         $kelas = Kelas::find($kode);
         //cari data kelas yang tingkatnya sama dengan data kelas sekarang
         $lain = DB::table('kelas')->where('kelas', '=', $kelas->kelas)->where('kd_kelas', '<>', $kode)->get();
         return View::make('mutasi.siswa_rombel')->with('siswa', $siswa)->with('lain', $lain)->with('setting', $setting)->with('awal', $awal);
     }
 }
 public static function getThemeSettings()
 {
     // Get the Active Theme and the Theme Settings
     $active_theme = Setting::first()->theme;
     $theme_settings = ThemeSetting::where('theme_slug', '=', $active_theme)->get();
     // Create an empty array to fill with theme settings
     $key_values = array();
     // loop through each key value and put into array accordingly
     foreach ($theme_settings as $setting) {
         $key_values[$setting->key] = $setting->value;
     }
     return (object) $key_values;
 }
 /**
  * Show the form for creating a new payment
  *
  * @return Response
  */
 public function create()
 {
     $tgl = new DateTime(date('Y-m-d'));
     $limit = Setting::first();
     $limitdtend = new DateTime($limit->enddaypay);
     $limitend = $limitdtend->diff($tgl)->format('%R%a');
     $menu = Menu::where('tipe', Sentry::getUser()->last_name)->get();
     $jstotal = Session::get('jstotal');
     if ($limitend > 0) {
         return Redirect::to('user/cost')->with('errorMessage', trans('Pembayaran Sudah Ditutup.'));
     }
     return View::make('payments.create')->withTitle('Payment')->with('menu', $menu)->with('jstotal', $jstotal);
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     //
     $settings = \Setting::first();
     $root_dir = __DIR__ . '/../../../';
     if (\Cookie::get('theme')) {
         $theme = \Crypt::decrypt(\Cookie::get('theme'));
     } else {
         if ($settings->theme) {
             $theme = $settings->theme;
         }
     }
     //echo $theme; die();
     // Add the theme view namespace
     \Config::set('mail.from', ['address' => $settings->system_email, 'name' => $settings->website_name]);
     @(include $root_dir . 'content/themes/' . $theme . '/functions.php');
     View::addNamespace('Theme', $root_dir . 'content/themes/' . $theme);
     Route::filter('auth', function () {
         if (Auth::guest()) {
             return Redirect::guest('login');
         }
     });
     Route::filter('auth.basic', function () {
         return Auth::basic();
     });
     Route::filter('if_logged_in_must_be_subscribed', function () {
         if (!Auth::guest()) {
             if (!Auth::user()->subscribed() && Auth::user()->role == 'subscriber') {
                 $username = Auth::user()->username;
                 return Redirect::to('user/' . $username . '/renew_subscription')->with(array('note' => 'Uh oh, looks like you don\'t have an active subscription, please renew to gain access to all content', 'note_type' => 'error'));
             }
         }
     });
     Route::filter('admin', function () {
         if (!Auth::guest() && (Auth::user()->role == 'admin' || Auth::user()->role == 'demo')) {
         } else {
             return Redirect::to('/login');
         }
     });
     Route::filter('demo', function () {
         if (!Auth::guest() && Auth::user()->role == 'demo') {
             return Redirect::back()->with(array('note' => 'Sorry, unfortunately this functionality is not available in demo accounts', 'note_type' => 'error'));
         }
     });
     Route::filter('guest', function () {
         if (Auth::check()) {
             return Redirect::to('/');
         }
     });
 }
 public function index()
 {
     if (Sentry::check()) {
         $user = Sentry::getUser();
         return Redirect::to('dashboard');
     } else {
         $users = User::take(2)->count();
         $sitenamerow = Setting::first();
         $sitename = '';
         if ($sitenamerow) {
             $sitename = $sitenamerow->sitename;
         }
         return View::make('frontend.index', array('users' => $users, 'sitename' => $sitename));
     }
 }
 public function __construct()
 {
     $this->data['messages'] = View::make('block.messages')->with('messages', $this->getMessage())->render();
     $this->data['setting'] = Setting::first();
     $this->data['sliderList'] = Slider::orderBy('sort')->get();
     $this->data['socialList'] = Social::orderBy('sort')->get();
     $this->data['categoryList'] = Category::where('main', 0)->orderBy('sort')->get();
     $this->data['groupList'] = Group::orderBy('sort')->get();
     $this->data['buildOwn'] = Product::where('is_build', 1)->first();
     $placeList = Place::all();
     foreach ($placeList as $place) {
         $this->data['place'][$place->name] = $place->pageList()->orderBy('sort')->get();
     }
     $this->data['seo'] = array('keywords' => 'Pepperino', 'title' => 'Pepperino', 'description' => 'Pepperino');
 }
Exemple #27
0
 function download($id = FALSE)
 {
     $this->load->helper(array('dompdf', 'file'));
     $this->load->library('parser');
     $data["invoice"] = Invoice::find($id);
     $data['items'] = InvoiceHasItem::find('all', array('conditions' => array('invoice_id=?', $id)));
     if ($data['invoice']->company_id != $this->client->company->id) {
         redirect('cinvoices');
     }
     $data["core_settings"] = Setting::first();
     $due_date = date($data["core_settings"]->date_format, human_to_unix($data["invoice"]->due_date . ' 00:00:00'));
     $parse_data = array('due_date' => $due_date, 'invoice_id' => $data["invoice"]->reference, 'client_link' => $data["core_settings"]->domain, 'company' => $data["core_settings"]->company);
     $html = $this->load->view($data["core_settings"]->template . '/' . 'invoices/preview', $data, true);
     $html = $this->parser->parse_string($html, $parse_data);
     $filename = 'Invoice_' . $data["invoice"]->reference;
     pdf_create($html, $filename, TRUE);
 }
 public function fire()
 {
     $pushWords = new Collection();
     $dayWord = WordCard::find(Setting::first()->word_id);
     $pushWords->push(['word_id' => $dayWord->id, 'category_id' => $dayWord->category_id]);
     Category::all()->each(function ($category) use($pushWords) {
         $this->info("looking at category {$category->id}");
         $word = $this->getSentWord($category);
         if ($word) {
             $pushWords->push(['word_id' => $word->id, 'category_id' => $category->id]);
         } else {
             $this->error('Empty category');
         }
     });
     $this->check();
     $this->pushWords2($pushWords);
 }
Exemple #29
0
 public function cetak_harian()
 {
     $kelas = Input::get('kelas');
     $tahun = Input::get('tahun');
     $mapel = Input::get('mapel');
     $semester = Input::get('semester');
     $siswa = DB::table('siswa_rombel')->where('kd_rombel', '=', $tahun . '-' . $kelas)->join('siswa', 'siswa_rombel.nis', '=', 'siswa.nis')->get();
     $kode = $tahun . '-' . $kelas;
     $rombel = Rombel::find($tahun . '-' . $kelas);
     $setting = Setting::first();
     $cekHarian = DB::table('nilai_harian')->where('kd_rombel', $kode)->where('kd_mapel', $mapel)->where('semester', $semester)->count();
     if ($cekHarian > 0) {
         return View::make('laporan.cetak_harian')->with('siswa', $siswa)->with('rombel', $rombel)->with('mapel', $mapel)->with('semester', $semester)->with('title', 'Laporan Nilai Harian');
     } else {
         Session::flash('pesan', "<div class='alert alert-danger'>\n      Data tidak ditemukan</div>");
         return Redirect::back();
     }
 }
 public function postEdit()
 {
     if (Input::has('id')) {
         $validator = Validator::make(array('id' => Input::get('id')), $this->validate_id_arr);
         if ($validator->fails()) {
             return Redirect::back()->withInput()->with('msg', 'Invalid ID')->with('state', '-1');
         }
     }
     if (Input::hasFile('logo')) {
         $mime = array('image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/bmp');
         $uploaded_mime = Input::file('logo')->getMimeType();
         $file = array('image' => Input::file('logo'));
         $validator2 = Validator::make($file, $this->validateImage);
         if ($validator2->fails()) {
             return Redirect::back()->withInput()->with('msg', 'Logo must be an image of type: jpeg, jpg, png, gif,bmp')->with('state', '-1');
         }
         if (!in_array($uploaded_mime, $mime)) {
             return Redirect::back()->with('msg', 'Logo must be an image of type: jpeg, jpg, png, gif,bmp')->with('state', '-1');
         }
         list($width, $height) = getimagesize(Input::file('logo'));
         if ($width != '115' && $height != '50 ') {
             return Redirect::back()->with('msg', 'Logo dimensions must be 115 * 50 px')->with('state', '-1');
         }
         $logo = Input::file('logo');
         $destination_path = base_path() . '/backend/images/';
         $file_name = $logo->getClientOriginalName();
         Input::file('logo')->move($destination_path, $file_name);
     } else {
         $file_name = Input::get('logo_name');
     }
     $setting = Setting::first();
     if (!$setting) {
         $setting = new Setting();
     }
     try {
         $setting->api_key = Input::get('api_key');
         $setting->logo = $file_name;
         $setting->site_name = Input::get('site_name');
         $setting->save();
         return Redirect::to('setting')->with('msg', 'Setting save successfully')->with('state', '1');
     } catch (Exception $e) {
         return Redirect::back()->withInput()->with('msg', 'Failed to save settings.')->with('state', '-1');
     }
 }