本文整理汇总了PHP中app\User::orderByRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP User::orderByRaw方法的具体用法?PHP User::orderByRaw怎么用?PHP User::orderByRaw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::orderByRaw方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(User::class, 50)->create()->each(function ($user) {
// store 10 rounds per user
for ($i = 0; $i < 10; $i++) {
// pick a random course to play on
$course = Course::orderByRaw("random()")->first();
// pick a random tee set on that course
$teeSet = TeeSet::orderByRaw("random()")->where('course_id', $course->id)->first();
$holes = $course->holes;
$scores = [];
// each round has 18 scores
for ($j = 0; $j < 18; $j++) {
$scores[] = factory(Score::class)->make(['hole_id' => $holes[$j]->id]);
}
$round = factory(Round::class)->make(['tee_set_id' => $teeSet->id]);
$round = $user->rounds()->save($round);
$round->scores()->saveMany($scores);
}
$followed = [$user->id];
// follow 10 random users
for ($i = 0; $i < 10; $i++) {
// pick a random user, that is not the current user and is not already followed
$userToFollow = User::orderByRaw("random()")->whereNotIn('users.id', $followed)->first();
$user->following()->attach($userToFollow);
$followed[] = $userToFollow->id;
}
});
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('bids')->delete();
$auctions = Auction::get();
foreach ($auctions as $auction) {
$random_user = User::orderByRaw("RAND()")->first();
if (rand(0, 5) == 0) {
Bid::create(['user_id' => $random_user->id, 'auction_id' => $auction->id, 'price' => $auction->min_price + 999]);
}
}
}
示例3: run
public function run()
{
DB::table('articles')->delete();
$faker = Faker\Factory::create('it_IT');
$articlesCount = 50;
$categoriesIds = $this->getCategoriesIdsArray();
for ($c = 0; $c < $articlesCount; $c++) {
$title = $faker->sentence();
$slug = Str::slug($title);
$article = Article::create(['title' => $title, 'slug' => $slug, 'body' => '<p>' . $faker->paragraph(10) . '</p>', 'is_published' => $faker->boolean(80), 'published_at' => $faker->dateTimeThisYear($max = 'now'), 'meta_keys' => implode(',', $faker->words(5)), 'meta_description' => $faker->sentence(), 'user_id' => User::orderByRaw('RAND()')->first()->id]);
$article->categories()->sync($faker->randomElements($categoriesIds, mt_rand(1, 2)));
}
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create('it_IT');
$articlesCount = 10;
//$descriptionsIds = $this->getDescriptionsIdsArray();
for ($c = 0; $c < $articlesCount; $c++) {
$name = $faker->text(54);
$slug = Str::slug($name);
// creo l'articolo
$project = Project::create(['name' => f, 'slug' => $slug, 'state' => $faker->boolean(80), 'progress' => $faker->unique()->randomDigit, 'meta_keys' => implode(',', $faker->words(5)), 'short_description' => $faker->sentence(), 'is_published' => $faker->boolean(80), 'published_at' => $faker->dateTimeThisYear($max = 'now'), 'user_id' => User::orderByRaw('RAND()')->first()->id]);
// associo le categorie casualmente (una o due per articolo)
//$project->descriptions()->sync($faker->randomElements($descriptionsIds, 1));
}
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$user = User::first();
Event::create(['title' => 'Northern Soul: The Film', 'time_start' => '2016-10-30-19-00-00', 'time_end' => '2016-10-30-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'CoderDojo at The Sharp Project', 'time_start' => '2016-10-30-19-00-00', 'time_end' => '2016-10-30-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Design How Talks', 'time_start' => '2016-10-30-19-00-00', 'time_end' => '2016-10-30-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Loz’s Birthday Party', 'time_start' => '2016-10-30-19-00-00', 'time_end' => '2016-10-30-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Introduction to Arduino', 'time_start' => '2016-10-30-19-00-00', 'time_end' => '2016-10-30-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Made You Look Documentary a Film About the Digital Age', 'time_start' => '2016-10-30-19-00-00', 'time_end' => '2016-10-30-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'CoderDojo at The Sharp Project Hackday', 'time_start' => '2016-10-30-19-00-00', 'time_end' => '2016-10-30-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Film How - Northern Soul / Factory', 'time_start' => '2016-10-30-19-00-00', 'time_end' => '2016-10-30-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Manchester Moleskine® Talks, Exhibition', 'time_start' => '2016-11-01-19-00-00', 'time_end' => '2016-11-01-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Manchester Worker Bee Exhibition', 'time_start' => '2016-11-03-19-00-00', 'time_end' => '2016-11-03-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Festival of the Spoken Nerd: Just for Graphs Comedy', 'time_start' => '2016-11-08-19-00-00', 'time_end' => '2016-11-08-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Back to the Future at Manchester Cathederal Film', 'time_start' => '2016-12-02-19-00-00', 'time_end' => '2016-12-02-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Biospheric Studio presents Urban Naturalist Workshop', 'time_start' => '2016-12-09-19-00-00', 'time_end' => '2016-12-09-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'The Hitchhiker’s Guide to the Solar System Exhibition', 'time_start' => '2016-12-12-19-00-00', 'time_end' => '2016-12-12-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Homeless Film festival - Waste Land Film', 'time_start' => '2016-12-19-19-00-00', 'time_end' => '2016-12-19-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Both sides now: It was the best of times, it was the worst of times? Exhibition', 'time_start' => '2016-05-04-19-00-00', 'time_end' => '2016-05-04-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
Event::create(['title' => 'Places', 'time_start' => '2016-05-06-19-00-00', 'time_end' => '2016-05-07-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18)]);
}
示例6: index
public function index()
{
return view('useradmin.index')->withUser($this->user)->withUsers(User::orderByRaw("FIELD(`state`, 'register', 'auth', 'disabled', 'rented', 'normal')")->orderBy('id', 'desc')->paginate(20));
}
示例7: function
<?php
use App\User;
use App\Question;
use Illuminate\Support\Facades\Redirect;
Route::group(['middleware' => 'web'], function () {
Route::group(['domain' => '{event}.plexus.dev'], function ($event) {
Route::get('/', ['as' => 'root', 'uses' => 'PagesController@root']);
Route::get('ss', function () {
dd(time());
//return serialize(['a'=>'abhay', 'b'=>'rawat', 'c'=>'aby', 'd'=>'awat']);
$x = User::orderByRaw("RAND()")->pluck('id')->toArray();
$event = "khoj";
dd($x);
$ques = Question::where('event_id', 2)->orderByRaw('RAND()')->get()->take(1)->toArray();
dd($ques);
});
// Route::get('/', function($event){return Redirect::route('as');});
Route::get('social/google', ['as' => 'social_login', 'uses' => 'UserController@social_redirect_g']);
Route::get('social/facebook', ['as' => 'social_login', 'uses' => 'UserController@social_redirect_f']);
Route::post('login', ['uses' => 'RegController@login']);
Route::post('signup', ['uses' => 'RegController@signup']);
Route::group(['middleware' => 'auth'], function () {
// All the GET routes ====>
// Route::get('dashboard', ['as'=>'dashboard_event', 'uses'=>'pagesController@dashboard_event']);
Route::get('battleground', ['as' => 'battleground', 'uses' => 'PagesController@battleground']);
Route::get('leaderboard', ['as' => 'leaderboard', 'uses' => 'PagesController@leaderboard']);
Route::get('waiting', ['as' => 'waiting', 'uses' => 'PagesController@wait']);
Route::get('rules', ['as' => 'rules', 'uses' => 'PagesController@rules']);
Route::get('upload', ['as' => 'upload', 'uses' => 'PagesController@upload']);
Route::get('fetch/{level}', ['uses' => 'OpController@fetch_ques']);
示例8: function
use App\User;
use App\Institution;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
/**
* Model Factory for Users
*/
$factory->define(App\User::class, function (Faker\Generator $faker) {
return ['firstName' => $faker->firstName, 'lastName' => $faker->lastName, 'email' => $faker->email, 'address' => $faker->streetAddress(), 'city' => $faker->city(), 'zip' => $faker->postcode(), 'country' => $faker->country(), 'password' => bcrypt(str_random(10)), 'isAdmin' => 0, 'remember_token' => str_random(10)];
});
/**
* Model Factory for Courses
*/
$factory->define(App\Course::class, function (Faker\Generator $faker) {
return ['assignedOwner' => User::orderByRaw("RAND()")->first()->id, 'assignedInstitution' => Institution::orderByRaw("RAND()")->first()->id, 'courseName' => $faker->sentence(4), 'description' => $faker->text(250), 'price' => $faker->randomNumber(4), 'startDate' => $faker->dateTimeBetween('now', '+3 years'), 'duration' => $faker->randomNumber(1), 'created_at' => $faker->dateTime($max = 'now'), 'confirmed' => 0, 'participantNum' => 20];
});
/**
* Model Factory for Institutions
*/
$factory->define(App\Institution::class, function (Faker\Generator $faker) {
return ['name' => $faker->company(), 'slug' => $faker->word(), 'address' => $faker->streetAddress(), 'city' => $faker->city(), 'zip' => $faker->postcode(), 'country' => $faker->country(), 'created_at' => $faker->dateTime($max = 'now')];
});
示例9: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$city = City::create(['name' => 'New York', 'iata' => 'nyc']);
$event = Event::create(['title' => 'A very NYC style event.', 'time_start' => '2016-10-30-19-00-00', 'time_end' => '2016-10-30-22-30-00', 'content' => 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum link style auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget Link style sem nec elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.', 'venue' => '70 Oxford Street, M1 5NH', 'user_id' => User::orderByRaw("RAND()")->first()->id, 'category_id' => rand(1, 5), 'color_scheme_id' => rand(1, 18), 'city_id' => $city->id]);
}