当前位置: 首页>>代码示例>>PHP>>正文


PHP Uuid类代码示例

本文整理汇总了PHP中Uuid的典型用法代码示例。如果您正苦于以下问题:PHP Uuid类的具体用法?PHP Uuid怎么用?PHP Uuid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Uuid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onBeforeWrite

 public function onBeforeWrite()
 {
     if (!$this->owner->SystemID) {
         $uuid = new Uuid();
         $this->owner->SystemID = $uuid->get();
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-syncrotron,代码行数:7,代码来源:SyncroSiteConfig.php

示例2: __construct

 protected function __construct($id = null)
 {
     if ($id !== null && !is_scalar($id)) {
         throw new InvalidIdException();
     }
     $this->id = null === $id ? Uuid::generate() : $id;
 }
开发者ID:kreta,项目名称:kreta,代码行数:7,代码来源:Id.php

示例3: testFromString

 public function testFromString()
 {
     $uuid1 = Uuid::fromString($this->uuid1);
     $uuid4 = Uuid::fromString($this->uuid4);
     $this->assertSame($uuid1->toString(), $this->uuid1);
     $this->assertSame($uuid4->toString(), $this->uuid4);
 }
开发者ID:lorenzomar,项目名称:valueobject,代码行数:7,代码来源:UuidTest.php

示例4: store

 /**
  * Store a newly created resource in storage.
  * POST /group
  *
  * @return Response
  */
 public function store($id)
 {
     //create sub team
     //return Redirect::action('SubController@create',$id)->with( 'notice', 'This action cannot be perform at this moment, please comeback soon.');
     $user = Auth::user();
     $club = $user->clubs()->FirstOrFail();
     $parent_team = Team::find($id);
     $uuid = Uuid::generate();
     $validator = Validator::make(Input::all(), Team::$rules_group);
     if ($validator->passes()) {
         $team = new Team();
         $team->id = $uuid;
         $team->name = Input::get('name');
         $team->season_id = $parent_team->season_id;
         $team->program_id = $parent_team->program_id;
         $team->description = $parent_team->description;
         $team->early_due = $parent_team->getOriginal('early_due');
         $team->early_due_deadline = $parent_team->early_due_deadline;
         $team->due = $parent_team->getOriginal('due');
         $team->plan_id = $parent_team->plan_id;
         $team->open = $parent_team->open;
         $team->close = $parent_team->close;
         $team->max = Input::get('max');
         $team->status = $parent_team->getOriginal('status');
         $team->parent_id = $parent_team->id;
         $team->club_id = $club->id;
         $team->allow_plan = 1;
         $status = $team->save();
         if ($status) {
             return Redirect::action('TeamController@show', $parent_team->id)->with('messages', 'Group created successfully');
         }
     }
     $error = $validator->errors()->all(':message');
     return Redirect::action('SubController@create', $id)->withErrors($validator)->withInput();
 }
开发者ID:illuminate3,项目名称:league-production,代码行数:41,代码来源:SubController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     session_start();
     if (!isset($_SESSION['AUTH']) || $_SESSION['AUTH'] == false) {
         \App::abort(500, 'User not authenticated');
     }
     $post = file_get_contents('php://input');
     $data = json_decode($post, true);
     if ($data['ipAddr'] != null && $data['type'] != null) {
         //creates a new VM in middleware database. Expects ipaddress and type
         $v = new vm();
         $v->id = \Uuid::generate(4);
         $v->ipAddr = $data['ipAddr'];
         $v->type = $data['type'];
         try {
             //emit request to make vm
             $redis = \Redis::connection();
             // Using the Redis extension provided client
             $redis->publish('demeter', json_encode(array('command' => 'init', 'vm' => $v->id->string, 'type' => $v->type, 'netId' => $_SESSION['AUTH_USER'])));
             if ($v->save()) {
                 echo "success";
             } else {
                 \App::abort(500, 'VM could not be created, please contact an Administrator');
             }
         } catch (Exception $e) {
             \App::abort(500, 'VM could not be created, please contact an Administrator');
         }
     } else {
         \App::abort(500, 'VM could not be created, please contact an Administrator');
     }
 }
开发者ID:DCUnit711,项目名称:Demeter,代码行数:37,代码来源:vmController.php

示例6: run

 public function run()
 {
     $participants = DB::table('event_participant')->get();
     foreach ($participants as $participant) {
         $player = Player::find($participant->player_id);
         $user = User::find($participant->user_id);
         $event = Evento::find($participant->event_id);
         $payment = Payment::find($participant->payment_id);
         $uuid = Uuid::generate();
         $new = new Participant();
         $new->id = $uuid;
         $new->firstname = $player->firstname;
         $new->lastname = $player->lastname;
         $new->due = $event->getOriginal('fee');
         $new->early_due = $event->getOriginal('early_fee');
         $new->early_due_deadline = $event->early_deadline;
         $new->method = 'full';
         $new->plan_id = Null;
         $new->player_id = $player->id;
         $new->event_id = $participant->event_id;
         $new->accepted_on = $participant->created_at;
         $new->accepted_by = $user->profile->firstname . " " . $user->profile->lastname;
         $new->accepted_user = $participant->user_id;
         $new->status = 1;
         $new->created_at = $participant->created_at;
         $new->updated_at = $participant->updated_at;
         $new->save();
         $update = Item::where('payment_id', '=', $payment->id)->firstOrFail();
         $update->participant_id = $uuid;
         $update->save();
     }
 }
开发者ID:illuminate3,项目名称:league-production,代码行数:32,代码来源:FollowersTableSeeder.php

示例7: postStore

 public function postStore(UsersRequest $request = null, $id = "")
 {
     $input = $request->except('save_continue', 'password_confirmation');
     $result = '';
     if (\Input::hasFile('photo')) {
         $photo = (new \ImageUpload($input))->upload();
     }
     if ($id == "") {
         $input['id'] = \Uuid::generate();
         $input['photo'] = isset($photo) ? $photo : "";
         $input['password'] = bcrypt($input['password']);
         $query = $this->model->create($input);
         $result = $query->id;
     } else {
         if (\Input::hasFile('photo')) {
             $input['photo'] = isset($photo) ? $photo : "";
         }
         if (isset($input['password']) && $input['password'] != "") {
             $input['password'] = bcrypt($input['password']);
         }
         $this->model->find($id)->update($input);
         $result = $id;
     }
     $save_continue = \Input::get('save_continue');
     $redirect = empty($save_continue) ? $this->url : $this->url . '/edit/' . $result;
     return redirect($redirect)->with('message', 'Berhasil tambah data Pengguna!');
 }
开发者ID:Abdulhmid,项目名称:inventory,代码行数:27,代码来源:Users.php

示例8: postStoreTransaction

 public function postStoreTransaction(Request $request)
 {
     $input = $request->only('idItemPart', 'qty', 'priceBuy');
     try {
         $arrayData = [];
         $itemId = explode(",", $input['idItemPart']);
         $qty = explode(",", $input['qty']);
         $priceBuy = explode(",", $input['priceBuy']);
         $keyTrans = \Uuid::generate();
         for ($i = 0; $i < count($itemId); $i++) {
             /* Update Stok */
             $this->updateStok($itemId[$i], $qty[$i]);
             /* Update Price */
             $this->updatePrice($itemId[$i], $priceBuy[$i]);
             /* Update Price */
             $this->updatePriceSell($itemId[$i], $priceBuy[$i]);
             $insert['item_id'] = $itemId[$i];
             $insert['qty'] = $qty[$i];
             $insert['price_buy'] = $priceBuy[$i];
             $insert['expedition'] = "-";
             $insert['created_at'] = \Carbon\Carbon::now();
             $insert['updated_at'] = \Carbon\Carbon::now();
             $insert['key_transaction'] = $keyTrans;
             array_push($arrayData, $insert);
         }
         $data = $this->transactionBuy->insert($arrayData);
         return $keyTrans;
     } catch (Exception $e) {
         return "0";
     }
 }
开发者ID:Abdulhmid,项目名称:inventory,代码行数:31,代码来源:Buying.php

示例9: store

 /**
  * Store a newly created resource in storage.
  * POST /plan
  *
  * @return Response
  */
 public function store()
 {
     $user = Auth::user();
     $club = $user->clubs()->FirstOrFail();
     $validator = Validator::make(Input::all(), Plan::$rules);
     $uuid = Uuid::generate();
     //check if recurrences
     if ($validator->passes()) {
         $amount = Input::get('total') - Input::get('initial');
         $recurring = Input::get('recurring');
         $recurrences = $amount / $recurring;
         $recidual = fmod($amount, $recurring);
         if ($recidual > 0) {
             return Redirect::action('PlanController@create')->withInput()->with('warning', "Please check the recurring amount and initial amount.");
         }
         $plan = new Plan();
         $plan->id = $uuid;
         $plan->name = Input::get('name');
         $plan->total = Input::get('total');
         $plan->initial = Input::get('initial');
         $plan->recurring = Input::get('recurring');
         $plan->recurrences = $recurrences;
         $plan->frequency_id = Input::get('frequency_id');
         $plan->on = Input::get('on');
         $plan->club_id = $club->id;
         $status = $plan->save();
         if ($status) {
             return Redirect::action('PlanController@index')->with('notice', 'Event created successfully');
         }
         return Redirect::action('PlanController@create')->with('warning', $status);
     }
     $error = $validator->errors()->all(':message');
     return Redirect::action('PlanController@create')->withErrors($validator)->withInput();
 }
开发者ID:illuminate3,项目名称:league-production,代码行数:40,代码来源:PlanController.php

示例10: file

 /**
  * Copy a random file from the source directory to the target directory and returns the filename/fullpath
  *
  * @param string $sourceDirectory
  *        	The directory to look for random file taking
  * @param string $targetDirectory        	
  * @param boolean $fullPath
  *        	Whether to have the full path or just the filename
  * @return string
  */
 public static function file($sourceDirectory = '/tmp', $targetDirectory = '/tmp', $fullPath = true)
 {
     if (!is_dir($sourceDirectory)) {
         throw new \InvalidArgumentException(sprintf('Source directory %s does not exist or is not a directory.', $sourceDirectory));
     }
     if (!is_dir($targetDirectory)) {
         throw new \InvalidArgumentException(sprintf('Target directory %s does not exist or is not a directory.', $targetDirectory));
     }
     if ($sourceDirectory == $targetDirectory) {
         throw new \InvalidArgumentException('Source and target directories must differ.');
     }
     // Drop . and .. and reset array keys
     $files = array_filter(array_values(array_diff(scandir($sourceDirectory), array('.', '..'))), function ($file) use($sourceDirectory) {
         return is_file($sourceDirectory . DIRECTORY_SEPARATOR . $file) && is_readable($sourceDirectory . DIRECTORY_SEPARATOR . $file);
     });
     if (empty($files)) {
         throw new \InvalidArgumentException(sprintf('Source directory %s is empty.', $sourceDirectory));
     }
     $sourceFullPath = $sourceDirectory . DIRECTORY_SEPARATOR . static::randomElement($files);
     $destinationFile = Uuid::uuid() . '.' . pathinfo($sourceFullPath, PATHINFO_EXTENSION);
     $destinationFullPath = $targetDirectory . DIRECTORY_SEPARATOR . $destinationFile;
     if (false === copy($sourceFullPath, $destinationFullPath)) {
         return false;
     }
     return $fullPath ? $destinationFullPath : $destinationFile;
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:36,代码来源:File.php

示例11: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('groups')->insert(['group_id' => '1', 'group_name' => 'Admin']);
     // \DB::statement("SELECT pg_catalog.setval(pg_get_serial_sequence('groups', 'group_id'), "
     //      . "MAX(group_id)) FROM groups");
     DB::table('users')->insert(['id' => Uuid::generate(), 'group_id' => '1', 'username' => 'admin', 'email' => 'admin@spam4.me', 'password' => bcrypt('123456'), 'name' => 'Admin Sistem Inventory', 'active' => '1', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
 }
开发者ID:Abdulhmid,项目名称:inventory,代码行数:12,代码来源:UsersTableSeeder.php

示例12: testNameBased

 public function testNameBased()
 {
     // test UUID parts
     $uuid = explode('-', Uuid::nameBased('bar'));
     $this->assertEquals(5, count($uuid));
     $this->assertEquals(true, ctype_xdigit($uuid[0]), 'time-low');
     $this->assertEquals(true, ctype_xdigit($uuid[1]), 'time-mid');
     $this->assertEquals(true, ctype_xdigit($uuid[2]), 'time-high-and-version');
     $this->assertEquals(true, ctype_xdigit($uuid[3]), 'clock-seq-and-reserved / clock-seq-low');
     $this->assertEquals(true, ctype_xdigit($uuid[4]), 'node');
     $this->assertEquals(8, strlen($uuid[0]), 'time-low');
     $this->assertEquals(4, strlen($uuid[1]), 'time-mid');
     $this->assertEquals(4, strlen($uuid[2]), 'time-high-and-version');
     $this->assertEquals(4, strlen($uuid[3]), 'clock-seq-and-reserved / clock-seq-low');
     $this->assertEquals(12, strlen($uuid[4]), 'node');
     $this->assertEquals(5, hexdec($uuid[2]) >> 12, 'Set the four most significant bits (bits 12 through 15) of the time_hi_and_version field to the appropriate 4-bit version number from Section 4.1.3.');
     $this->assertEquals(2, hexdec($uuid[3]) >> 14, 'Set the two most significant bits (bits 6 and 7) of the clock_seq_hi_and_reserved to zero and one, respectively.');
     // the UUIDs generated at different times from the same name in the same
     // namespace MUST be equal.
     $uuid = Uuid::nameBased('foobar');
     sleep(1);
     $this->assertEquals($uuid, Uuid::nameBased('foobar'));
     // the UUIDs generated from two different names in the same namespace
     // should be different (with very high probability).
     $this->assertTrue(Uuid::nameBased('foobar') != Uuid::nameBased('bar'));
 }
开发者ID:seytar,项目名称:psx,代码行数:26,代码来源:UuidTest.php

示例13: boot

 /**
  * Bootstrap the UUID service.
  *
  * @return void
  */
 public function boot()
 {
     $this->loadTranslationsFrom(__DIR__ . '../Lang', '');
     Validator::extend('uuid', function ($attribute, $value, $parameters) {
         return \Uuid::isValid($value);
     });
 }
开发者ID:sammarks,项目名称:laravel-uuid,代码行数:12,代码来源:UuidServiceProvider.php

示例14: valid

 public static function valid($uuid)
 {
     if (!self::$uuid) {
         self::$uuid = Uuid::getInstance();
     }
     return self::$uuid->test($uuid);
 }
开发者ID:noccy80,项目名称:cherryphp,代码行数:7,代码来源:uuidgenerator.php

示例15: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     # Clear the table.
     Segment::truncate();
     # Seed the table.
     $segments = [['Seg_Name' => 'Age', 'Seg_CreatedOn' => Carbon\Carbon::now(), 'Seg_CreatedBy' => 1, 'Seg_GUID' => (string) Uuid::generate(4)], ['Seg_Name' => 'Location', 'Seg_CreatedOn' => Carbon\Carbon::now(), 'Seg_CreatedBy' => 1, 'Seg_GUID' => (string) Uuid::generate(4)]];
     Segment::insert($segments);
 }
开发者ID:bambangadrian,项目名称:mailmarketing,代码行数:13,代码来源:SegmentSeeder.php


注:本文中的Uuid类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。