public function onBeforeWrite() { if (!$this->owner->SystemID) { $uuid = new Uuid(); $this->owner->SystemID = $uuid->get(); } }
protected function __construct($id = null) { if ($id !== null && !is_scalar($id)) { throw new InvalidIdException(); } $this->id = null === $id ? Uuid::generate() : $id; }
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); }
/** * 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(); }
/** * 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'); } }
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(); } }
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!'); }
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"; } }
/** * 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(); }
/** * 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; }
/** * 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' => '*****@*****.**', 'password' => bcrypt('123456'), 'name' => 'Admin Sistem Inventory', 'active' => '1', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]); }
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')); }
/** * Bootstrap the UUID service. * * @return void */ public function boot() { $this->loadTranslationsFrom(__DIR__ . '../Lang', ''); Validator::extend('uuid', function ($attribute, $value, $parameters) { return \Uuid::isValid($value); }); }
public static function valid($uuid) { if (!self::$uuid) { self::$uuid = Uuid::getInstance(); } return self::$uuid->test($uuid); }
/** * 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); }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. CampaignType::truncate(); # Seed the table. $campaignTypes = [['Cgt_Name' => 'Plain Text', 'Cgt_CreatedOn' => Carbon\Carbon::now(), 'Cgt_CreatedBy' => 1, 'Cgt_GUID' => (string) Uuid::generate(4)], ['Cgt_Name' => 'HTML', 'Cgt_CreatedOn' => Carbon\Carbon::now(), 'Cgt_CreatedBy' => 1, 'Cgt_GUID' => (string) Uuid::generate(4)]]; CampaignType::insert($campaignTypes); }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. MailTrackingStatus::truncate(); # Seed the table. $mailTrackingStatuses = [['Mts_Name' => 'open', 'Mts_CreatedOn' => Carbon\Carbon::now(), 'Mts_CreatedBy' => 1, 'Mts_GUID' => (string) Uuid::generate(4)], ['Mts_Name' => 'read', 'Mts_CreatedOn' => Carbon\Carbon::now(), 'Mts_CreatedBy' => 1, 'Mts_GUID' => (string) Uuid::generate(4)], ['Mts_Name' => 'click', 'Mts_CreatedOn' => Carbon\Carbon::now(), 'Mts_CreatedBy' => 1, 'Mts_GUID' => (string) Uuid::generate(4)], ['Mts_Name' => 'subscribe', 'Mts_CreatedOn' => Carbon\Carbon::now(), 'Mts_CreatedBy' => 1, 'Mts_GUID' => (string) Uuid::generate(4)], ['Mts_Name' => 'unsubscribe', 'Mts_CreatedOn' => Carbon\Carbon::now(), 'Mts_CreatedBy' => 1, 'Mts_GUID' => (string) Uuid::generate(4)], ['Mts_Name' => 'bounce', 'Mts_CreatedOn' => Carbon\Carbon::now(), 'Mts_CreatedBy' => 1, 'Mts_GUID' => (string) Uuid::generate(4)], ['Mts_Name' => 'fail', 'Mts_CreatedOn' => Carbon\Carbon::now(), 'Mts_CreatedBy' => 1, 'Mts_GUID' => (string) Uuid::generate(4)]]; MailTrackingStatus::insert($mailTrackingStatuses); }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. Subscriber::truncate(); # Seed the table. $subscribers = [['Sbr_ImportFromID' => 4, 'Sbr_EmailAddress' => '*****@*****.**', 'Sbr_FirstName' => 'Maita', 'Sbr_LastName' => 'Elfrida', 'Sbr_Address1' => 'Perumahan Bagasasi Blok F3 No.1', 'Sbr_Address2' => 'Cibarusah', 'Sbr_Address3' => 'Cikarang Selatan', 'Sbr_CreatedOn' => Carbon\Carbon::now(), 'Sbr_CreatedBy' => 1, 'Sbr_GUID' => (string) Uuid::generate(4)]]; Subscriber::insert($subscribers); }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. ImportFrom::truncate(); # Seed the table. $importFrom = [['Imf_Name' => 'Old Database', 'Imf_Description' => 'Import from old database', 'Imf_CreatedOn' => Carbon\Carbon::now(), 'Imf_CreatedBy' => 1, 'Imf_GUID' => (string) Uuid::generate(4)], ['Imf_Name' => 'Excel', 'Imf_Description' => 'Import from excel', 'Imf_CreatedOn' => Carbon\Carbon::now(), 'Imf_CreatedBy' => 1, 'Imf_GUID' => (string) Uuid::generate(4)], ['Imf_Name' => 'Register', 'Imf_Description' => 'Registered subscriber', 'Imf_CreatedOn' => Carbon\Carbon::now(), 'Imf_CreatedBy' => 1, 'Imf_GUID' => (string) Uuid::generate(4)], ['Imf_Name' => 'Manual Input', 'Imf_Description' => 'Manual input subscriber registration', 'Imf_CreatedOn' => Carbon\Carbon::now(), 'Imf_CreatedBy' => 1, 'Imf_GUID' => (string) Uuid::generate(4)]]; ImportFrom::insert($importFrom); }
/** * add UUID to existing request * @return Request */ public function prepareRequest() { // get all input $request = Request::all(); // attach uuid as id $request['id'] = Uuid::generate(4)->string; return $request; }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. Company::truncate(); # Seed the table. $company = [['Cpy_Name' => 'Cahaya Bagi Negri (CBN Indonesia)', 'Cpy_Email' => '*****@*****.**', 'Cpy_WebsiteUrl' => 'http://www.jawaban.com', 'Cpy_Address1' => 'Jl. Sriwijaya Kavling 5-7', 'Cpy_Address2' => 'Lippo Cikarang, Cikarang Selatan', 'Cpy_City' => 'Kabupaten Bekasi', 'Cpy_PostCode' => '17550', 'Cpy_Country' => 'Indonesia', 'Cpy_TimeZone' => 'Asia/Jakarta', 'Cpy_CreatedOn' => Carbon\Carbon::now(), 'Cpy_CreatedBy' => 1, 'Cpy_GUID' => (string) Uuid::generate(4)]]; Company::insert($company); }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. MailList::truncate(); # Seed the table. $mailList = [['Mls_Name' => 'Jawaban Mailing List (Monthly)', 'Mls_EmailAddressFrom' => '*****@*****.**', 'Mls_EmailNameFrom' => 'Webmaster Jawaban.com', 'Mls_Reminder' => 'Y', 'Mls_CompanyName' => 'CBN Indonesia', 'Mls_Address1' => 'Jl. Sriwijaya Kavling 5-7', 'Mls_Address2' => 'Lippo Cikarang', 'Mls_City' => 'Kab. Bekasi', 'Mls_Country' => 'Indonesia', 'Mls_Phone' => '0218888888', 'Mls_NotifType' => 'All', 'Mls_CreatedOn' => Carbon\Carbon::now(), 'Mls_CreatedBy' => 1, 'Mls_GUID' => (string) Uuid::generate(4)]]; MailList::insert($mailList); }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. UserRoleDetail::truncate(); # Seed the table. $userRoleDetails = [['Urd_UserID' => 1, 'Urd_RoleID' => 1, 'Urd_CreatedOn' => Carbon\Carbon::now(), 'Urd_CreatedBy' => 1, 'Urd_GUID' => (string) Uuid::generate(4)], ['Urd_UserID' => 2, 'Urd_RoleID' => 2, 'Urd_CreatedOn' => Carbon\Carbon::now(), 'Urd_CreatedBy' => 1, 'Urd_GUID' => (string) Uuid::generate(4)], ['Urd_UserID' => 3, 'Urd_RoleID' => 3, 'Urd_CreatedOn' => Carbon\Carbon::now(), 'Urd_CreatedBy' => 1, 'Urd_GUID' => (string) Uuid::generate(4)]]; UserRoleDetail::insert($userRoleDetails); }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. UserRole::truncate(); # Seed the table. $userRoles = [['Ur_Name' => 'Administrator', 'Ur_Slug' => 'admin', 'Ur_CreatedOn' => Carbon\Carbon::now(), 'Ur_CreatedBy' => 1, 'Ur_GUID' => (string) Uuid::generate(4)], ['Ur_Name' => 'Content Editor', 'Ur_Slug' => 'content-editor', 'Ur_CreatedOn' => Carbon\Carbon::now(), 'Ur_CreatedBy' => 1, 'Ur_GUID' => (string) Uuid::generate(4)], ['Ur_Name' => 'Supervisor', 'Ur_Slug' => 'supervisor', 'Ur_CreatedOn' => Carbon\Carbon::now(), 'Ur_CreatedBy' => 1, 'Ur_GUID' => (string) Uuid::generate(4)], ['Ur_Name' => 'Designer', 'Ur_Slug' => 'designer', 'Ur_CreatedOn' => Carbon\Carbon::now(), 'Ur_CreatedBy' => 1, 'Ur_GUID' => (string) Uuid::generate(4)], ['Ur_Name' => 'Manager', 'Ur_Slug' => 'manager', 'Ur_CreatedOn' => Carbon\Carbon::now(), 'Ur_CreatedBy' => 1, 'Ur_GUID' => (string) Uuid::generate(4)]]; UserRole::insert($userRoles); }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. UserAccount::truncate(); # Seed the table. $userAccounts = [['Usr_Name' => 'Administrator', 'Usr_Email' => '*****@*****.**', 'Usr_Password' => bcrypt('optilog2014'), 'Usr_CreatedOn' => Carbon\Carbon::now(), 'Usr_CreatedBy' => 1, 'Usr_GUID' => (string) Uuid::generate(4)], ['Usr_Name' => 'Bambang Adrian', 'Usr_Email' => '*****@*****.**', 'Usr_Password' => bcrypt('content2015'), 'Usr_CreatedOn' => Carbon\Carbon::now(), 'Usr_CreatedBy' => 1, 'Usr_GUID' => (string) Uuid::generate(4)], ['Usr_Name' => 'Faber Banjarnahor', 'Usr_Email' => '*****@*****.**', 'Usr_Password' => bcrypt('supervisor2015'), 'Usr_CreatedOn' => Carbon\Carbon::now(), 'Usr_CreatedBy' => 3, 'Usr_GUID' => (string) Uuid::generate(4)]]; UserAccount::insert($userAccounts); }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. Permission::truncate(); # Seed the table. $permissions = [['Pm_Name' => 'Show All', 'Pm_Slug' => 'show-all', 'Pm_Description' => 'Show all menu', 'Pm_CreatedOn' => Carbon\Carbon::now(), 'Pm_CreatedBy' => 1, 'Pm_GUID' => (string) Uuid::generate(4)], ['Pm_Name' => 'Show Campaign', 'Pm_Slug' => 'show-campaign', 'Pm_Description' => 'Only show campaign menu', 'Pm_CreatedOn' => Carbon\Carbon::now(), 'Pm_CreatedBy' => 1, 'Pm_GUID' => (string) Uuid::generate(4)]]; Permission::insert($permissions); }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. PermissionRole::truncate(); # Seed the table. $permissionRoles = [['Pmr_PermissionID' => 1, 'Pmr_RoleID' => 1, 'Pmr_CreatedOn' => Carbon\Carbon::now(), 'Pmr_CreatedBy' => 1, 'Pmr_GUID' => (string) Uuid::generate(4)], ['Pmr_PermissionID' => 2, 'Pmr_RoleID' => 3, 'Pmr_CreatedOn' => Carbon\Carbon::now(), 'Pmr_CreatedBy' => 1, 'Pmr_GUID' => (string) Uuid::generate(4)]]; PermissionRole::insert($permissionRoles); }
private function createNewSite($markerSite) { $markerSite->id = Uuid::uuid4()->toString(); $markerSite->save(); Log::debug("Created " . $markerSite->id . " from " . $_SERVER['REMOTE_ADDR']); $this->authService->createAuth($markerSite->id); return $markerSite; }
/** * Run the database seeds. * * @return void */ public function run() { # Clear the table. SegmentCriteria::truncate(); # Seed the table. $segmentCriterias = [['Sc_Name' => 'Adult', 'Sc_CreatedOn' => Carbon\Carbon::now(), 'Sc_CreatedBy' => 1, 'Sc_GUID' => (string) Uuid::generate(4)], ['Sc_Name' => 'Kids', 'Sc_CreatedOn' => Carbon\Carbon::now(), 'Sc_CreatedBy' => 1, 'Sc_GUID' => (string) Uuid::generate(4)]]; SegmentCriteria::insert($segmentCriterias); }
public static function create(array $attributes = array(), $confirmation = true) { $attributes["confirmation_code"] = \Uuid::generate()->string; $user = parent::create($attributes); if ($confirmation) { self::sendComfirmationMail($user); } return $user; }