public function import($entity)
 {
     $appHelper = new libs\AppHelper();
     $className = $appHelper->getNameSpace() . $entity;
     $model = new $className();
     $table = $model->getTable();
     $columns = \Schema::getColumnListing($table);
     $key = $model->getKeyName();
     $notNullColumnNames = array();
     $notNullColumnsList = \DB::select(\DB::raw("SHOW COLUMNS FROM `" . $table . "` where `Null` = 'no'"));
     if (!empty($notNullColumnsList)) {
         foreach ($notNullColumnsList as $notNullColumn) {
             $notNullColumnNames[] = $notNullColumn->Field;
         }
     }
     $status = \Input::get('status');
     $filePath = null;
     if (\Input::hasFile('import_file') && \Input::file('import_file')->isValid()) {
         $filePath = \Input::file('import_file')->getRealPath();
     }
     if ($filePath) {
         \Excel::load($filePath, function ($reader) use($model, $columns, $key, $status, $notNullColumnNames) {
             $this->importDataToDB($reader, $model, $columns, $key, $status, $notNullColumnNames);
         });
     }
     $importMessage = $this->failed == true ? \Lang::get('panel::fields.importDataFailure') : \Lang::get('panel::fields.importDataSuccess');
     return \Redirect::to('panel/' . $entity . '/all')->with('import_message', $importMessage);
 }
 public function run()
 {
     DB::table('Posts')->delete();
     Post::create(['title' => 'First Post', 'author' => 'Евгений', 'excerpt' => 'First Post body', 'text' => 'Content First Post body', 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
     Post::create(['title' => 'Second Post', 'author' => 'Евгений', 'excerpt' => 'Second Post body', 'text' => 'Content Second Post body', 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
     Post::create(['title' => 'Third Post', 'author' => 'Евгений', 'excerpt' => 'Third Post body', 'text' => 'Content Third Post body', 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('posts', function (Blueprint $table) {
         $table->boolean('body_rtl')->nullable()->default(null)->after('body_html');
     });
     Post::where(DB::raw('1=1'))->update(['body_parsed' => null, 'body_parsed_at' => null, 'body_html' => null]);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('orders', function (Blueprint $table) {
         $table->increments('id');
         $table->string('sn', 32)->unique();
         $table->enum('order_status', ['pending', 'confirmed', 'completed', 'branched', 'canceled'])->default('pending');
         $table->jsonb('branches')->nullable();
         $table->integer('order_lock_id')->default(0)->nullable();
         $table->decimal('order_discount', 10, 2)->default(0);
         $table->integer('user_id');
         $table->string('logistics_consignee');
         $table->jsonb('logistics_region');
         $table->string('logistics_address');
         $table->string('logistics_zipcode')->nullable();
         $table->string('logistics_mobile')->nullable();
         $table->string('logistics_phone')->nullable();
         $table->string('logistics_email')->nullable();
         $table->integer('logistics_id');
         $table->boolean('logistics_cod')->default(false);
         $table->string('logistics_tracking_number')->default('');
         $table->enum('logistics_status', ['unshipped', 'shipped'])->default('unshipped');
         $table->timestamp('logistics_time')->nullable();
         $table->integer('payment_id');
         $table->enum('payment_status', ['unpaid', 'paid'])->default('unpaid');
         $table->timestamp('payment_due')->default(\DB::raw('now()::timestamp(0) + interval \'1 day\''));
         $table->timestamp('payment_time')->nullable();
         $table->decimal('subtotal_product', 10, 2)->default(0);
         $table->decimal('subtotal_tax', 10, 2)->default(0);
         $table->decimal('subtotal_discount', 10, 2)->default(0);
         $table->decimal('subtotal_logistics', 10, 2)->default(0);
         $table->decimal('total_amount', 10, 2)->default(0);
         $table->decimal('total_refunded', 10, 2)->default(0);
         $table->timestamps();
     });
 }
Beispiel #5
0
 public function getDetailData($id, $postData, $properties)
 {
     $templateId = $postData['templateId'];
     $pdContractData = PdContractData::getTableName();
     $pdContractTemplateAttribute = PdContractTemplateAttribute::getTableName();
     $pdCodeContractAttribute = PdCodeContractAttribute::getTableName();
     $pdContractQtyFormula = PdContractQtyFormula::getTableName();
     $contractDataSet = PdContractData::join($pdCodeContractAttribute, "{$pdContractData}.ATTRIBUTE_ID", '=', "{$pdCodeContractAttribute}.ID")->leftJoin($pdContractQtyFormula, "{$pdCodeContractAttribute}.FORMULA_ID", '=', "{$pdContractQtyFormula}.ID")->where("{$pdContractData}.CONTRACT_ID", '=', $id)->select("{$pdContractData}.*", "{$pdContractData}.CONTRACT_ID as CONTRACT_ID_INDEX", "{$pdContractData}.ATTRIBUTE_ID as ATTRIBUTE_ID_INDEX", "{$pdCodeContractAttribute}.ID as DT_RowId", "{$pdCodeContractAttribute}.ID as {$pdContractData}", "{$pdCodeContractAttribute}.NAME as CONTRACT_ID", "{$pdCodeContractAttribute}.CODE as ATTRIBUTE_ID", "{$pdCodeContractAttribute}.ID as ID", "{$pdContractQtyFormula}.NAME as FORMULA")->get();
     $selects = ["{$pdCodeContractAttribute}.ID as DT_RowId", "{$pdCodeContractAttribute}.ID as {$pdContractData}", "{$pdCodeContractAttribute}.NAME as CONTRACT_ID", "{$pdCodeContractAttribute}.CODE as ATTRIBUTE_ID", "{$pdCodeContractAttribute}.ID", "{$pdCodeContractAttribute}.FORMULA_ID as FORMULA", "{$pdCodeContractAttribute}.ID as ATTRIBUTE_ID_INDEX", "{$pdContractQtyFormula}.NAME as FORMULA", \DB::raw("{$id} as CONTRACT_ID_INDEX")];
     foreach ($properties as $property) {
         $columnName = $property['data'];
         if ($columnName != 'CONTRACT_ID' && $columnName != 'ATTRIBUTE_ID' && $columnName != 'ID') {
             $selects[] = \DB::raw("null as {$columnName}");
         }
     }
     $templateQuery = PdContractTemplateAttribute::join($pdCodeContractAttribute, "{$pdContractTemplateAttribute}.ATTRIBUTE", '=', "{$pdCodeContractAttribute}.ID")->leftJoin($pdContractQtyFormula, "{$pdCodeContractAttribute}.FORMULA_ID", '=', "{$pdContractQtyFormula}.ID")->where("{$pdContractTemplateAttribute}.CONTRACT_TEMPLATE", '=', $templateId)->where("{$pdContractTemplateAttribute}.ACTIVE", '=', 1)->select($selects);
     // 										    	->get();
     $existAttributes = $contractDataSet->pluck('DT_RowId');
     if (count($existAttributes) > 0) {
         $templateQuery->whereNotIn("{$pdCodeContractAttribute}.ID", $existAttributes);
     }
     $templateDataSet = $templateQuery->get();
     $dataSet = $contractDataSet->merge($templateDataSet);
     return $dataSet;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('sales', function (Blueprint $table) {
         $table->engine = 'InnoDB';
         $table->increments('id');
         $table->unsignedInteger('qc_user_id')->nullable()->index();
         // quality control user
         $table->timestamp('qc_processed_datetime')->nullable();
         $table->unsignedInteger('sale_status_id')->nullable()->index();
         $table->unsignedInteger('user_id')->index();
         // agent who entered the sale
         $table->unsignedInteger('product_id')->index();
         $table->unsignedInteger('customer_id')->index();
         $table->date('date_sold');
         $table->string('order_number');
         $table->tinyInteger('ninety_days')->default('0');
         $table->tinyInteger('verified')->default('0');
         $table->text('remarks');
         $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
         $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
         $table->foreign('user_id')->references('id')->on('users')->onDelete('restrict');
         $table->foreign('product_id')->references('id')->on('products')->onDelete('restrict');
         $table->foreign('customer_id')->references('id')->on('customers')->onDelete('restrict');
         $table->foreign('sale_status_id')->references('id')->on('sale_statuses')->onDelete('restrict');
         $table->foreign('qc_user_id')->references('id')->on('users')->onDelete('restrict');
     });
 }
Beispiel #7
0
 protected static function personPrepare()
 {
     return PersonModel::join(PersonLangModel::getTableName(), PersonLangModel::getField("person_id"), '=', PersonModel::getField("id"))->join(PersonRelModel::getTableName(), PersonRelModel::getField("person_id"), '=', PersonModel::getField("id"))->leftJoin(Files::getTableName(), function ($join) {
         $join->on(Files::getField("module_id"), '=', PersonModel::getField("id"));
         $join->on(Files::getField("module_name"), '=', DB::raw("'person'"));
     })->where(PersonLangModel::getField("lang_id"), \WebAPL\Language::getId())->orderBy('first_name', 'asc')->orderBy('last_name', 'asc');
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('users', function (Blueprint $table) {
         $table->increments('id');
         $table->string('emp_name');
         $table->string('emp_gender');
         $table->integer('shift_id')->unsigned();
         $table->foreign('shift_id')->references('id')->on('shifts')->onDelete('cascade');
         $table->integer('position_id')->unsigned();
         $table->foreign('position_id')->references('id')->on('positions')->onDelete('cascade');
         $table->integer('img_id')->unsigned();
         $table->foreign('img_id')->references('id')->on('profile_image')->onDelete('cascade');
         $table->string('email');
         $table->integer('username')->unique();
         $table->string('password', 60);
         $table->integer('permissioners');
         $table->integer('VL_entitlement');
         $table->integer('SL_entitlement');
         $table->integer('ML_entitlement');
         $table->integer('PL_entitlement');
         $table->integer('VL_taken')->default(0);
         $table->integer('SL_taken')->default(0);
         $table->integer('ML_taken')->default(0);
         $table->integer('PL_taken')->default(0);
         $table->rememberToken();
         $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
         $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
     });
 }
Beispiel #9
0
 public function no_assigned($user_id)
 {
     $no_assigned = EntrustRole::whereNotIn('id', function ($query) use($user_id) {
         $query->select(DB::raw('role_id'))->from('assigned_roles')->whereRaw("user_id = ?", array($user_id));
     })->lists('name', 'id');
     return $no_assigned;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('company_person', function (Blueprint $table) {
         $table->increments('id');
         $table->integer('person_id')->unsigned();
         $table->integer('company_id')->unsigned();
         $table->integer('department_id')->unsigned()->nullable();
         $table->integer('title_id')->unsigned()->nullable();
         $table->integer('group_type_id')->unsigned();
         $table->integer('group_id')->unsigned()->nullable();
         $table->string('phone')->nullable();
         $table->string('extension')->nullable();
         $table->string('cellphone')->nullable();
         $table->string('email')->nullable();
         $table->string('division_ids')->nullable();
         $table->string('slack_token')->nullable();
         $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
         $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP'));
         $table->softDeletes();
     });
     Schema::table('company_person', function (Blueprint $table) {
         $table->foreign('person_id')->references('id')->on('people');
         $table->foreign('company_id')->references('id')->on('companies');
         $table->foreign('department_id')->references('id')->on('departments');
         $table->foreign('title_id')->references('id')->on('titles');
         $table->foreign('group_type_id')->references('id')->on('group_types');
         $table->foreign('group_id')->references('id')->on('groups');
         $table->unique(['person_id', 'company_id']);
     });
 }
Beispiel #11
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //
     $configTables = config('sync.sync_tables');
     $logs = \DB::table(\DB::raw('(select * from table_logs order by id desc) as logs'))->groupBy('logs.table', 'logs.column', 'logs.pk_id')->get();
     foreach ($logs as $log) {
         if (isset($configTables[$log->table])) {
             $info = $configTables[$log->table];
             $pk = array_shift($info);
             if (!$pk) {
                 $this->info('Pk not found for ' . $log->table . ' with pk id ' . $log->pk_id);
                 continue;
             }
             $row = \DB::table($log->table)->where($pk, $log->pk_id)->first();
             if ($row) {
                 $currentValue = $row->{$log->column};
                 if ($currentValue != $log->value) {
                     $this->info('Value not equal for ' . $log->table . ' column ' . $log->column . ' with pk id ' . $log->pk_id . ' val: ' . $currentValue . ':' . $log->value);
                     if (false !== strpos($log->column, 'date')) {
                         $values = [$log->column => new \DateTime($log->value), 'updated_at' => $log->created_at, 'updated_by' => $log->updated_by];
                     } else {
                         $values = [$log->column => $log->value, 'updated_at' => $log->created_at, 'updated_by' => $log->updated_by];
                     }
                     \DB::table($log->table)->where($pk, $log->pk_id)->lockForUpdate()->update($values);
                 }
             } else {
                 $this->info('Row not found for ' . $log->table . ' with pk id ' . $log->pk_id);
             }
         } else {
             $this->info('Table pk column not found ' . $log->table);
         }
     }
 }
 public function current()
 {
     $count = Host::where("id", "!=", 0)->get()->count();
     $backups = Backup::where(DB::raw('YEAR(created_at)'), '=', "2013")->where(DB::raw('MONTH(created_at)'), '=', "01")->where(DB::raw('DAY(created_at)'), '=', "21")->where('type', '=', 'cron')->get(array('id', 'host_id', 'hostname', 'status', 'files_original_size', 'db_original_size', 'total_size'));
     $report = "";
     foreach ($backups as $backup) {
         $backup["files_original_size"] = $this->ghs($backup["files_original_size"]);
         $backup["db_original_size"] = $this->ghs($backup["db_original_size"]);
         $backup["total_size"] = $this->ghs($backup["total_size"]);
         if ($backup["status"] == "ok") {
             $row = '<tr class="success">';
         }
         if ($backup["status"] == "broken") {
             $row = '<tr class="danger">';
         }
         if ($backup["status"] == "removed") {
             $row = '<tr class="warning">';
         }
         $row .= "<td>" . $backup["id"] . "</td>";
         $row .= "<td>" . $backup["host_id"] . "</td>";
         $row .= "<td>" . $backup["hostname"] . "</td>";
         $row .= "<td>" . $backup["files_original_size"] . "</td>";
         $row .= "<td>" . $backup["db_original_size"] . "</td>";
         $row .= "<td>" . $backup["total_size"] . "</td>";
         $row .= "</tr>";
         $report .= $row;
     }
     return View::make('reports.daily')->with('report', $report)->with('hosts_count', $count)->with('email', Auth::user()->email);
 }
Beispiel #13
0
 /**
  * Display the specified resource.
  * GET /sessions/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $session = TheSession::find($id);
     $array = array();
     $array["sensors"] = DB::select(DB::raw('Select DISTINCT `sensors`.*, `data`.`session_id` FROM `sensors` INNER JOIN `data` ON `data`.`sensor_id` = `sensors`.`sensor_id` WHERE `data`.`session_id` = ' . $session->session_id));
     return View::make('session', ['session' => $array, 'id' => $id]);
 }
Beispiel #14
0
 public function scopenombre($publicidad, $nombre)
 {
     $publicidad = DB::table('publicidad as p')->leftjoin('restaurantes as r', function ($join) use($nombre) {
         $join->on('r.id', '=', DB::raw('"' . $nombre . '"'));
     })->select('r.nombre as nombre');
     return $publicidad;
 }
Beispiel #15
0
 public function run()
 {
     DB::table('ClickBusPlaces')->delete();
     $clickbusPlaces = file_get_contents('https://api-evaluation.clickbus.com.br/api/v1/places');
     $clickbusHash = md5($clickbusPlaces);
     $clickbusPlaces = (array) json_decode($clickbusPlaces)->items;
     foreach ($clickbusPlaces as $place) {
         $array_insert = array('item_id' => $place->id, 'station_id' => $place->station_id, 'slug' => $place->slug, 'locale' => $place->locale, 'is_primary' => $place->is_primary, 'item_created_at' => $place->created_at, 'item_updated_at' => $place->updated_at, 'place_created_at' => $place->place->created_at, 'place_updated_at' => $place->place->updated_at, 'place_id' => $place->place->place_id, 'place_name' => $place->place->name, 'state_code' => $place->place->state->code, 'state_name' => $place->place->state->name);
         if (strcasecmp(env('DB_DRIVER'), 'pgsql') == 0 && count($place->place->longitude) > 0 && count($place->place->latitude) > 0) {
             $array_insert['place_position'] = DB::raw("ST_GeomFromText('POINT({$place->place->longitude} {$place->place->latitude})', 4326)");
         }
         DB::table('ClickBusPlaces')->insert($array_insert);
     }
     DB::table('ClickBusCompanies')->delete();
     $pages = json_decode(file_get_contents('https://api-evaluation.clickbus.com.br/api/v1/buscompanies'))->meta->totalPages;
     $busCompaniesHash = '';
     for ($i = 1; $i <= intval($pages); $i++) {
         $companies = file_get_contents("https://api-evaluation.clickbus.com.br/api/v1/buscompanies?page={$i}");
         $busCompaniesHash .= $companies;
         $companies = json_decode($companies)->busCompanies;
         foreach ($companies as $company) {
             DB::table('ClickBusCompanies')->insert(array('id' => $company->id, 'nome' => $company->name, 'logo_url' => $company->logo->url));
         }
     }
 }
Beispiel #16
0
 public function edit(User $user)
 {
     $currencies = Currency::select(\DB::raw("CONCAT(name, ' ', symbol) AS full_name, id"))->lists("full_name", "id");
     $users = User::select(\DB::raw("CONCAT(surname, ' ', name) AS full_name, id"))->lists("full_name", "id");
     $vehicles = Vehicle::lists("name", "id");
     return View::make('Middle.Web.User.edit', compact(['user', 'currencies', 'users', 'vehicles']));
 }
 public function index2()
 {
     set_time_limit(300);
     $stok = DB::table('tbstock')->groupBy('cKode')->select(DB::raw('cKode, sum(nQtyReal) as sum'))->orderBy('cKode', 'asc')->get();
     foreach ($stok as $row) {
         $data = DB::table('tbinventori')->where('cKode', $row->cKode)->orderBy('urutan', 'asc')->get();
         $n = 1;
         $i = 0;
         $jum = 0;
         $cek = false;
         foreach ($data as $baris) {
             if ($cek == false) {
                 $jum += $baris->stok;
                 if ($row->sum <= $jum) {
                     $cek = true;
                     if ($i == 0) {
                         DB::table('tbinventori')->where('cKode', $baris->cKode)->where('urutan', $baris->urutan)->update(array('stok' => (int) $row->sum));
                     } else {
                         $st = $jum - $row->sum;
                         DB::table('tbinventori')->where('cKode', $baris->cKode)->where('urutan', $baris->urutan)->update(array('stok' => $baris->stok - $st));
                     }
                 }
             } else {
                 DB::table('tbinventori')->where('cKode', $baris->cKode)->where('urutan', $baris->urutan)->update(array('stok' => 0, 'urutan' => ''));
             }
             $i++;
         }
         $data = DB::table('tbinventori')->where('cKode', $row->cKode)->where('urutan', '<>', '')->orderBy('urutan', 'desc')->get();
         foreach ($data as $baris) {
             DB::table('tbinventori')->where('id', $baris->id)->update(array('urutan' => $n));
             $n++;
         }
     }
 }
Beispiel #18
0
 public function edit($id)
 {
     if (Request::isMethod('post')) {
         $rules = array('status_id' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/{$this->name}/{$id}/{$this->action}")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = Order::find($id);
             $table->status_id = Input::get('status_id');
             if ($table->save()) {
                 $name = trans("name.{$this->name}");
                 return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
             }
             return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
         }
     }
     $order = DB::table('orders as o')->join('users as u', 'o.user_id', '=', 'u.id')->join('order_status as os', 'o.status_id', '=', 'os.id')->join('orders_details as od', 'o.id', '=', 'od.order_id')->select('o.id', DB::raw('CONCAT(u.firstname, " ", u.lastname) AS fullname'), 'os.title', 'o.created_at', DB::raw('SUM(od.price) AS total'), 'o.comment', 'o.status_id')->where('o.id', $id)->first();
     $products = DB::table('products as p')->join('orders_details as od', 'p.id', '=', 'od.product_id')->join('orders as o', 'od.order_id', '=', 'o.id')->select('p.id', 'p.link', 'p.name', 'od.price', 'od.quantity', DB::raw('od.price * od.quantity AS total'))->where('o.id', $id)->orderBy('o.id', 'asc')->get();
     $ordersStatus = OrderStatus::all();
     foreach ($ordersStatus as $status) {
         $orderStatus[$status['id']] = $status['title'];
     }
     return View::make("admin.shop.order.edit", ['item' => $order, 'name' => $this->name, 'action' => $this->action, 'status' => $orderStatus, 'products' => $products]);
 }
Beispiel #19
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('categories')->truncate();
     DB::table('categories')->insert(array(array('name' => 'Браслеты', 'url' => 'bracelets', 'created_at' => DB::raw('NOW()'), 'updated_at' => DB::raw('NOW()')), array('name' => 'Сережки', 'url' => 'earrings', 'created_at' => DB::raw('NOW()'), 'updated_at' => DB::raw('NOW()')), array('name' => 'Кольца', 'url' => 'rings', 'created_at' => DB::raw('NOW()'), 'updated_at' => DB::raw('NOW()')), array('name' => 'Кулоны', 'url' => 'pendants', 'created_at' => DB::raw('NOW()'), 'updated_at' => DB::raw('NOW()')), array('name' => 'Разное', 'url' => 'misc', 'created_at' => DB::raw('NOW()'), 'updated_at' => DB::raw('NOW()'))));
     DB::table('users')->truncate();
     DB::table('users')->insert(array('name' => 'admin', 'email' => '*****@*****.**', 'password' => bcrypt('123456789'), 'created_at' => DB::raw('NOW()'), 'updated_at' => DB::raw('NOW()')));
 }
 public function model()
 {
     $data = array();
     $make = Input::get('make', '');
     $models = DB::select(DB::raw("SELECT * FROM model WHERE id in (SELECT model FROM search_suggestion WHERE make = :make)"), array('make' => $make));
     return Response::json($models);
 }
Beispiel #21
0
 public function run()
 {
     DB::table('Posts')->delete();
     Post::create(['title' => 'First Post', 'slug' => 'first-post', 'excerpt' => 'First Post body', 'content' => 'Content First Post body', 'published' => true, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
     Post::create(['title' => 'Second Post', 'slug' => 'second-post', 'excerpt' => 'Second Post body', 'content' => 'Content Second Post body', 'published' => false, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
     Post::create(['title' => 'Third Post', 'slug' => 'third-post', 'excerpt' => 'Third Post body', 'content' => 'Content Third Post body', 'published' => false, 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
 }
 public function dashboard()
 {
     $counts = ['organizations' => Organization::count(), 'users' => User::count(), 'todos' => Todo::count(), 'mt_users' => User::has('organizations', '>', 1)->count()];
     $newestOrg = Organization::orderBy('created_at', 'desc')->first();
     $orgWithMostTodos = DB::table('organizations')->select(['organizations.name', DB::raw('count(todos.organization_id) as total')])->join('todos', 'todos.organization_id', '=', 'organizations.id')->orderBy('total', 'desc')->groupBy('todos.organization_id')->first();
     $this->view('dashboard', compact('counts', 'newestOrg', 'orgWithMostTodos'));
 }
 public function getProfile($id)
 {
     DB::setFetchMode(PDO::FETCH_ASSOC);
     $member = DB::table('members')->where('members.id', '=', $id)->leftjoin('region', 'members.region_id', '=', 'region.id')->leftjoin('city', 'members.city_id', '=', 'city.id')->select(DB::raw('members.id, members.user_id, members.avatar_url, members.avatar_url_big, members.name, members.surname,members.rep, city.name as city_name, region.name as region_name, city.id as city_id, region.id as region_id'))->get();
     //echo "<pre>";
     //var_dump($regions);
     //echo "</pre>";
     //die();
     if (!empty($member)) {
         $member = $member[0];
         $member['ajax_url'] = action('ProfileController@postCities');
         $member['all_regions'] = DB::table('region')->get();
         $member['regions_cities'] = DB::table('city')->where('region_id', '=', $member['region_id'])->get();
         if (Auth::check()) {
             if ($member['user_id'] === Auth::user()->id) {
                 if (Auth::user()->vk_id != 0) {
                     $member['is_vk'] = true;
                 } else {
                     $member['is_vk'] = false;
                 }
                 return View::make('profile-edit', $member);
             }
         } else {
             return View::make('profile', $member);
         }
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('exit_pass', function (Blueprint $table) {
         $table->increments('id');
         $table->integer('user_id')->unsigned();
         $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
         $table->integer('department_id')->unsigned();
         $table->foreign('department_id')->references('id')->on('departments')->onDelete('cascade');
         $table->integer('form_id')->unsigned()->default(1);
         $table->foreign('form_id')->references('id')->on('form_types')->onDelete('cascade');
         $table->text('reason');
         $table->text('purpose');
         $table->integer('permission_id1')->unsigned();
         $table->foreign('permission_id1')->references('id')->on('users')->onDelete('cascade');
         $table->integer('permission_id2')->unsigned();
         $table->foreign('permission_id2')->references('id')->on('users')->onDelete('cascade');
         $table->integer('permission_id3')->unsigned();
         $table->foreign('permission_id3')->references('id')->on('users')->onDelete('cascade');
         $table->integer('permission_id4')->unsigned();
         $table->foreign('permission_id4')->references('id')->on('users')->onDelete('cascade');
         $table->integer('permission_1');
         $table->integer('permission_2');
         $table->integer('permission_3');
         $table->integer('permission_4');
         $table->integer('days_applied');
         $table->integer('status')->default(0);
         $table->timestamp('date_from')->default('0000-00-00 00:00:00');
         $table->timestamp('date_to')->default('0000-00-00 00:00:00');
         $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
         $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
     });
 }
Beispiel #25
0
 public function run()
 {
     DB::table('update_records')->delete();
     DB::table('view_cache')->delete();
     DB::table('posts')->delete();
     DB::table('threads')->delete();
     ##################
     Thread::create(['id' => 1, 'thread_id' => 111111111, 'board' => 'a', 'updated_num' => 0, 'views' => '500', 'notice' => null, 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null]);
     Post::create(['chan_id' => 111111111, 'thread_id' => 1, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 111111112, 'thread_id' => 1, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 111111113, 'thread_id' => 1, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 111111114, 'thread_id' => 1, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     ##################
     Thread::create(['id' => 2, 'thread_id' => 222222222, 'board' => 'b', 'updated_num' => 0, 'views' => '555', 'notice' => null, 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null]);
     Post::create(['chan_id' => 222222222, 'thread_id' => 2, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 222222223, 'thread_id' => 2, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 222222224, 'thread_id' => 2, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 222222225, 'thread_id' => 2, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     ##################
     Thread::create(['id' => 3, 'thread_id' => 333333333, 'board' => 'g', 'updated_num' => 3, 'views' => '123', 'notice' => 'Admin note: This thread is garbage.', 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null]);
     Post::create(['chan_id' => 333333333, 'thread_id' => 3, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 333333334, 'thread_id' => 3, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 333333335, 'thread_id' => 3, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 333333336, 'thread_id' => 3, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     ##################
     Thread::create(['id' => 4, 'thread_id' => 444444444, 'board' => 'q', 'updated_num' => 10, 'views' => '1250', 'notice' => null, 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null, 'deleted_at' => DB::raw('NOW()')]);
     Post::create(['chan_id' => 444444444, 'thread_id' => 4, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 444444445, 'thread_id' => 4, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 444444446, 'thread_id' => 4, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 444444447, 'thread_id' => 4, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
 }
Beispiel #26
0
 public function get_total_rows($table, $param)
 {
     $select_total = $table->select(\DB::raw('sql_calc_found_rows ' . $param['select']));
     $select_total = $select_total->get();
     $select_total = \DB::select(\DB::raw("select found_rows() as total;"));
     return $select_total[0]->total;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('users', function (Blueprint $table) {
         $table->dateTime('announcement_expires')->nullable();
     });
     DB::update(DB::raw("UPDATE users SET announcement_expires = DATE_ADD(announcement_start, INTERVAL 7 DAY) WHERE announcement_start IS NOT NULL"));
 }
Beispiel #28
0
    public function scopeNearLatLong($query, $lat, $lng, $radius = 10, $unit = 69.0)
    {
        if (!is_numeric($lat) || -90 >= $lat || $lat >= 90) {
            throw new RangeException("Latitude must be between -90 and 90 degrees.");
        }
        if (!is_numeric($lng) || -180 >= $lng || $lng >= 180) {
            throw new RangeException("Longitude must be between -180 and 180 degrees.");
        }
        $subQuery = clone $query;
        $latDistance = $radius / $unit;
        $latNorth = $lat - $latDistance;
        $latSouth = $lat + $latDistance;
        $lngDistance = $radius / ($unit * cos(deg2rad($lat)));
        $lngEast = $lng - $lngDistance;
        $lngWest = $lng + $lngDistance;
        $subQuery->selectRaw(DB::raw('*, (? * DEGREES(
			ACOS(
				  COS(RADIANS(?)) * COS(RADIANS(latitude)) * COS(RADIANS(? - longitude))
				+ SIN(RADIANS(?)) * SIN(RADIANS(latitude))
			)
		)) AS distance'))->addBinding([$unit, $lat, $lng, $lat], 'select');
        $subQuery->whereBetween('latitude', [$latNorth, $latSouth]);
        $subQuery->whereBetween('longitude', [$lngEast, $lngWest]);
        $query->from(DB::raw('(' . $subQuery->toSql() . ') as d'));
        $query->mergeBindings($subQuery->getQuery());
        $query->where('distance', '<=', $radius);
        // // To use:
        // $latitude  =  29.443778;
        // $longitude = -98.478903;
        // // Default radius is 10; default unit is miles.
        // Model::nearLatLong($latitude, $longitude)->get();
    }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if ($this->executable) {
         Schema::create('sections', function (Blueprint $table) {
             $table->increments('id');
             $table->string('uid', 22)->nullable()->default(null);
             $table->integer('course_id')->nullable()->unsigned()->default(null);
             $table->string('name')->nullable()->default(null);
             $table->string('description', 500)->nullable()->default(null);
             $table->text('content')->nullable()->default(null);
             $table->string('video')->nullable()->default(null);
             $table->text('downloads')->nullable()->default(null);
             $table->boolean('published')->nullable()->default(false);
             $table->boolean('chapter')->nullable()->default(false);
             $table->smallInteger('order')->nullable()->unsigned()->default(0);
             $table->smallInteger('wait')->nullable()->unsigned()->default(24);
             //wait in hours
             $table->timestamp('opens_at')->nullable()->default(null);
             //wait until datetime
             $table->timestamp('created_at')->nullable()->default(DB::raw('CURRENT_TIMESTAMP'));
             $table->timestamp('updated_at')->nullable()->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
             $table->foreign('course_id')->references('id')->on('courses')->onUpdate('cascade')->onDelete('cascade');
         });
     }
 }
 public function create()
 {
     $regions = Region::lists("name", "id");
     $users = User::select(\DB::raw("CONCAT(surname, ' ', name) AS full_name, id"))->lists("full_name", "id");
     $vehicles = Vehicle::lists("name", "id");
     return View::make('Middle.Web.VehiclesRegionsAllotment.create', compact(['regions', 'users', 'vehicles']));
 }