本文整理汇总了PHP中str_random函数的典型用法代码示例。如果您正苦于以下问题:PHP str_random函数的具体用法?PHP str_random怎么用?PHP str_random使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_random函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
m5eOT7ECgYEAzbVdEVngZd/jRlAo/LOLyy6NbZP4fli26hZjJBAJ8HhI93JEcxts
l/1E3rUME2a+F8CQ5FlGP02k66sB5lhzCg81Ym4fxbIP1n09IPmaRzSdM55SpbFy
7OV4VyrJKl7g2Y/utdb17DjYGovu+HX978j1iOH8qUruwAZyWshqdW0CgYEAwIVO
AohxuytN1GlQW4byQvHO4y+AXtZJ4iuBiyOqGhYs8bcnbV3+B0UTHtJyM8Novzj6
OcgiCEHP0Kj6Lj9RYu2sBvsgyfxEURdkHD7DPpYKlheCd7I1a9qk4/UyGx11YdnP
bcqrxv6e2FPBXNZGTXGBmHtIItxHYBEehguRLWUCgYALpR61or7fRYNaMaOAWrGp
OONstpm0nVUNf2LxYa8OW+DVkTRqx7yoBgBmEx2x43kTYyVQp/UgFEcnyDB9V7h7
c0z0W4OU73WSENjrCvY+3a2ghG/tTVRSMNNVK+jjayeTaWB8DsUxMC6bohxPGG7d
qiSsMQ7ajpFhcXv7w6izKQKBgQC+Pz0+vYz+NCXeQRAa0nj29LPIx7kofsRWTz3d
vKmsy7swRhkdN6P/lR/29mnKg1EwnmKP1RjkZfyyKznHl+SaSVoVL/dQAw2TwPS6
AL+6SlU9yw+vrxihc1g8uKICL5M+1hnoWj50EEvyZJoRXuHsR72UbEd1w454/ZHX
TvjxDQKBgCtikMNAqTParY/tX0xNohD7+svTKZt92CxW7Q/17H26ehFKUQvw6Agd
ulR2AVTGi6STEgzXf6UP5CAVhYRw9irCAQYpceL0GVzfZPQsXyLuMCnJ8UD6CBRn
i5vkNY4OZdOuEV9boFOFYa58WRNK7vthHkZJj++Amu3dZ6RHBlLQ
-----END RSA PRIVATE KEY-----', 'public_key' => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCasyO1qNW+Z331PzHBQ2sgVuvNKZnpUIzz2F+bhS31q2/b2Aa' . 'XYcU8ljtW2yVcMlUvrvDkRQyynLza2QBfsXTeJpqtKxujqcLXpRN9t81OLjhKebRP/lExq9I6c4xEnwFBx/OqB7' . '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]);
}
开发者ID:JamesForks,项目名称:deployer,代码行数:31,代码来源:ProjectTableSeeder.php
示例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)]);
}
}
开发者ID:johnathanmdell,项目名称:phpsouthafrica-2015-laravel-workshop,代码行数:12,代码来源:TasksTableSeeder.php
示例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('[email protected]', '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);
}
}
开发者ID:Charu91,项目名称:Wowtables1,代码行数:28,代码来源:AdminReservationsController.php
示例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;
}
开发者ID:lingxuan630,项目名称:invoiceninja,代码行数:29,代码来源:InvoiceService.php
示例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);
}
}
开发者ID:orloc,项目名称:seat,代码行数:26,代码来源:RegisterController.php
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(CuentasFacturas\User::class)->create(['name' => 'Luigi', 'username' => 'luigi', 'email' => '[email protected]', 'password' => bcrypt('12345'), 'type' => 'administrador', 'remember_token' => str_random(10)]);
factory(CuentasFacturas\User::class)->create(['name' => 'Admin 12345', 'username' => 'admin', 'email' => '[email protected]', 'password' => bcrypt('12345'), 'type' => 'administrador', 'remember_token' => str_random(10)]);
factory(CuentasFacturas\User::class)->create(['name' => 'Diana', 'username' => 'diana', 'email' => '[email protected]', 'password' => bcrypt('12345'), 'type' => 'usuario', 'remember_token' => str_random(10)]);
factory(CuentasFacturas\User::class, 25)->create();
}
开发者ID:luigilapa,项目名称:CuentasFacturas,代码行数:12,代码来源:UserTableSeeder.php
示例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);
}
}
开发者ID:nilove,项目名称:motibubackend,代码行数:35,代码来源:CandidatesController.php
示例8: createPublicCode
public function createPublicCode()
{
do {
$public_code = str_random(40);
} while ($this->where('public_code', $public_code)->count() > 0);
return $public_code;
}
开发者ID:ElasticOrange,项目名称:issue-monitoring,代码行数:7,代码来源:News.php
示例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;
}
开发者ID:weiyeu,项目名称:laravel_date,代码行数:36,代码来源:MatchDates.php
示例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());
}
}
//通过循环存储照片
}
开发者ID:abcn,项目名称:jxc,代码行数:34,代码来源:MarketController.php
示例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]);
}
}
开发者ID:rkkautsar,项目名称:CuapCuap,代码行数:30,代码来源:RepliesTableSeeder.php
示例12: run
public function run()
{
#Criação de Cliente
factory(Cliente::class)->create(['name' => 'Cliente', 'email' => '[email protected]', 'password' => bcrypt(1234), 'remember_token' => str_random(10)]);
#Criação de Motorista
factory(Motorista::class)->create(['name' => 'Motorista', 'email' => '[email protected]', 'password' => bcrypt(1234), 'remember_token' => str_random(10)]);
}
开发者ID:phelippe,项目名称:multitest,代码行数:7,代码来源:UsuariosTableSeeder.php
示例13: encriptar_contra
function encriptar_contra($contra = null)
{
if ($contra == null) {
$contra = str_random(10);
}
return \Hash::make($contra);
}
开发者ID:guiyebelli,项目名称:laprevia,代码行数:7,代码来源:Aplication.php
示例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);
}
开发者ID:jencko,项目名称:bbk,代码行数:32,代码来源:FoundReportController.php
示例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;
}
}
开发者ID:Pterodactyl,项目名称:Panel,代码行数:36,代码来源:UserRepository.php
示例16: postCreate
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function postCreate(UserRequest $request)
{
$user = new User();
$user->name = $request->name;
$user->tipo_usuario = $request->tipo_usuario;
$user->username = $request->username;
$user->email = $request->email;
$user->password = bcrypt($request->password);
$user->confirmation_code = str_random(32);
$user->confirmed = $request->confirmed;
$picture = "";
if ($request->hasFile('image')) {
$file = $request->file('image');
$filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$picture = sha1($filename . time()) . '.' . $extension;
$destinationPath = public_path() . '/uploads/users/fotos/';
$request->file('image')->move($destinationPath, $picture);
$path2 = public_path() . '/uploads/users/fotos/thumbs/';
Thumbnail::generate_image_thumbnail($destinationPath . $picture, $path2 . $picture);
}
$user->filename = $picture;
if ($user->save()) {
return redirect("/admin/users");
}
}
开发者ID:hyagobasilio,项目名称:gebep,代码行数:31,代码来源:UserController.php
示例17: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(ProjetRequest $request)
{
$projet = new Projet();
$image = $request->file('image');
if ($image->isValid()) {
$chemin = 'uploads';
$extension = $image->getClientOriginalExtension();
do {
$nom = str_random(10) . '.' . $extension;
} while (file_exists($chemin . '/' . $nom));
if ($image->move($chemin, $nom)) {
$projet->imageUne = $nom;
}
}
$projet->titre = $request->input('titre');
$projet->resume = $request->input('resume');
$projet->dateCreation = $request->input('date');
$projet->lien = $request->input('lien');
$projet->outils = $request->input('outils');
$projet->description = $request->input('description');
$projet->cupofcoffee = $request->input('cupofcoffee');
$projet->save();
$projets = projet::all();
return view('projet/liste', ['projets' => $projets]);
}
开发者ID:AunCly,项目名称:aunclyplay,代码行数:31,代码来源:ProjetController.php
示例18: postCreate
/**
* This function create employee
* when data is posted from
* /admin/employee/create
*/
public function postCreate()
{
// Check validation
$validator = Validator::make(Input::all(), Employee::$rulesForCreate, Employee::$messages);
// If failed then redirect to employee-create-get route with
// validation error and input old
if ($validator->fails()) {
return Redirect::route('employee-create-get')->withErrors($validator)->withInput();
}
// If validation is not failed then create employee
$employee = Employee::create(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'age' => Input::get('age'), 'gender' => Input::get('gender'), 'DOB' => DateFormat::store(Input::get('DOB')), 'present_address' => Input::get('present_address'), 'permanent_address' => Input::get('permanent_address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'country' => Input::get('country'), 'mobile_no' => Input::get('mobile_no'), 'email' => Input::get('email'), 'created_by' => Session::get('username')));
// Also create user account for the employee
$user = User::create(array('details_id' => $employee->id, 'username' => Input::get('username'), 'email' => $employee->email, 'user_level' => Input::get('userlevel'), 'active' => 0));
// generate random code and password
$password = str_random(10);
$code = str_random(60);
$newHashPassword = Hash::make($password);
// Save new password and code
$user->password_tmp = $newHashPassword;
$user->activation_code = $code;
if ($user->save()) {
// Send email to the employee.
// This email contains username,password,activation link
Mail::send('emails.auth.activation', array('first_name' => $employee->first_name, 'last_name' => $employee->last_name, 'username' => $user->username, 'password' => $password, 'activation_link' => URL::route('activation-get', $code)), function ($message) use($user) {
$message->to($user->email, $user->username)->subject('Confirm Activation');
});
}
return View::make('adminArea.employee.create')->with('success', 'Activation link has been sent successfully');
}
开发者ID:madiarsa,项目名称:DVD-Rental,代码行数:34,代码来源:EmployeeController.php
示例19: boot
/**
* Boot the model.
*
* @return void
*/
public static function boot()
{
parent::boot();
static::creating(function ($user) {
$user->token = str_random(30);
});
}
开发者ID:paihz,项目名称:instaX-project,代码行数:12,代码来源:User.php
示例20: postRegister
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
$activation_code = str_random(60) . $request->input('email');
$user = new User();
$user->username = $request->input('username');
$user->name = $request->input('name');
$user->lastname = $request->input('lastname');
$user->birthdate = $request->input('birthdate');
$user->email = $request->input('email');
$user->password = bcrypt($request->input('password'));
$user->activation_code = $activation_code;
if ($user->save()) {
$data = array('name' => $user->name, 'code' => $activation_code);
\Mail::queue('emails.activateAccount', $data, function ($message) use($user) {
$message->to($user->email, 'Please activate your account.');
});
return view('user.activateAccount');
} else {
Flash::message('Your account couldn\'t be create please try again');
return redirect()->back()->withInput();
}
}
开发者ID:angebe,项目名称:CloudWac.github.io,代码行数:26,代码来源:AuthController.php
注:本文中的str_random函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论