/**
  * Run the migrations.
  */
 public function up()
 {
     Schema::create('character_set_structure', function (Blueprint $table) {
         $table->increments('id');
         $table->unsignedInteger('character_set_id')->index();
         $table->unsignedInteger('version_number_id')->index();
         $table->string('description');
         $table->string('mysql_character_set');
         // Composite keys
         $table->unique(['character_set_id', 'version_number_id'], uniqid());
         // Foreign keys
         $table->foreign('character_set_id')->references('id')->on('character_set');
         $table->foreign('version_number_id')->references('id')->on('version_number');
     });
     DB::transaction(function () {
         CharacterSetStructure::unguard();
         foreach ($this->data as $datum) {
             $character_set = CharacterSet::where(['value' => $datum['character_set']])->firstOrFail();
             $version_number = VersionNumber::where(['value' => $datum['version_number']])->firstOrFail();
             $character_set_structure = new CharacterSetStructure();
             $character_set_structure->description = $datum['description'];
             $character_set_structure->mysql_character_set = $datum['mysql_character_set'];
             $character_set_structure->characterSet()->associate($character_set);
             $character_set_structure->versionNumber()->associate($version_number);
             $character_set_structure->save();
         }
         CharacterSetStructure::reguard();
     });
 }
 /**
  * Store a newly created resource in storage.
  * POST /users
  *
  * @return Response
  */
 public function store()
 {
     Input::merge(array_map('trim', Input::all()));
     $input = Input::all();
     $validation = Validator::make($input, User::$rules);
     if ($validation->passes()) {
         DB::transaction(function () {
             $user = new User();
             $user->first_name = strtoupper(Input::get('first_name'));
             $user->middle_initial = strtoupper(Input::get('middle_initial'));
             $user->last_name = strtoupper(Input::get('last_name'));
             $user->dept_id = Input::get('department');
             $user->confirmed = 1;
             $user->active = 1;
             $user->email = Input::get('email');
             $user->username = Input::get('username');
             $user->password = Input::get('password');
             $user->password_confirmation = Input::get('password_confirmation');
             $user->confirmation_code = md5(uniqid(mt_rand(), true));
             $user->image = "default.png";
             $user->save();
             $role = Role::find(Input::get('name'));
             $user->roles()->attach($role->id);
         });
         return Redirect::route('user.index')->with('class', 'success')->with('message', 'Record successfully added.');
     } else {
         return Redirect::route('user.create')->withInput(Input::except(array('password', 'password_confirmation')))->withErrors($validation)->with('class', 'error')->with('message', 'There were validation errors.');
     }
 }
Ejemplo n.º 3
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     if ($this->beforeTransaction()) {
         \DB::transaction($this->transaction());
         $this->afterTransaction();
     }
 }
Ejemplo n.º 4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::transaction(function () {
         DB::statement('SET foreign_key_checks = 0;');
         DB::table('roles')->truncate();
         DB::table('users')->truncate();
         DB::table('folders')->truncate();
         DB::table('q_and_a')->truncate();
         DB::table('tags')->truncate();
         DB::table('comment')->truncate();
         DB::table('votes')->truncate();
         DB::table('roles')->truncate();
         DB::statement('SET foreign_key_checks = 1;');
         $this->call(RolesTableSeeder::class);
         $this->call(UsersSeeder::class);
         $this->call(FoldersSeeder::class);
         $this->call(QuestionsSeeder::class);
         $this->call(TagsSeeder::class);
         $this->call(AnswersSeeder::class);
         $this->call(VotesSeeder::class);
         $this->call(CommentForAnswerSeeder::class);
         $this->call(CommentForQuestionSeeder::class);
     });
     Model::reguard();
 }
Ejemplo n.º 5
0
 public function nuevaCorreccionObservacion($inputs)
 {
     $Correspondencia = Correspondencia::find($inputs['IdCorrespondencia']);
     if ($Correspondencia->getIdCaracter() == 1) {
         DB::transaction(function () use($inputs) {
             $oficio = new OficioSaliente();
             $oficioU = Observaciones::find($inputs['IdObservaciones']);
             $oficioU->Oficio_Saliente_Id = $inputs['IdConsecutivo'];
             $oficioU->Observacion_Usuario_Id = $oficio->getIdRevisor($inputs['IdConsecutivo'], 1);
             //Usuario que va a corregir
             $oficioU->DescripcionObservaciones = $inputs['Observacion'];
             $oficioU->save();
         });
     } else {
         DB::transaction(function () use($inputs) {
             $oficio = new OficioSaliente();
             $oficioU = Observaciones::find($inputs['IdObservaciones']);
             $oficioU->Oficio_Saliente_Id = $inputs['IdConsecutivo'];
             $oficioU->Observacion_Usuario_Id = $oficio->getIdRevisor($inputs['IdConsecutivo'], $Correspondencia->getIdCaracter());
             //Usuario que va a corregir
             $oficioU->DescripcionObservaciones = $inputs['Observacion'];
             $oficioU->save();
         });
     }
     /*DB::transaction(function () use ($inputs, $path){
     			$oficioU = Correspondencia::find($inputs['IdCorrespondencia']);
     			$oficioU->URLPDF = $path;
     			$oficioU->save();
     		});*/
     DB::transaction(function () use($inputs) {
         $oficioU = Correspondencia::find($inputs['IdCorrespondencia']);
         $oficioU->Estatus_Id = 401;
         $oficioU->save();
     });
 }
 public function approveApplication(Request $request)
 {
     $shop_card_application_id = $request->input('require_id');
     $application = ShopCardApplication::find($shop_card_application_id);
     $customer = Customer::find($application->customer_id);
     $card_type = $application->cardType;
     try {
         \DB::transaction(function () use($application, $customer, $card_type) {
             $customer_rows = \DB::table('customers')->where('id', $customer->id);
             $customer_rows->lockForUpdate();
             $customer_row = $customer_rows->first();
             if ($customer_row->beans_total < $card_type->beans_value * $application->amount) {
                 throw new NotEnoughBeansException();
             }
             $cards = \DB::table('shop_cards')->where('card_type_id', '=', $card_type->id)->whereNull('customer_id')->limit($application->amount);
             $cards->lockForUpdate();
             if ($cards->count() < $application->amount) {
                 throw new CardNotEnoughException();
             }
             $customer->minusBeansByHand($application->amount * $card_type->beans_value);
             $cards->update(['customer_id' => $customer->id, 'bought_at' => Carbon::now()]);
             $application->update(['authorized' => true]);
             return true;
         });
     } catch (CardNotEnoughException $e) {
         return '相应卡片不足,无法继续。';
     } catch (NotEnoughBeansException $e) {
         return '用户迈豆不足!';
     }
     return "操作成功!";
 }
Ejemplo n.º 7
0
 public function handle(CreateBehaviorDO $do)
 {
     \DB::transaction(function () use($do) {
         $entity = new Model();
         $entity->attributeSet()->associate($this->loadAttributeSetById($do->attribute_set_id));
         $entity->representation()->associate($this->loadRepresentationEntity($do->representation_id));
         $entity->name = $do->name;
         $entity->label = $do->label;
         $entity->default_value = $do->default_value;
         $entity->max_values_count = $do->max_values_count;
         $entity->required_create = $do->required_create;
         $entity->required_order = $do->required_order;
         $entity->save();
         if (count($do->options)) {
             foreach ($do->options as $optionDO) {
                 $optionEntity = $this->optionEntity($optionDO);
                 $entity->options()->save($optionEntity);
                 foreach ($optionDO->values as $valueDO) {
                     $valueEntity = $this->valueEntity(AttributeOptionModel::OBJECT_TYPE, $valueDO);
                     $optionEntity->values()->save($valueEntity);
                 }
             }
             $entity->options()->save($optionEntity);
         }
         if (count($do->values)) {
             foreach ($do->values as $valueDO) {
                 $entity->objectValues()->save($this->valueEntity(Model::OBJECT_TYPE, $valueDO));
             }
         }
     });
 }
Ejemplo n.º 8
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $videoItems = array(array("Breakfast Show!", "This is the breakfast show description."), array("BBC News"), array("BBC News 24"), array("Dragons Den"), array("Mock The Week!"), array("Some Other Show"), array("Soundbooth Sessions"), array("The LA1 Show"), array("The One Show"), array("Star Wars"), array("Sugar TV!"), array("The Incredibles"), array("University Challenge"), array("Countdown"), array("8 out of 10 Cats Does Countdown"), array("Jurassic Park"), array("Jurassic Park 2"), array("Shrek"), array("Shrek 2"), array("Shrek 3"), array("Mission Impossible"));
     foreach ($videoItems as $a) {
         $mediaItemVideo = new MediaItemVideo(array("is_live_recording" => rand(0, 1) ? true : false, "time_recorded" => Carbon::now()->subHour(), "description" => rand(0, 4) === 0 ? "A description that should override the general media item one." : null, "enabled" => rand(0, 1) ? true : false));
         $mediaItem = new MediaItem(array("name" => $a[0], "description" => count($a) >= 2 ? $a[1] : null, "enabled" => rand(0, 1) ? true : false, "scheduled_publish_time" => Carbon::now()));
         DB::transaction(function () use(&$mediaItem, &$mediaItemVideo) {
             $mediaItem->save();
             $mediaItem->videoItem()->save($mediaItemVideo);
         });
         $this->addLikes($mediaItem);
         $this->addComments($mediaItem);
     }
     //$mediaItemLiveStream = new MediaItemLiveStream(array(
     //	"enabled"	=>	true
     //));
     $mediaItem = new MediaItem(array("name" => "Lunchtime Show!", "description" => "This is the lunchtime show description.", "enabled" => true, "scheduled_publish_time" => Carbon::now()));
     DB::transaction(function () use(&$mediaItem, &$mediaItemLiveStream) {
         $mediaItem->save();
         //	$mediaItem->liveStreamItem()->save($mediaItemLiveStream);
     });
     $this->addLikes($mediaItem);
     $this->addComments($mediaItem);
     $this->command->info('Media items created!');
 }
Ejemplo n.º 9
0
 public function addyear(Request $request)
 {
     $postData = $request->all();
     $contractId = $postData['PdContract'];
     $year = $postData['year'];
     $qltyFormulas = PdContractQtyFormula::all();
     $formulaValues = \FormulaHelpers::getDataFormulaContract($qltyFormulas, $contractId, $year);
     $resultTransaction = \DB::transaction(function () use($qltyFormulas, $formulaValues, $contractId, $year) {
         $attributes = ['CONTRACT_ID' => $contractId];
         $yAttributes = ['CONTRACT_ID' => $contractId, 'YEAR' => $year];
         $yValues = ['CONTRACT_ID' => $contractId, 'YEAR' => $year];
         // 	     	PdContractYear::where($yAttributes)->delete();
         foreach ($qltyFormulas as $key => $qltyFormula) {
             $attributes['FORMULA_ID'] = $qltyFormula->ID;
             $values = $attributes;
             $calculation = PdContractCalculation::updateOrCreate($attributes, $values);
             /* $sql = "INSERT INTO pd_contract_calculation(FORMULA_ID,CONTRACT_ID) "
             			. "VALUE(".$aryRequest['FORMULA_ID'.$id].",".$aryRequest['CONTRACT_ID'].")"; */
             $formulaValue = (int) $formulaValues[$qltyFormula->ID];
             $yAttributes['CALCULATION_ID'] = $calculation->ID;
             $yValues['CALCULATION_ID'] = $calculation->ID;
             $yValues['FORMULA_VALUE'] = $formulaValue;
             $contractYear = PdContractYear::updateOrCreate($yAttributes, $yValues);
             /* $val = (int) $aryValue[$formulaId[$key]]; // abc($id,$contractId)  se thay bang cong thuc
              		$sql2 = "INSERT INTO pd_contract_year(CALCULATION_ID,YEAR,FORMULA_VALUE,CONTRACT_ID) VALUE($id,$year,'$val',$contractId)";
              		$sql2=str_replace("''", "NULL", $sql2); */
         }
     });
     $results = $this->loadData($contractId, $postData);
     return response()->json($results);
 }
Ejemplo n.º 10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::transaction(function () {
         // create admin user
         $root = factory(App\User::class)->create(['name' => 'Administrator', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'username' => 'admin', 'location' => 'Da Nang', 'country' => 'Viet Nam', 'biography' => 'Dev', 'occupation' => 'Dev', 'website' => 'greenglobal.vn', 'image' => 'avatar.jpg']);
         // create default roles
         $admin = new Role();
         $admin->name = 'admin';
         $admin->display_name = 'Administrator';
         $admin->description = 'User is allowed to manage all system.';
         $admin->active = 1;
         $admin->save();
         // create default guest roles
         $guest = new Role();
         $guest->name = 'guest';
         $guest->display_name = 'Guest';
         $guest->description = 'User are not logged in.';
         $guest->active = 1;
         $guest->save();
         // attach roles
         $root->attachRole($admin);
         // create root permission
         $admin = new NodePermission();
         $admin->name = 'Root';
         $admin->display_name = 'Root permission';
         $admin->description = 'The root.';
         $admin->save();
         // create all permission to admin
         $root = new PermissionRole();
         $root->permission_id = 1;
         $root->role_id = 1;
         $root->status = 1;
         $root->save();
     });
 }
Ejemplo n.º 11
0
 public function postUpdate($id)
 {
     $rules = array('txtNombres' => 'required|min:2|max:100', 'txtApellidos' => 'required|min:2|max:100', 'txtEmail' => 'required|min:2|max:100', 'username' => 'required|min:2|max:100', 'txtPassword' => 'required|min:2|max:100', 'txtRol' => 'required|max:100', 'txtEstado' => 'required|max:100');
     $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :min carácteres.', 'unique' => 'El :attribute ingresado ya existe en la base de datos', "numeric" => "El campo :attribute debe ser un numero");
     $friendly_names = array("txtNombres" => "Nombres", "txtApellidos" => "Apellidos", "txtEmail" => "Email", "username" => "Usuario", "txtPassword" => "Password", "txtRol" => "Rol", "txtEstado" => "Estado");
     $validation = Validator::make(Input::all(), $rules, $messages);
     $validation->setAttributeNames($friendly_names);
     if ($validation->fails()) {
         return Redirect::to('usuarios/modificar/' . $id)->withErrors($validation)->withInput();
     } else {
         try {
             DB::transaction(function () use($id) {
                 $usuario = Usuario::find($id);
                 $usuario->username = strtoupper(Input::get("username"));
                 $usuario->nombres = strtoupper(Input::get("txtNombres"));
                 $usuario->apellidos = strtoupper(Input::get("txtApellidos"));
                 $usuario->email = strtoupper(Input::get("txtEmail"));
                 $usuario->password = strtoupper(Hash::make(Input::get("txtPassword")));
                 $usuario->roles_id = Input::get("txtRol");
                 $usuario->estado = Input::get("txtEstado");
                 $usuario->save();
             });
         } catch (ValidationException $ex) {
             //return "1";
             return Redirect::to("usuarios")->with("modificar", true);
         } catch (Exception $ex) {
             //return "2";
             return Redirect::to("usuarios")->with("modificar", true);
         }
         return Redirect::to("admin")->with("modificar", true);
     }
 }
Ejemplo n.º 12
0
 public function getExercise()
 {
     $json_data = file_get_contents(public_path() . "/js/ejercicio4.json");
     $json = json_decode($json_data);
     DB::transaction(function () use(&$json) {
         $results = DB::select("insert into Exercises (id, description) SELECT COALESCE(MAX(id),0) + 1, 'Interfaz de Constantes' FROM exercises RETURNING id ");
         $exercise_id = $results[0]->id;
         echo $exercise_id;
         $step_number = 0;
         foreach ($json->excercises as $step) {
             $step_number++;
             $results = DB::select("insert into explanations(id, description,exercise_id,step_number,incremental_example,progress) SELECT COALESCE(MAX(id),0) + 1, ?,?,?,?,? FROM explanations RETURNING id ", array($step->explanation, $exercise_id, $step_number, implode("\n", $step->incrementalText), $step->progress));
             $explanation_id = $results[0]->id;
             foreach ($step->answers as $answer) {
                 if (isset($answer->error)) {
                     $error = $answer->error;
                 } else {
                     $error = "";
                 }
                 $description = implode("\n", $answer->text);
                 $correct = $answer->rightAnswer ? 1 : 0;
                 $results = DB::select("insert into answers (id, description,exercise_id,error,correct,step_number) SELECT COALESCE(MAX(id),0) + 1, ?,?,?,?,? FROM answers RETURNING id ", array($description, $exercise_id, $error, $correct, $step_number));
             }
         }
     });
     echo var_dump(DB::getQueryLog());
 }
Ejemplo n.º 13
0
 public function requestRefund()
 {
     $order_id = Input::get('order_id');
     $order = AgencyOrder::find($order_id);
     if (!isset($order)) {
         return Response::json(array('errCode' => 21, 'message' => '该订单不存在'));
     }
     $refund_record = RefundRecord::where('order_id', '=', $order_id)->get();
     if (count($refund_record) != 0) {
         return Response::json(array('errCode' => 22, 'message' => '申请已提交'));
     }
     if ($order->trade_status != 1 || $order->process_status != 1) {
         return Response::json(array('errCode' => 23, 'message' => '该订单不可申请退款'));
     }
     try {
         DB::transaction(function () use($order) {
             $order->trade_status = 2;
             $order->save();
             $refund_record = new RefundRecord();
             $refund_record->order_id = $order->order_id;
             $refund_record->user_id = Sentry::getUser()->user_id;
             $refund_record->save();
         });
     } catch (Exception $e) {
         return Response::json(array('errCode' => 24, 'message' => '退款申请失败,请重新申请'));
     }
     return Response::json(array('errCode' => 0, 'message' => '申请成功'));
 }
Ejemplo n.º 14
0
 public function dUserNotice()
 {
     if (!Sentry::check()) {
         return Response::json(array('errCode' => 10, 'message' => '请登录'));
     }
     $user = Sentry::getUser();
     $join_coms = ArticleJoinCom::where('receiver_id', '=', $user->id)->where('is_delete', '=', 0)->get();
     $replys = ArticleJoinReply::where('receiver_id', '=', $user->id)->where('is_delete', '=', 0)->get();
     try {
         DB::transaction(function () use($replys, $join_coms) {
             if (count($join_coms) != 0) {
                 foreach ($join_coms as $com) {
                     $com->is_delete = 1;
                     $com->save();
                 }
             }
             if (count($replys) != 0) {
                 foreach ($replys as $reply) {
                     $reply->is_delete = 1;
                     $reply->save();
                 }
             }
         });
     } catch (\Exception $e) {
         return Response::json(array('errCode' => 11, 'message' => '操作失败'));
     }
     return Response::json(array('errCode' => 0, 'message' => '删除成功'));
 }
Ejemplo n.º 15
0
 public function genBLMR(Request $request)
 {
     $postData = $request->all();
     $pid = $postData['id'];
     $shipCargoBlmr = $this->getShipCargoBlmr($pid);
     $xid = $shipCargoBlmr ? $shipCargoBlmr->ID : 0;
     $results = \DB::transaction(function () use($xid, $pid) {
         $mdl = $this->modelName;
         $transportType = $mdl::getTableName();
         $shipCargoBlmr = ShipCargoBlmr::getTableName();
         if ($xid > 0) {
             // 			    			\DB::enableQueryLog();
             $values = $this->getUpdateFields($shipCargoBlmr, $transportType);
             ShipCargoBlmr::join($transportType, "{$transportType}.ID", '=', "{$shipCargoBlmr}.PARENT_ID")->where("{$shipCargoBlmr}.ID", $xid)->update($values);
             // 			   \Log::info(\DB::getQueryLog());
             return 'Success(only update exist rows)';
         } else {
             $pdVoyage = PdVoyage::getTableName();
             $storage = Storage::getTableName();
             $values = $this->getInsertFields($pid, $pdVoyage, $storage, $transportType);
             $mdl::join($pdVoyage, "{$pdVoyage}.ID", '=', "{$transportType}.VOYAGE_ID")->join($storage, "{$storage}.ID", '=', "{$pdVoyage}.STORAGE_ID")->where("{$transportType}.ID", $pid)->select($values)->chunk(10, function ($rows) {
                 ShipCargoBlmr::insert($rows->toArray());
             });
             return 'Success!';
         }
     });
     return response()->json($results);
 }
Ejemplo n.º 16
0
 /**
  * Delete a category.
  *
  * @param Category $category
  * @return mixed
  */
 public function deleteCategory(Category $category)
 {
     $result = \DB::transaction(function () use($category) {
         return $category->delete();
     });
     return $result;
 }
Ejemplo n.º 17
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if ($this->argument('studentsdcid')) {
         $spedStudents = $this->getStudent($this->argument('studentsdcid'));
     } else {
         if ($this->option('all')) {
             $spedStudents = $this->getSpedStudents();
         }
     }
     if ($total = count($spedStudents)) {
         foreach ($spedStudents as $index => $spedStudent) {
             \DB::transaction(function () use($spedStudent) {
                 $forms = $this->getSpedForms($spedStudent->id);
                 $iep = $this->createIep($spedStudent->dcid, $spedStudent->created_by);
                 foreach ($forms as $form) {
                     if ($form->form_title == 'IEP: SpEd 51') {
                         $iep->updateCaseManager($form);
                     }
                     if ($form->form_title == 'IEP: SpEd 6a1') {
                         $iep->updateStartDate($form);
                     }
                     $this->createIepResponse($iep->id, $form->id);
                 }
             });
             $this->logPercent($total, $index);
         }
         $this->logPercent($total, $index, true);
     }
 }
Ejemplo n.º 18
0
 public function down(Comment $comment)
 {
     \DB::transaction(function () use($comment) {
         $this->user()->voteDown($comment);
     });
     return 1;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $books = (array) json_decode(Input::all()['add_book_data']);
     DB::transaction(function () use($books) {
         $db_flag = false;
         $user_id = Auth::id();
         $book_title = Books::insertGetId(array('title' => $books['title'], 'author' => $books['author'], 'description' => $books['description'], 'category_id' => $books['category'], 'added_by' => $user_id));
         $newId = $book_title;
         if (!$book_title) {
             $db_flag = true;
         } else {
             $number_of_issues = $books['number'];
             for ($i = 0; $i < $number_of_issues; $i++) {
                 $issues = Issue::create(array('book_id' => $newId, 'added_by' => $user_id));
                 if (!$issues) {
                     $db_flag = true;
                 }
             }
         }
         if ($db_flag) {
             throw new Exception('Invalid update data provided');
         }
     });
     return "Books Added successfully to Database";
 }
Ejemplo n.º 20
0
 public function postVerify()
 {
     $this->beforeFilter('admin');
     $request = Input::get('request');
     $status = Input::get('status');
     if (!Group::isValidStatus($status)) {
         throw new \Exception("Invalid value for verify request");
     }
     $group = Group::where('id', '=', $request['id'])->first();
     if (!$group) {
         throw new \Exception("Invalid Group");
     }
     $group->status = $status;
     DB::transaction(function () use($group) {
         $group->save();
         switch ($group->status) {
             case Group::STATUS_ACTIVE:
                 $group->createRbacRules();
                 break;
             case Group::STATUS_PENDING:
                 $group->destroyRbacRules();
                 break;
         }
     });
     return Response::json($group);
 }
Ejemplo n.º 21
0
 public function cal(Request $request)
 {
     $postData = $request->all();
     $id = $postData['id'];
     $isAll = isset($postData['isAll']) ? $postData['isAll'] : false;
     //     		$sql="select ID, FORMULA_ID from SHIP_CARGO_BLMR_DATA where BLMR_ID=$vid";
     $where = $isAll ? ["BLMR_ID" => $id] : ["ID" => $id];
     $blmrData = ShipCargoBlmrData::where($where)->select(["ID", "FORMULA_ID"])->get();
     try {
         $ids = \DB::transaction(function () use($blmrData) {
             $ids = [];
             foreach ($blmrData as $shipCargoBlmrData) {
                 $val = \FormulaHelpers::doEvalFormula($shipCargoBlmrData->FORMULA_ID);
                 $shipCargoBlmrData->LAST_CALC_TIME = Carbon::now();
                 $shipCargoBlmrData->ITEM_VALUE = $val;
                 $shipCargoBlmrData->save();
                 $ids[] = $shipCargoBlmrData->ID;
             }
             return $ids;
             /* $row=getOneRow("select ID, FORMULA_ID from SHIP_CARGO_BLMR_DATA where ID=$vid");
              		$val=evalFormula($row[FORMULA_ID],false,$vid);
              		$sql="update SHIP_CARGO_BLMR_DATA set LAST_CALC_TIME=now(),ITEM_VALUE='$val' where ID=$vid"; */
         });
     } catch (\Exception $e) {
         //     		$results = "error";
         $msg = $e->getMessage();
         return response()->json($msg, 500);
     }
     $updatedData = ["ShipCargoBlmrData" => ShipCargoBlmrData::findManyWithConfig($ids)];
     $results = ['updatedData' => $updatedData, 'postData' => $postData];
     return response()->json($results);
 }
Ejemplo n.º 22
0
 public function handle(UpdateBehaviorDO $do)
 {
     $entity = $this->model->find($do->id->value());
     if (!$entity) {
         throw new EntityNotFoundException('Entity Not Found');
     }
     \DB::transaction(function () use($entity, $do) {
         $entity->representation()->associate($this->loadRepresentationEntity($do->representation_id));
         $entity->name = $do->name;
         $entity->label = $do->label;
         $entity->default_value = $do->default_value;
         $entity->max_values_count = $do->max_values_count;
         $entity->required_create = $do->required_create;
         $entity->required_order = $do->required_order;
         $entity->save();
         $entity->options()->delete();
         if (count($do->options)) {
             foreach ($do->options as $optionDO) {
                 $optionEntity = $this->optionEntity($optionDO);
                 $entity->options()->save($optionEntity);
                 foreach ($optionDO->values as $valueDO) {
                     $valueEntity = $this->valueEntity(AttributeOptionModel::OBJECT_TYPE, $valueDO);
                     $optionEntity->values()->save($valueEntity);
                 }
             }
             $entity->options()->save($optionEntity);
         }
         $entity->values()->delete();
         if (count($do->values)) {
             foreach ($do->values as $valueDO) {
                 $entity->values()->save($this->valueEntity(Model::OBJECT_TYPE, $valueDO));
             }
         }
     });
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::create('lds_sealing_status', function (Blueprint $table) {
         $table->increments('id');
         $table->unsignedInteger('lds_sealing_id');
         $table->unsignedInteger('lds_status_id');
         $table->boolean('standard')->default(false);
         // Indexes
         $table->unique(['lds_sealing_id', 'lds_status_id']);
         $table->unique(['lds_status_id', 'lds_sealing_id']);
         // Foreign keys
         $table->foreign('lds_sealing_id')->references('id')->on('lds_sealing');
         $table->foreign('lds_status_id')->references('id')->on('lds_status');
     });
     DB::transaction(function () {
         LdsSealingStatus::unguard();
         foreach ($this->data as $datum) {
             $lds_sealing = LdsSealing::where(['value' => $datum['sealing']])->firstOrFail();
             $lds_status = LdsStatus::where(['value' => $datum['status']])->firstOrFail();
             $lds_sealing_status = new LdsSealingStatus(['standard' => true]);
             $lds_sealing_status->ldsSealing()->associate($lds_sealing);
             $lds_sealing_status->ldsStatus()->associate($lds_status);
             $lds_sealing_status->save();
         }
         LdsSealingStatus::reguard();
     });
 }
 public static function initiate($user_id, array $other_details)
 {
     return DB::transaction(function () use($user_id, $other_details) {
         $details = [];
         switch ($other_details['type']) {
             case 'recharge':
                 $details = ['type' => 'recharge', 'plan_id' => $other_details['plan_id'], 'plan_name' => $other_details['plan_name']];
                 break;
             case 'refill':
                 $details = ['type' => 'refill', 'value' => $other_details['value'], 'unit' => $other_details['unit']];
         }
         $dp_transaction = new self(['status' => 'Initiated', 'other_details' => http_build_query($details)]);
         if (!$dp_transaction->save()) {
             throw new Exception('Could not initiate transaction. Failed: Phase 1');
         }
         do {
             $uid = uniqid();
             $exists = OnlinePayment::where('order_id', $uid)->count();
         } while ($exists);
         $payment = ['user_id' => $user_id, 'gw_type' => 'DirecpayTransaction', 'gw_id' => $dp_transaction->id, 'order_id' => $uid, 'amount' => $other_details['amount']];
         $transaction = new OnlinePayment($payment);
         if (!$transaction->save()) {
             throw new Exception('Could not initiate transaction. Failed: Phase 2');
         }
         return $transaction->order_id;
     });
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::create('gedcom_form_structure', function (Blueprint $table) {
         $table->increments('id');
         $table->unsignedInteger('gedcom_form_id')->index();
         $table->unsignedInteger('version_number_id')->index();
         // Composite keys
         $table->unique(['gedcom_form_id', 'version_number_id']);
         // Foreign keys
         $table->foreign('gedcom_form_id')->references('id')->on('gedcom_form');
         $table->foreign('version_number_id')->references('id')->on('version_number');
     });
     DB::transaction(function () {
         GedcomFormStructure::unguard();
         foreach ($this->data as $datum) {
             $gedcom_form = GedcomForm::where(['value' => $datum['gedcom_form']])->firstOrFail();
             $version_number = VersionNumber::where(['value' => $datum['version_number']])->firstOrFail();
             $gedcom_form_structure = new GedcomFormStructure();
             $gedcom_form_structure->gedcomForm()->associate($gedcom_form);
             $gedcom_form_structure->versionNumber()->associate($version_number);
             $gedcom_form_structure->save();
         }
         GedcomFormStructure::reguard();
     });
 }
 public function savePedido()
 {
     $cart = Session::get('kart');
     if (empty($cart)) {
         return Redirect::to('/');
     }
     DB::transaction(function () {
         $productos = null;
         $invitado = Input::get('invitado');
         $fecha = date("Y-m-d H:i:s");
         $datosCliente = Session::get('datosCliente');
         $cliente_id = Session::has('datosCliente') ? $datosCliente[0]['id'] : null;
         $email = Input::get('email');
         #si no es invitado
         if (!$invitado) {
             # comprobamos que no este logeado para guardar el cliente
             if (!Session::has('datosCliente')) {
                 $arrCliente = array('nombres' => Input::get('nombre'), 'apellidos' => Input::get('apellidos'), 'email' => $email, 'telefono' => Input::get('telefono'), 'password' => Input::get('password_registro'), 'empresa' => Input::get('empresa'), 'rfc' => Input::get('rfc'), 'calleNum' => Input::get('calle'), 'colonia' => Input::get('colonia'), 'ciudad' => Input::get('ciudad'), 'estado' => Input::get('estado'), 'pais' => Input::get('pais'), 'codigopostal' => Input::get('codigoPostal'));
                 #guardar el cliente
                 $cliente_id = DB::table('clientes')->insertGetId($arrCliente);
             }
         }
         #guardar pedido,
         $pedido_id = DB::table('pedidos')->insertGetId(array('fecha_pedido' => $fecha, 'fecha_atendido' => '0000-00-00 0000:00', 'fecha_atendido' => '0000-00-00 0000:00', 'estado' => 0, 'cliente_id' => $cliente_id));
         # guardar pedidosproductos , pedidoInformacion
         $productos = Session::get('kart');
         foreach ($productos as $producto) {
             DB::table('pedidosproductos')->insert(array('pedido_id' => $pedido_id, 'producto_id' => $producto['id'], 'num_productos' => $producto['cantidad'], 'precio' => $producto['precio']));
         }
         #insertar la informacion del pedido
         $arrPedidoInfo = array('pedido_id' => $pedido_id, 'formaEnvio' => Input::get('formaEnvio'), 'formaPago' => Input::get('formaPago'), 'comentarioPedido' => Input::get('comentarioPedido'), 'comentarioEnvio' => Input::get('comentarioEnvio'), 'nombresCliente' => Input::get('nombre'), 'apellidos' => Input::get('apellidos'), 'email' => $email, 'telefono' => Input::get('telefono'), 'empresa' => Input::get('empresa'), 'rfc' => Input::get('rfc'), 'calleNum' => Input::get('calleEnvio'), 'colonia' => Input::get('coloniaEnvio'), 'ciudad' => Input::get('ciudadEnvio'), 'estado' => Input::get('estadoEnvio'), 'pais' => Input::get('paisEnvio'), 'codigopostal' => Input::get('codigoPostalEnvio'));
         DB::table('pedidoinformacion')->insert($arrPedidoInfo);
         $productos = Session::get('kart');
         #array que gradara los productos que no estan disponibles en el stock inmediatamente
         $this->arrProductosNoStock = array();
         $productosStock = array();
         foreach ($productos as $producto) {
             $stockProducto = DB::table('productos')->where('id', $producto['id'])->first();
             $productosStoc[] = array('id' => $stockProducto->id, 'cantidad', $stockProducto->cantidad);
             if ($stockProducto->cantidad < $producto['cantidad']) {
                 $this->arrProductosNoStock[] = array('producto' => $stockProducto->producto, 'stockDisponible' => $stockProducto->cantidad, 'cantidadPedida' => $producto['cantidad']);
             }
             #se obtiene el nuevo stock de los productos en existencia#
             $newStock = $stockProducto->cantidad - $producto['cantidad'];
             #se valida que el stock no sea negativo, si lo es se iguala a cero#
             $newStock = $newStock < 0 ? 0 : $newStock;
             DB::table('productos')->where('id', $stockProducto->id)->update(array('cantidad' => $newStock));
         }
         $data = array('productos' => array_values($productos), 'noStock' => $this->arrProductosNoStock);
         Mail::send('emails.emailPedido', $data, function ($message) {
             $message->subject('Informacion de su compra');
             $message->to(Input::get('email'));
         });
     });
     $cart = null;
     #Session::get('kart');
     Session::put('kart', null);
     return View::make('pedidoDetalles', compact('cart'))->with('arrProductosNoStock', $this->arrProductosNoStock);
 }
Ejemplo n.º 27
0
 /**
  * Saves order of skills
  *
  * @param Request $request
  */
 public function order(Request $request)
 {
     \DB::transaction(function () use($request) {
         foreach ($request->get('order') as $id => $order) {
             \DB::table('user_skills')->where('id', $id)->where('user_id', auth()->user()->id)->update(['order' => intval($order) + 1]);
         }
     });
 }
Ejemplo n.º 28
0
 public function updateEstatusFinalizado($IdOficio)
 {
     DB::transaction(function () use($inputs, $IdOficio) {
         $oficioU = Correspondencia::find($IdOficio);
         $oficioU->Estatus_Id = 406;
         $oficioU->save();
     });
 }
Ejemplo n.º 29
0
 public function deleteFriend($userID, $friendUserID)
 {
     DB::transaction(function () use($userID, $friendUserID) {
         $friendModel = Friend::where('user_id', '=', $userID)->where('friend_user_id', '=', $friendUserID)->delete();
         $inverseFriendModel = Friend::where('user_id', '=', $friendUserID)->where('friend_user_id', '=', $userID)->delete();
     });
     return true;
 }
Ejemplo n.º 30
0
 public function execute()
 {
     \DB::transaction(function () {
         $outlet = $this->factory->create($this->data);
         $owner = User::whereTitle('owner')->whereCompanyId($this->auth->getCompanyId())->first();
         $owner->outlets()->attach($outlet->id);
     });
 }