/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Variant::$rules);
     if ($validation->passes()) {
         $this->variant->create($input);
         $vid = DB::getPdo()->lastInsertId();
         $templates = Template::getImages();
         return Redirect::route('variants.assigntemp', compact('vid', 'templates'));
     }
     return Redirect::route('variants.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     $date = new Carbon();
     $addRows = [];
     foreach (Page::all() as $page) {
         if ($page->in_group) {
             $addRows[] = ['page_id' => $page->id, 'group_id' => $page->in_group, 'created_at' => $date, 'updated_at' => $date];
         }
     }
     DB::table('page_group_pages')->insert($addRows);
     Schema::table('pages', function (Blueprint $table) {
         $table->dropColumn('in_group');
         $table->integer('group_container_url_priority')->default(0)->after('group_container');
         $table->integer('canonical_parent')->default(0)->after('group_container_url_priority');
     });
     Schema::table('page_group', function (Blueprint $table) {
         $table->dropColumn('default_parent');
         $table->dropColumn('order_by_attribute_id');
         $table->dropColumn('order_dir');
         $table->integer('url_priority')->default(50)->after('item_name');
     });
     Schema::table('page_group_attributes', function (Blueprint $table) {
         $table->integer('item_block_order_priority')->default(0)->after('item_block_id');
         $table->string('item_block_order_dir')->default('asc')->after('item_block_order_priority');
         $table->integer('filter_by_block_id')->default(0)->change();
     });
     $groupsController = DB::table('admin_controllers')->select('id')->where('controller', '=', 'groups')->first();
     DB::table('admin_actions')->insert(array(array('controller_id' => $groupsController->id, 'action' => 'edit', 'inherit' => 0, 'edit_based' => 0, 'name' => 'Edit Group Settings', 'about' => null, 'created_at' => $date, 'updated_at' => $date)));
     $lastInsertId = DB::getPdo()->lastInsertId();
     DB::table('user_roles_actions')->insert(array(array('role_id' => 2, 'action_id' => $lastInsertId, 'created_at' => $date, 'updated_at' => $date)));
 }
 public function addAction()
 {
     try {
         $school = Input::get('hiddenSchools');
         $name = Input::get('name');
         $description = Input::get('description');
         $publish = Input::get('publish');
         $class = new Classes();
         $class->name = $name;
         $class->description = $description;
         $class->published = $publish;
         $class->save();
         $id = DB::getPdo()->lastInsertId();
         $schools = explode(',', $school);
         for ($i = 0; $i < count($schools); $i++) {
             if ($schools[$i] != "") {
                 $schoolclass = new Schoolclass();
                 $schoolclass->school = $schools[$i];
                 $schoolclass->class = $id;
                 $schoolclass->save();
             }
         }
         //Session::put('id', $id);
         Session::flash('status_success', 'Successfully Updated.');
         return Redirect::route('admin/classEdit', array('id' => $id));
         //return Redirect::route('admin/classEdit');
     } catch (Exception $ex) {
         echo $ex;
         Session::flash('status_error', '');
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // create package table
     Schema::create('tests', function ($table) {
         $table->increments('id');
         $table->string('name');
         $table->timestamps();
     });
     /**
      * Opcional
      */
     /*DB::table('packages')->insert(
           array(
                   'package_name' => 'Nombre del paquete',
                   'icon' => 'fa-cog',// icono de la plantilla
           )
       );
       $packageid = DB::getPdo()->lastInsertId(); */
     // agregamos el paquete id al cual queremos que este relacionada
     $package_id = 2;
     // insertamos en la tabla modules, el nombre de nuestro paquete
     DB::table('modules')->insert(array('package_id' => $package_id, 'module_name' => 'Nombre del paquete', 'route' => 'test'));
     $module_id = DB::getPdo()->lastInsertId();
     // Insertamos los permisos que tendra nuestros modulo
     DB::table('module_permissions')->insert([['module_id' => $module_id, 'display_name' => 'ver test', 'permission' => 'test.view'], ['module_id' => $module_id, 'display_name' => 'create test', 'permission' => 'test.create'], ['module_id' => $module_id, 'display_name' => 'actualizar test', 'permission' => 'test.update'], ['module_id' => $module_id, 'display_name' => 'delete test', 'permission' => 'test.delete'], ['module_id' => $module_id, 'display_name' => 'widget test', 'permission' => 'TestWidget.view']]);
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     $date = new Carbon();
     DB::table('admin_controllers')->insert(array(array('controller' => 'search', 'role_name' => 'Search log', 'role_order' => 4, 'role_section' => 3, 'created_at' => $date, 'updated_at' => $date)));
     $controller_id = DB::getPdo()->lastInsertId();
     DB::table('admin_actions')->insert(array(array('controller_id' => $controller_id, 'action' => 'index', 'inherit' => -1, 'edit_based' => 0, 'name' => 'View Search Log', 'about' => null, 'created_at' => $date, 'updated_at' => $date)));
 }
 /**
  * Store a newly created song in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Set rules for validator
     $rules = array("artist" => "required", "title" => "required", "requester" => "required", "link" => "required|url");
     // Validate input
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         // TODO: Remember form input...
         return Redirect::to('song/create')->withErrors($validator, "song");
     }
     // Create new song
     $song = Input::all();
     // Set or unset remember cookie
     if (isset($song['remember-requester'])) {
         $cookie = Cookie::make("requester", $song['requester']);
     } else {
         $cookie = Cookie::forget("requester");
     }
     $artist = DB::getPdo()->quote($song['artist']);
     $title = DB::getPdo()->quote($song['title']);
     if (Song::whereRaw("LOWER(artist) = LOWER({$artist}) AND LOWER(title) = LOWER({$title})")->count() > 0) {
         return Redirect::to('song/create')->with('error', "HEBBEN WE AL!!!")->withCookie($cookie);
     }
     Song::create($song);
     // Set success message
     $msg = "Gefeliciteerd! Je nummer is aangevraagd :D";
     // Redirect to song index page with message and cookie
     return Redirect::to("/")->with("success", $msg)->withCookie($cookie);
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     $date = new Carbon();
     $themesController = DB::table('admin_controllers')->select('id')->where('controller', '=', 'themes')->first();
     DB::table('admin_actions')->insert(array(array('controller_id' => $themesController->id, 'action' => 'selects', 'inherit' => 0, 'edit_based' => 0, 'name' => 'Change Select Block Options', 'about' => null, 'created_at' => $date, 'updated_at' => $date)));
     $lastInsertId = DB::getPdo()->lastInsertId();
     DB::table('user_roles_actions')->insert(array(array('role_id' => 2, 'action_id' => $lastInsertId, 'created_at' => $date, 'updated_at' => $date)));
 }
Example #8
0
 public function uploadBankReceipt()
 {
     if (Input::hasFile('uploadReceipt')) {
         $data = array();
         if (is_array(Input::get('room_id'))) {
             foreach (Input::get('room_id') as $key => $val) {
                 $data[$key] = array('am_id' => Input::get('am_id.' . $key), 'rooms' => $val);
             }
         }
         $data2 = array();
         if (is_array(Input::get('add_Am'))) {
             foreach (Input::get('add_Am') as $key => $val) {
                 $data2[$key] = array('am_id' => Input::get('am_id.' . $key), 'rooms' => $val);
             }
         }
         $name = Input::get('packname');
         $price = Input::get('amount');
         $input_dFrom = Input::get('package_datefrom');
         $input_dTo = Input::get('package_dateto');
         $input_nPax = Input::get('num_pax');
         $input_fName = Input::get('fullN');
         $postData = new Reservation();
         $postData->dataInsertPost($name, $price, $input_dFrom, $input_dTo, $input_nPax, $input_fName, json_encode($data), 'Bank', json_encode($data2));
         $lastInsert = DB::getPdo()->lastInsertId();
         $files = Input::file('uploadReceipt');
         $i = 1;
         foreach ($files as $file) {
             try {
                 $path = public_path() . '\\uploads\\bank_deposit\\';
                 $extension = $file->getClientOriginalExtension();
                 $filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
                 $dateNow = date('Ymd_His');
                 $new_filename = Auth::user()->id . '_' . $filename . '_' . $i . '.' . $extension;
                 $upload_success = $file->move($path, $new_filename);
             } catch (Exception $ex) {
                 $path = public_path() . '/uploads/bank_deposit/';
                 $extension = $file->getClientOriginalExtension();
                 $filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
                 $dateNow = date('Ymd_His');
                 $new_filename = Auth::user()->id . '_' . $filename . '_' . $i . '.' . $extension;
                 $upload_success = $file->move($path, $new_filename);
             }
             $insertVal = array('image_fieldvalue' => $lastInsert, 'image_name' => $new_filename);
             $this->GlobalModel->insertModel('tbl_images', $insertVal);
             $i++;
         }
         $data = array('refNumber' => str_pad($lastInsert, 10, "0", STR_PAD_LEFT), 'package' => $name, 'amount' => '₱' . number_format($price, 2), 'paymentMethod' => 'Bank Deposit', 'status' => 1);
         try {
             Mail::send('emails.user.transactionReservation', $data, function ($message) use($data) {
                 $message->from('*****@*****.**', 'El Sitio Filipino');
                 $message->to(Auth::user()->user_email, Auth::user()->user_fname . ' ' . Auth::user()->user_lname)->subject('El Sitio Filipino Transaction Details');
             });
         } catch (Exception $ex) {
             dd($ex->getMessage());
         }
         return Response::json($data);
     }
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     $date = new Carbon();
     $themesController = DB::table('admin_controllers')->select('id')->where('controller', '=', 'themes')->first();
     $indexAction = DB::table('admin_actions')->select('id')->where('controller_id', '=', $themesController->id)->where('action', '=', 'index')->first();
     DB::table('admin_actions')->insert(array(array('controller_id' => $themesController->id, 'action' => 'list', 'inherit' => $indexAction->id, 'edit_based' => 0, 'name' => 'View Uploaded Themes', 'about' => null, 'created_at' => $date, 'updated_at' => $date), array('controller_id' => $themesController->id, 'action' => 'export', 'inherit' => 0, 'edit_based' => 0, 'name' => 'Export Uploaded Themes', 'about' => null, 'created_at' => $date, 'updated_at' => $date)));
     $lastInsertId = DB::getPdo()->lastInsertId();
     DB::table('user_roles_actions')->insert(array(array('role_id' => 2, 'action_id' => $lastInsertId, 'created_at' => $date, 'updated_at' => $date)));
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     $date = new Carbon();
     $themesController = DB::table('admin_controllers')->select('id')->where('controller', '=', 'themes')->first();
     $updateAction = DB::table('admin_actions')->select('id')->where('controller_id', '=', $themesController->id)->where('action', '=', 'update')->first();
     DB::table('admin_actions')->insert(array(array('controller_id' => $themesController->id, 'action' => 'forms', 'inherit' => 0, 'edit_based' => 0, 'name' => 'Change Form Rules', 'about' => null, 'created_at' => $date, 'updated_at' => $date)));
     $lastInsertId = DB::getPdo()->lastInsertId();
     DB::table('user_roles_actions')->insert(array(array('role_id' => 2, 'action_id' => $updateAction->id, 'created_at' => $date, 'updated_at' => $date), array('role_id' => 2, 'action_id' => $lastInsertId, 'created_at' => $date, 'updated_at' => $date)));
     DB::table('admin_actions')->where('controller_id', '=', $themesController->id)->where('action', '=', 'update')->update(['inherit' => 0]);
     DB::table('admin_actions')->where('controller_id', '=', $themesController->id)->where('action', '=', 'index')->update(['name' => 'Show Theme Management']);
 }
Example #11
0
    public function opponents($tournament)
    {
        return $players = Player::select(array('*', 'players.id AS id'))->distinct()->join('reports', 'reports.player', '=', 'players.id')->whereRaw('reports.game IN (
				SELECT games.id 
				FROM reports
				JOIN games ON games.id =  reports.game
				JOIN rounds ON rounds.id = games.round
				WHERE reports.player = ' . DB::getPdo()->quote($this->id) . '
				AND rounds.tournament = ' . DB::getPdo()->quote($tournament->id) . '
			)')->where('players.id', '<>', $this->id);
    }
Example #12
0
 function get_last_query()
 {
     $queries = DB::getQueryLog();
     $sql = end($queries);
     if (!empty($sql['bindings'])) {
         $pdo = DB::getPdo();
         foreach ($sql['bindings'] as $binding) {
             $sql['query'] = preg_replace('/\\?/', $pdo->quote($binding), $sql['query'], 1);
         }
     }
     return $sql['query'];
 }
Example #13
0
 /**
  * The attributes excluded from the model's JSON form.
  *
  * @var array
  */
 public function dataInsertPost($name, $price, $input_dFrom, $input_dTo, $input_nPax, $input_fName, $data, $bank = null, $data2)
 {
     $paymentMethod = $bank == null ? 'PayPal' : 'Bank';
     $status = $bank == null ? '1' : '2';
     $packName = DB::table('tbl_packages')->where('pc_name', $name)->first();
     $insertOrders = DB::table('tbl_orders')->insert(array('order_packageid' => $packName->pc_id, 'order_userid' => Auth::user()->id, 'order_datefrom' => $input_dFrom, 'order_dateto' => $input_dTo, 'order_person_count' => $input_nPax, 'order_datecreated' => date('Y-m-d H:i:s'), 'payment_method' => $paymentMethod));
     $lastInsert = DB::getPdo()->lastInsertId();
     $insertOrdersRooms = DB::table('tbl_orders_room')->insert(array('or_orderid' => $lastInsert, 'or_roomid' => $data));
     $insertOrdersAdded = DB::table('tbl_orders_added')->insert(array('order_addOrderid' => $lastInsert, 'order_add_id' => $data2));
     $dataResevInsert = DB::table('tbl_reservation')->insert(array('order_id' => $lastInsert, 'full_name' => $input_fName, 'number_of_person' => $input_nPax, 'total_amount' => $price, 'pack_name' => $name, 'date_time_from' => $input_dFrom, 'date_time_to' => $input_dTo, 'status' => $status, 'created_by' => Auth::user()->id));
     return $dataResevInsert;
 }
Example #14
0
File: Log.php Project: shiwolang/db
 public function getRawSql()
 {
     if (empty($this->params)) {
         return $this->sql;
     }
     $params = $this->params;
     $sql = '';
     if (isset($params[0])) {
         foreach (explode('?', $this->sql) as $i => $part) {
             if (!empty($part)) {
                 $param = isset($params[$i]) ? $params[$i] : '';
                 $sql .= $part . $this->db->getPdo()->quote($param);
             }
         }
     } else {
         $sql = $this->sql;
         foreach ($params as $name => $param) {
             $sql = strtr($sql, [$name => $this->db->getPdo()->quote($param)]);
         }
     }
     return $sql;
 }
Example #15
0
 public function postSignup()
 {
     $username = Input::get('username');
     $password = Input::get('password');
     $password = md5($password);
     $email = Input::get('email');
     DB::table('users')->insertGetId(array('username' => $username, 'password' => $password, 'email' => $email));
     $id = DB::getPdo()->lastInsertId();
     DB::table('profile')->insertGetId(array('profilepic' => 'images/users/default.png', 'usersid' => $id));
     // $profile = new Profile;
     // $profile->usersid = $id;
     // $profile->profilepic = "images/default.png";
     // $profile->save();
 }
Example #16
0
 public function addPackage()
 {
     if (Input::has('amenities') && Input::has('quantity')) {
         $data = array();
         if (is_array(Input::get('amenities'))) {
             foreach (Input::get('amenities') as $key => $val) {
                 $data[$key] = array('id' => $val, 'quantity' => Input::get('quantity.' . $key));
             }
         }
         $insertVal = array('pc_itemid' => json_encode($data), 'pc_name' => Input::get('package_name'), 'pc_num_pax' => Input::get('num_pax'), 'pc_quantity_perday' => Input::get('package_quantity'), 'pc_price' => str_replace(',', '', Input::get('total_amount')), 'pc_groupid' => Input::get('package_type'), 'pc_datecreated' => date('Y-m-d H:i:s'));
         $this->GlobalModel->insertModel('tbl_packages', $insertVal);
         $this->TransLog->transLogger('Package Module', 'Added Package', DB::getPdo()->lastInsertId());
     }
 }
Example #17
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $rules = ['nama' => 'required'];
     $pesan = ['nama.required' => 'Nama harus diisi'];
     $validasi = Validator::make(Input::all(), $rules, $pesan);
     if ($validasi->fails()) {
         return Redirect::back()->withErrors($validasi);
     } else {
         $album = Album::find($id);
         $album->nm_album = Input::get('nama');
         $album->save();
         $theId = DB::getPdo()->lastInsertId();
         Session::flash('pesan', "<div class='alert alert-info'>\n\t\t\tData Berhasil diupdate</div>");
         return Redirect::back();
     }
 }
Example #18
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data = Input::all();
     if ($data) {
         $resource = 'Patient';
         $table = 'demographics';
         $table_primary_key = 'pid';
         $table_key = ['name' => ['lastname', 'firstname'], 'identifier' => 'pid', 'telcom' => ['phone_home', 'phone_work', 'phone_cell'], 'gender' => 'sex', 'birthDate' => 'dob', 'address' => ['address', 'city', 'state', 'zip'], 'contact.relationship' => 'guardian_relationship', 'contact.name' => ['guardian_lastname', 'guardian_firstname'], 'contact.telcom' => 'guardian_phone_home', 'active' => 'active'];
         $result = $this->resource_translation($data, $table, $table_primary_key, $table_key);
         $queries = DB::getQueryLog();
         $sql = end($queries);
         if (!empty($sql['bindings'])) {
             $pdo = DB::getPdo();
             foreach ($sql['bindings'] as $binding) {
                 $sql['query'] = preg_replace('/\\?/', $pdo->quote($binding), $sql['query'], 1);
             }
         }
         if ($result['response'] == true) {
             $statusCode = 200;
             $time = date('c', time());
             $reference_uuid = $this->gen_uuid();
             $response['resourceType'] = 'Bundle';
             $response['title'] = 'Search result';
             $response['id'] = 'urn:uuid:' . $this->gen_uuid();
             $response['updated'] = $time;
             $response['category'][] = ['scheme' => 'http://hl7.org/fhir/tag', 'term' => 'http://hl7.org/fhir/tag/message', 'label' => 'http://ht7.org/fhir/tag/label'];
             $practice = DB::table('practiceinfo')->where('practice_id', '=', '1')->first();
             $response['author'][] = ['name' => $practice->practice_name, 'uri' => route('home') . '/fhir'];
             $response['totalResults'] = $result['total'];
             foreach ($result['data'] as $row_id) {
                 $row = DB::table($table)->where($table_primary_key, '=', $row_id)->first();
                 $resource_content = $this->resource_detail($row, $resource);
                 $response['entry'][] = ['title' => 'Resource of type ' . $resource . ' with id = ' . $row_id . ' and version = 1', 'link' => ['rel' => 'self', 'href' => Request::url() . '/' . $row_id], 'id' => Request::url() . '/' . $row_id, 'updated' => $time, 'published' => $time, 'author' => ['name' => $practice->practice_name, 'uri' => route('home') . '/fhir'], 'category' => ['scheme' => 'http://hl7.org/fhir/tag', 'term' => 'http://hl7.org/fhir/tag/message', 'label' => 'http://ht7.org/fhir/tag/label'], 'content' => $resource_content, 'summary' => '<div><h5>' . $row->lastname . ', ' . $row->firstname . '. MRN: ' . $row->pid . '</h5></div>'];
             }
         } else {
             $response = ['error' => "Query returned 0 records."];
             $statusCode = 404;
         }
     } else {
         $response = ['error' => "Invalid query."];
         $statusCode = 404;
     }
     $response['code'] = $sql['query'];
     return Response::json($response, $statusCode);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data = Input::all();
     if ($data) {
         $resource = 'Patient';
         $table = 'demographics';
         $table_primary_key = 'pid';
         $table_key = ['name' => ['lastname', 'firstname'], 'identifier' => 'pid', '_id' => 'pid', 'telcom' => ['phone_home', 'phone_work', 'phone_cell'], 'gender' => 'sex', 'birthDate' => 'dob', 'address' => ['address', 'city', 'state', 'zip'], 'contact.relationship' => 'guardian_relationship', 'contact.name' => ['guardian_lastname', 'guardian_firstname'], 'contact.telcom' => 'guardian_phone_home', 'active' => 'active'];
         $result = $this->resource_translation($data, $table, $table_primary_key, $table_key);
         $queries = DB::getQueryLog();
         $sql = end($queries);
         if (!empty($sql['bindings'])) {
             $pdo = DB::getPdo();
             foreach ($sql['bindings'] as $binding) {
                 $sql['query'] = preg_replace('/\\?/', $pdo->quote($binding), $sql['query'], 1);
             }
         }
         if ($result['response'] == true) {
             $statusCode = 200;
             $response['resourceType'] = 'Bundle';
             $response['type'] = 'searchset';
             $response['id'] = 'urn:uuid:' . $this->gen_uuid();
             $response['total'] = $result['total'];
             foreach ($result['data'] as $row_id) {
                 $row = DB::table($table)->where($table_primary_key, '=', $row_id)->first();
                 $resource_content = $this->resource_detail($row, $resource);
                 $response['entry'][] = ['fullUrl' => Request::url() . '/' . $row_id, 'resource' => $resource_content];
             }
         } else {
             $response = ['error' => "Query returned 0 records."];
             $statusCode = 404;
         }
     } else {
         $response = ['error' => "Invalid query."];
         $statusCode = 404;
     }
     return Response::json($response, $statusCode);
 }
 public function upload()
 {
     $input = Input::all();
     $validation = Validator::make($input, Template::$rules);
     if ($validation->passes()) {
         $file = Input::file('image');
         // your file upload input field in the form should be named 'file'
         $css = Input::file('css');
         $destinationPath = app_path() . '/views/uploads/layouts';
         $csspath = public_path() . '/assets/css';
         $thumbdestination = public_path() . '/assets/thumb';
         $name = Input::get('name');
         $newname = str_replace(' ', '_', $name);
         $filename = $file->getClientOriginalName();
         //$extension =$file->getClientOriginalExtension();
         //if you need extension of the file
         $uploadSuccess = Input::file('image')->move($destinationPath, $filename);
         $extension = Input::file('thumbnail')->getClientOriginalExtension();
         $uploadthumbnail = Input::file('thumbnail')->move($thumbdestination, $newname . '.' . $extension);
         $uploadcss = Input::file('css')->move($csspath, $css . '.css');
         $input = Input::all();
         if ($uploadSuccess && $uploadthumbnail) {
             //return Response::json('success', 200); // or do a redirect with some message that file was uploaded
             $this->template->name = Input::get('name');
             $this->template->file = $filename;
             $this->template->css = $css;
             $this->template->save();
             $id = DB::getPdo()->lastInsertId();
             $thumb = new Image_thumbnail();
             $thumb->img = $newname . '.' . $extension;
             $thumb->title = $name;
             $thumb->t_id = $id;
             $thumb->save();
             return Redirect::route('templates.definefields', array('id' => $id));
         }
     }
     return Redirect::route('templates.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
 public function addAction()
 {
     try {
         $name = Input::get('name');
         $description = Input::get('description');
         $address = Input::get('address');
         $publish = Input::get('publish');
         $school = new School();
         $school->name = $name;
         $school->description = $description;
         $school->address = $address;
         $school->published = $publish;
         $school->save();
         $id = DB::getPdo()->lastInsertId();
         $schools = explode(',', $school);
         //Session::put('id', $id);
         Session::flash('status_success', 'Successfully Updated.');
         return Redirect::route('admin/schoolEdit', array('id' => $id));
         //return Redirect::route('admin/classEdit');
     } catch (Exception $ex) {
         echo $ex;
         Session::flash('status_error', '');
     }
 }
Example #22
0
/**
 * Escape the string for search
 *
 * @param $string
 * @return string
 */
function dbEscape($string)
{
    return trim(DB::getPdo()->quote($string), '\'');
}
Example #23
0
 function buildRelation($table, $field)
 {
     $pdo = \DB::getPdo();
     $sql = "\n        SELECT\n            referenced_table_name AS 'table',\n            referenced_column_name AS 'column'\n        FROM\n            information_schema.key_column_usage\n        WHERE\n            referenced_table_name IS NOT NULL\n            AND table_schema = '" . $this->db . "'  AND table_name = '{$table}' AND column_name = '{$field}' ";
     $Q = $pdo->query($sql);
     $rows = array();
     while ($row = $Q->fetch()) {
         $rows[] = $row;
     }
     return $rows;
 }
Example #24
0
 public static function getColoumnInfo($result)
 {
     $pdo = \DB::getPdo();
     $res = $pdo->query($result);
     $i = 0;
     $coll = array();
     while ($i < $res->columnCount()) {
         $info = $res->getColumnMeta($i);
         $coll[] = $info;
         $i++;
     }
     return $coll;
 }
Example #25
0
 /**
  * Applies a filter scope constraints to a DB query.
  * @param  string $scope
  * @param  Builder $query
  * @return Builder
  */
 public function applyScopeToQuery($scope, $query)
 {
     if (is_string($scope)) {
         $scope = $this->getScope($scope);
     }
     if (!$scope->value) {
         return;
     }
     $value = is_array($scope->value) ? array_keys($scope->value) : $scope->value;
     /*
      * Condition
      */
     if ($scopeConditions = $scope->conditions) {
         if (is_array($value)) {
             $filtered = implode(',', array_build($value, function ($key, $_value) {
                 return [$key, Db::getPdo()->quote($_value)];
             }));
         } else {
             $filtered = Db::getPdo()->quote($value);
         }
         $query->whereRaw(strtr($scopeConditions, [':filtered' => $filtered]));
     }
     /*
      * Scope
      */
     if ($scopeMethod = $scope->scope) {
         $query->{$scopeMethod}($value);
     }
     return $query;
 }
Example #26
0
 /**
  * Add new activity
  *
  * @param string $name
  *
  * @return int
  */
 public function addNew($name)
 {
     self::create(['name' => $name]);
     return (int) \DB::getPdo()->lastInsertId();
 }
Example #27
0
 /**
  * New conversation
  *
  * @param NewMessage $message
  *
  * @return int
  */
 public function addNewConversation(\Flocc\Mail\NewMessage $message)
 {
     /**
      * mail_conversations
      */
     $conversation = new Conversations();
     $conversation->last_message_time = null;
     $conversation->save();
     /**
      * ID
      */
     $conversation_id = (int) \DB::getPdo()->lastInsertId();
     /**
      * User label
      */
     $labels = new Labels();
     /**
      * owner
      */
     $mail_users = new Users();
     $mail_users->conversation_id = $conversation_id;
     $mail_users->user_id = $message->getUserId();
     $mail_users->label_id = $labels->getUserInboxID($message->getUserId());
     $mail_users->is_owner = '1';
     $mail_users->save();
     /**
      * mail_users
      */
     foreach ($message->getUsers() as $user_id) {
         if ((int) $user_id != $message->getUserId()) {
             $mail_users = new Users();
             $mail_users->conversation_id = $conversation_id;
             $mail_users->user_id = (int) $user_id;
             $mail_users->label_id = $labels->getUserInboxID($user_id);
             $mail_users->unread_messages = 1;
             $mail_users->save();
         }
     }
     /**
      * mail_messages
      */
     $messages = new Messages();
     $messages->conversation_id = $conversation_id;
     $messages->user_id = $message->getUserId();
     $messages->message = $message->getMessage();
     $messages->save();
     return (int) $conversation_id;
 }
Example #28
-1
 public function addItem()
 {
     if (Request::isMethod('post')) {
         $insertVal = array('am_name' => Input::get('item_name'), 'am_description' => Input::get('item_desc'), 'am_quantity' => Input::get('stock'), 'am_capacity' => Input::get('capacity'), 'am_price' => str_replace(',', '', Input::get('price')), 'am_group' => Input::get('item_type'));
         $this->GlobalModel->insertModel('tbl_amenities', $insertVal);
         $lastID = DB::getPdo()->lastInsertId();
         if (Input::hasFile('item_image')) {
             $files = Input::file('item_image');
             $i = 1;
             foreach ($files as $file) {
                 try {
                     $path = public_path() . '\\uploads\\amenity_type\\';
                     $extension = $file->getClientOriginalExtension();
                     $filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
                     $dateNow = date('Ymd_His');
                     $new_filename = Auth::user()->id . '_' . $dateNow . '_' . $i . '.' . $extension;
                     $upload_success = $file->move($path, $new_filename);
                 } catch (Exception $ex) {
                     $path = public_path() . '/uploads/amenity_type/';
                     $extension = $file->getClientOriginalExtension();
                     $filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
                     $dateNow = date('Ymd_His');
                     $new_filename = Auth::user()->id . '_' . $dateNow . '_' . $i . '.' . $extension;
                     $upload_success = $file->move($path, $new_filename);
                 }
                 $insertVal = array('image_fieldvalue' => $lastID, 'image_name' => $new_filename);
                 $this->GlobalModel->insertModel('tbl_images', $insertVal);
                 $i++;
             }
         }
         $this->TransLog->transLogger('Amenity Module', 'Added Amenity', $lastID);
     }
 }
 public function upload()
 {
     $input = Input::all();
     $validation = Validator::make($input, Template::$rules);
     if ($validation->passes()) {
         $file = Input::file('image');
         // your file upload input field in the form should be named 'file'
         $destinationPath = public_path() . '\\templates';
         $filename = $file->getClientOriginalName();
         //$extension =$file->getClientOriginalExtension(); //if you need extension of the file
         $uploadSuccess = Input::file('image')->move($destinationPath, $filename);
         $input = Input::all();
         if ($uploadSuccess) {
             //return Response::json('success', 200); // or do a redirect with some message that file was uploaded
             $this->image_thumbnail->t_id = Input::get('t_id');
             $this->image_thumbnail->title = Input::get('title');
             $this->image_thumbnail->img = $filename;
             $this->image_thumbnail->save();
             $id = DB::getPdo()->lastInsertId();
             return Redirect::route('templates.definefields', array('id' => $id));
             //return Redirect::route('image_thumbnail.upload', array('id' => $id));
         }
     }
     return Redirect::route('templates.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
Example #30
-4
 function index()
 {
     ob_start();
     $data = DB::select('SELECT * FROM countries LIMIT 2');
     print_r2($data);
     $select_text = ob_get_contents();
     ob_end_clean();
     //insert
     $inserted = DB::insert('INSERT INTO test (a,b) VALUES(?,?)', array(1, 2));
     $insert_text = 'inserted: ' . $inserted . '<br>';
     //update
     $affected = DB::update('UPDATE test SET b=? WHERE a=?', array(55, 1));
     $update_text = 'update affected: ' . $affected . '<br>';
     //delete
     $affected = DB::delete('DELETE test WHERE a=?', array(999));
     $delete_text = 'delete affected: ' . $affected . '<br>';
     //show tables
     ob_start();
     $data = DB::select('SHOW TABLES');
     print_r2($data);
     $show_tables_text = ob_get_contents();
     ob_end_clean();
     //use pdo object
     //
     $pdo = DB::getPdo();
     $sql = 'SELECT * FROM language LIMIT 2';
     $query = $pdo->query($sql);
     ob_start();
     while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
         print_r($row);
     }
     $pdo_text = ob_get_contents();
     ob_end_clean();
     // ---------------
     $texts = array();
     $texts['select_text'] = $select_text;
     $texts['insert_text'] = $insert_text;
     $texts['update_text'] = $update_text;
     $texts['delete_text'] = $delete_text;
     $texts['show_tables_text'] = $show_tables_text;
     $texts['pdo_text'] = $pdo_text;
     return View::make('database', $texts);
 }