本文整理汇总了PHP中str_random函数的典型用法代码示例。如果您正苦于以下问题:PHP str_random函数的具体用法?PHP str_random怎么用?PHP str_random使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_random函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
DB::table('projects')->delete();
Project::create(['name' => 'Deployer', 'hash' => str_random(60), 'repository' => 'https://github.com/REBELinBLUE/deployer.git', 'url' => 'http://deployer.app', 'group_id' => 2, 'private_key' => '-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAmrMjtajVvmd99T8xwUNrIFbrzSmZ6VCM89hfm4Ut9atv29gG
l2HFPJY7VtslXDJVL67w5EUMspy82tkAX7F03iaarSsbo6nC16UTfbfNTi44Snm0
T/5RMavSOnOMRJ8BQcfzqge4oIQzVGXOs0YvNFdSt4paBp9dssKS+7yP/hDvgAVz
+LE3IcIeO26aXATcuB4zq3vjaqSzWZGdNhOJZ4EmjgmOq9+k3SAmooHkF+p/14MJ
tq0ZK9KjSGbHfyKMi2EuvwllFCY19eqsV7dcMDIsMKUW2diFC52dJSO+EF47nA/j
sNDisFsIC7DeeVVBl1TpaV9RidqeZmdx+mF9AQIDAQABAoIBAH4qhYAdTx03eGGw
hVqSKmc4nJ05RX4kJKCmoerLZh1LETJh75Y8tchg2cpPdhvILPNzoKD6s41kCR4P
BqAEsUSQhWufka4bwH1w8wGACp+tUFllAqqOxhdVg2IKZKZ+a18DvPS50ViQGPDH
CxnorozoftyTqDJofNlSmN9X/LN+RZ1zRJRaPkBvSkYOCT4gnJLmHLGN7eJsHQeR
EJe83E4VPZ+2faBHEigXAHc4rh63iRxmmqqlcrItXzONZZUOjXwBNqZs4aVl+DZd
1pPiB9nOT9zLiy9ZwHZfIRIF3LkWAVsIkzOPDw9wLNgzI60uiLlYY1ODua8maqDP
m5eOT7ECgYEAzbVdEV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. 'ighDNUZc6zRi80V1K3iloGn12ywpL7vI/+EO+ABXP4sTchwh47bppcBNy4HjOre+NqpLNZkZ02E4lngSaOCY6r3' . '6TdICaigeQX6n/Xgwm2rRkr0qNIZsd/IoyLYS6/CWUUJjX16qxXt1wwMiwwpRbZ2IULnZ0lI74QXjucD+Ow0OKw' . 'WwgLsN55VUGXVOlpX1GJ2p5mZ3H6YX0B deploy@deployer', 'last_run' => null, 'build_url' => 'http://ci.rebelinblue.com/build-status/image/3?branch=master', 'allow_other_branch' => true, 'include_dev' => false]);
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('tasks')->delete();
for ($i = 0; $i < 5; $i++) {
DB::table('tasks')->insert(['title' => str_random(10)]);
}
}
示例3: addMember
public function addMember()
{
$password = str_random(6);
$phone = Input::get('phone');
$cityid = Input::get('city');
$user_id = DB::table('users')->insertGetId(['full_name' => Input::get('full_name'), 'email' => Input::get('email'), 'password' => bcrypt($password), 'role_id' => 3, 'location_id' => Input::get('city'), 'phone_number' => $phone]);
$data = array('full_name' => Input::get('full_name'), 'email' => Input::get('email'), 'phone_number' => Input::get('phone'));
if ($user_id) {
DB::table('user_attributes_varchar')->insert(['user_id' => $user_id, 'user_attribute_id' => 7, 'attribute_value' => '1' . str_pad($user_id, 6, '0', STR_PAD_LEFT)]);
$createPasswordRequest = Password::creatRequestWebsitePassword($data);
$createPasswordRequest['password'] = $password;
Mail::send('site.pages.website_admin_registration', ['data' => $createPasswordRequest], function ($message) use($createPasswordRequest) {
$message->from('concierge@wowtables.com', 'WowTables by GourmetItUp');
$message->to($createPasswordRequest['email'])->subject('You have been registered as a WowTables member!');
});
$city_name = Location::where(['Type' => 'City', 'id' => $cityid])->pluck('name');
if (empty($city_name)) {
$city_name = 'mumbai';
}
$city = ucfirst($city_name);
$merge_vars = array('NAME' => isset($createPasswordRequest['userName']) ? $createPasswordRequest['userName'] : '', 'SIGNUPTP' => 'Email', 'BDATE' => '', 'GENDER' => '', 'MERGE11' => 0, 'MERGE17' => 'Admin added account', 'PHONE' => isset($phone) ? $phone : '', 'GROUPINGS' => array(array('id' => 9713, 'groups' => [$city])));
$this->mailchimp->lists->subscribe($this->listId, ["email" => $createPasswordRequest['email']], $merge_vars, "html", false, true);
$my_email = $createPasswordRequest['email'];
$success_message = "Email " . $my_email . " has been registered as a member.";
$data = array('user_id' => $user_id, 'success_message' => $success_message);
echo json_encode($data);
}
}
示例4: save
public function save($data)
{
if (isset($data['client'])) {
$client = $this->clientRepo->save($data['client']);
$data['client_id'] = $client->id;
}
$invoice = $this->invoiceRepo->save($data);
$client = $invoice->client;
$client->load('contacts');
$sendInvoiceIds = [];
foreach ($client->contacts as $contact) {
if ($contact->send_invoice || count($client->contacts) == 1) {
$sendInvoiceIds[] = $contact->id;
}
}
foreach ($client->contacts as $contact) {
$invitation = Invitation::scope()->whereContactId($contact->id)->whereInvoiceId($invoice->id)->first();
if (in_array($contact->id, $sendInvoiceIds) && !$invitation) {
$invitation = Invitation::createNew();
$invitation->invoice_id = $invoice->id;
$invitation->contact_id = $contact->id;
$invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
$invitation->save();
} elseif (!in_array($contact->id, $sendInvoiceIds) && $invitation) {
$invitation->delete();
}
}
return $invoice;
}
示例5: postNew
public function postNew()
{
$validation = new Validators\SeatUserRegisterValidator();
if ($validation->passes()) {
// Let's register a user.
$user = new \User();
$user->email = Input::get('email');
$user->username = Input::get('username');
$user->password = Hash::make(Input::get('password'));
$user->tsid = Input::get('tsid');
$user->activation_code = str_random(24);
$user->activated = 1;
$user->save();
// Prepare data to be sent along with the email. These
// are accessed by their keys in the email template
$data = array('activation_code' => $user->activation_code);
// Send the email with the activation link
Mail::send('emails.auth.register', $data, function ($message) {
$message->to(Input::get('email'), 'New SeAT User')->subject('SeAT Account Confirmation');
});
// And were done. Redirect to the login again
return Redirect::action('SessionController@getSignIn')->with('success', 'Successfully registered a new account. Please check your email for the activation link.');
} else {
return Redirect::back()->withInput()->withErrors($validation->errors);
}
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(CuentasFacturas\User::class)->create(['name' => 'Luigi', 'username' => 'luigi', 'email' => 'ss@mail.com', 'password' => bcrypt('12345'), 'type' => 'administrador', 'remember_token' => str_random(10)]);
factory(CuentasFacturas\User::class)->create(['name' => 'Admin 12345', 'username' => 'admin', 'email' => 'admin@mail.com', 'password' => bcrypt('12345'), 'type' => 'administrador', 'remember_token' => str_random(10)]);
factory(CuentasFacturas\User::class)->create(['name' => 'Diana', 'username' => 'diana', 'email' => 'diana@mail.com', 'password' => bcrypt('12345'), 'type' => 'usuario', 'remember_token' => str_random(10)]);
factory(CuentasFacturas\User::class, 25)->create();
}
示例7: update
public function update($candidate_id)
{
try {
Log::info(Input::all());
$candidate = Candidate::findOrFail($candidate_id);
$candidate->fill(Input::all());
$user = User::find($candidate->user_id);
if (\Input::has('skills')) {
$skills = [];
foreach (\Input::get('skills') as $skill) {
$skills[$skill['skill_id']] = ['description' => isset($skill['description']) ? $skill['description'] : '', 'level' => isset($skill['level']) ? $skill['level'] : 0];
}
$user->skills()->detach();
$user->skills()->sync($skills);
}
// Destination path for uplaoded files which is at /public/uploads
$destinationPath = public_path() . '/uploads/img/';
// Handle profile Picture
if (Input::hasFile('profile_pic_filename')) {
$file = Input::file('profile_pic_filename');
$profile_pic_filename = str_random(6) . '_' . str_replace(' ', '_', $file->getClientOriginalName());
$uploadSuccess = $file->move($destinationPath, $profile_pic_filename);
if ($uploadSuccess) {
$candidate->profile_pic_filename = $profile_pic_filename;
}
}
$candidate->save();
$user->candidateProfile->profile_pic_filename = url('/uploads/img/' . $user->candidateProfile->profile_pic_filename);
$response = $user->candidateProfile;
$response['skills'] = $user->skills;
return $this->respondWithArray(['success' => true, 'message' => 'Candidate info updated', 'candidate_profile' => $response]);
} catch (ModelNotFoundException $e) {
return $this->setStatusCode(404)->respondWithError('Candidate with ID ' . $candidate_id . ' not found', 404);
}
}
示例8: createPublicCode
public function createPublicCode()
{
do {
$public_code = str_random(40);
} while ($this->where('public_code', $public_code)->count() > 0);
return $public_code;
}
示例9: generateTestDate
/**
* generate test date applications and users
* @param int
* @return mixed
*/
public function generateTestDate($numberOfDate)
{
// process time start
$pStartTime = microtime(true);
// faker
$faker = Factory::create();
// gender random array
$genderArr = ['male', 'female'];
for ($i = 0; $i < $numberOfDate; $i++) {
// fake user data
$fakeUserData = ['nickname' => $faker->userName, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'real_name' => $faker->firstName, 'sex' => $this->genderArr[rand(0, 1)], 'year' => $faker->year, 'month' => $faker->month, 'date' => $faker->dayOfMonth, 'phone_number' => $faker->phoneNumber, 'confirmed' => 1, 'remember_token' => str_random(10)];
// create faker user
$fakeUser = User::create($fakeUserData);
// time range
$timeRange = array_rand($this->timeArr, 2);
// start time
$startTime = $this->timeArr[$timeRange[1]];
// end time
$endTime = $this->timeArr[$timeRange[0]];
// swap time range if not reasonable
if ($startTime > $endTime && $startTime != 0 && $endTime != 0) {
list($startTime, $endTime) = array($endTime, $startTime);
}
// fake date applicatoin
$fakeDateAppData = ['user_id' => $fakeUser->id, 'city' => $this->cityArr[array_rand($this->cityArr, 1)], 'start_time' => $startTime, 'end_time' => $endTime, 'vegetarian_type' => $this->vegetarianTypeArr[array_rand($this->vegetarianTypeArr, 1)], 'meal_type' => $this->mealTypeArr[array_rand($this->mealTypeArr, 1)], 'sex_constraint' => $this->genderArr[array_rand($this->genderArr, 1)]];
// create fake date applicatoin
$fakeDateApp = DateApplication::create($fakeDateAppData);
}
$pTime = microtime(true) - $pStartTime;
echo 'process time is ' . $pTime;
}
示例10: store
public function store()
{
//存储数据
$market = new Market();
$market->title1 = $this->request->get('title1');
$market->sc_price = $this->request->get('sc_price');
$market->cb_price = $this->request->get('cb_price');
$market->desc = $this->request->get('desc');
$market->amount = $this->request->get('amount');
$market->rank = $this->request->get('rank');
$market->alibaba1 = $this->request->get('alibaba1');
$market->alibaba2 = $this->request->get('alibaba2');
$market->investigators = $this->request->get('investigators');
$market->save();
//获取图片
$images = $this->request->file('images');
foreach ($images as $image) {
//获取图片名称
$fileName = md5(uniqid(str_random(10)));
//
try {
\Image::make($image)->resize(100, 100)->save('uploads/images/' . $fileName . '.jpg');
//存储图片
$marketImage = new MarketImage();
$marketImage->image = 'uploads/images/' . $fileName . '.jpg';
$marketImage->market_id = $market->id;
$marketImage->save();
} catch (\Exception $e) {
//图片上传失败
dd($e->getMessage());
}
}
//通过循环存储照片
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
for ($count = 1; $count <= 10; $count++) {
$thread_id = rand(1, DB::table('threads')->count());
$position = Helper::appendZero($count, 5);
$user_id = rand(1, DB::table('users')->count());
DB::table('replies')->insert(['thread_id' => $thread_id, 'user_id' => $user_id, 'content' => str_random(100), 'position' => $position . ',', 'depth' => 0]);
DB::table('threads')->where('id', $thread_id)->increment('comment_count');
DB::table('users')->where('id', $user_id)->increment('comment_count');
$author_id = DB::table('threads')->where('id', $thread_id)->first()->author_id;
DB::table('notifications')->insert(['type' => 1, 'user_id' => $author_id, 'content_id' => $count]);
}
for ($count = 11; $count <= 30; $count++) {
$parent_id = rand(1, DB::table('replies')->count());
$parent = DB::table('replies')->where('id', $parent_id)->first();
$position = $parent->position . Helper::appendZero($count, 5) . ',';
$thread_id = $parent->thread_id;
$user_id = rand(1, DB::table('users')->count());
DB::table('replies')->insert(['thread_id' => $thread_id, 'user_id' => $user_id, 'content' => str_random(100), 'parent_id' => $parent_id, 'depth' => $parent->depth + 1, 'position' => $position]);
DB::table('threads')->where('id', $thread_id)->increment('comment_count');
DB::table('users')->where('id', $user_id)->increment('comment_count');
$author_id = DB::table('threads')->where('id', $thread_id)->first()->author_id;
DB::table('notifications')->insert(['type' => 1, 'user_id' => $author_id, 'content_id' => $thread_id]);
}
}
示例12: run
public function run()
{
#Criação de Cliente
factory(Cliente::class)->create(['name' => 'Cliente', 'email' => 'cliente@email.com', 'password' => bcrypt(1234), 'remember_token' => str_random(10)]);
#Criação de Motorista
factory(Motorista::class)->create(['name' => 'Motorista', 'email' => 'motorista@email.com', 'password' => bcrypt(1234), 'remember_token' => str_random(10)]);
}
示例13: encriptar_contra
function encriptar_contra($contra = null)
{
if ($contra == null) {
$contra = str_random(10);
}
return \Hash::make($contra);
}
示例14: postPublish
public function postPublish()
{
$msg = 'Report Successfully Published';
$inputs = Input::except('notify');
foreach (Input::all() as $key => $single_input) {
if (empty($single_input) && (stristr($key, 'state') || stristr($key, 'city'))) {
unset($inputs[$key]);
}
}
$inputs['dob'] = GlobalFunc::set_date_format(Input::get('dob'));
$inputs['found_date'] = GlobalFunc::set_date_format(Input::get('found_date'));
if (!Input::hasFile('kid_image')) {
unset($inputs['kid_image']);
} else {
$file = Input::file('kid_image');
$destination_path = 'admin/images/upload/';
$filename = str_random(15) . '.' . $file->getClientOriginalExtension();
$file->move($destination_path, $filename);
$inputs['kid_image'] = $destination_path . $filename;
}
if (Input::get('clicked') == 'Success') {
// if the report is marked as a success
$inputs['status'] = 9;
$msg = 'Report Successfully Marked As Success';
} else {
//if the report is updated or published
$inputs['status'] = 1;
}
unset($inputs['clicked']);
Found::where('id', '=', Input::get('id'))->update($inputs);
return Redirect::to('admin/found/published')->with('success', $msg);
}
示例15: create
/**
* Creates a user on the panel. Returns the created user's ID.
*
* @param string $email
* @param string|null $password An unhashed version of the user's password.
* @return bool|integer
*/
public function create($email, $password = null, $admin = false)
{
$validator = Validator::make(['email' => $email, 'password' => $password, 'root_admin' => $admin], ['email' => 'required|email|unique:users,email', 'password' => 'nullable|regex:((?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,})', 'root_admin' => 'required|boolean']);
// Run validator, throw catchable and displayable exception if it fails.
// Exception includes a JSON result of failed validation rules.
if ($validator->fails()) {
throw new DisplayValidationException($validator->errors());
}
DB::beginTransaction();
try {
$user = new Models\User();
$uuid = new UuidService();
$user->uuid = $uuid->generate('users', 'uuid');
$user->email = $email;
$user->password = Hash::make(is_null($password) ? str_random(30) : $password);
$user->language = 'en';
$user->root_admin = $admin ? 1 : 0;
$user->save();
// Setup a Password Reset to use when they set a password.
$token = str_random(32);
DB::table('password_resets')->insert(['email' => $user->email, 'token' => $token, 'created_at' => Carbon::now()->toDateTimeString()]);
$user->notify(new AccountCreated($token));
DB::commit();
return $user->id;
} catch (\Exception $ex) {
DB::rollBack();
throw $ex;
}
}