コード例 #1
0
ファイル: ModelFactory.php プロジェクト: travtex/fdmovers
<?php

/*
|--------------------------------------------------------------------------
| 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.
|
*/
$factory->define(App\User::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)];
});
$factory->define(App\Mover::class, function (Faker\Generator $faker) {
    return ['first_name' => $faker->firstNameMale, 'last_name' => $faker->lastName, 'email' => $faker->email, 'hired_at' => $faker->dateTimeBetween('-1 year', '-1 week')];
});
$factory->define(App\Truck::class, function (Faker\Generator $faker) {
    return ['make_model' => $faker->company, 'model_year' => $faker->year, 'vin' => $faker->md5, 'serviced_at' => $faker->dateTimeBetween('-6 month', '-1 week')];
});
$factory->define(App\Crew::class, function (Faker\Generator $faker) {
    return ['name' => $faker->sentence(2, true)];
});
$factory->define(App\Move::class, function (Faker\Generator $faker) {
    return ['truck_id' => App\Truck::all()->random(1)->id, 'crew_id' => App\Crew::all()->random(1)->id, 'location' => $faker->streetAddress, 'completed_at' => $faker->dateTimeBetween('-1 year', '+1 month')];
});
コード例 #2
0
ファイル: DatabaseSeeder.php プロジェクト: travtex/fdmovers
 public function run()
 {
     App\Truck::truncate();
     factory(App\Truck::class, 5)->create();
 }
コード例 #3
0
ファイル: routes.php プロジェクト: stoic1979/laravel_trucks
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', ['middleware' => 'auth', 'uses' => 'CompanyController@index']);
Route::model('company', 'Company');
Route::model('customer', 'Customer');
Route::model('driver', 'Driver');
Route::model('truck', 'Truck');
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::bind('company', function ($value, $route) {
    return App\Company::whereId($value)->first();
});
Route::bind('customer', function ($value, $route) {
    return App\Customer::whereId($value)->first();
});
Route::bind('driver', function ($value, $route) {
    return App\Driver::whereId($value)->first();
});
Route::bind('truck', function ($value, $route) {
    return App\Truck::whereId($value)->first();
});
Route::resource('company', 'CompanyController');
Route::resource('customer', 'CustomerController');
Route::resource('driver', 'DriverController');
Route::resource('truck', 'TruckController');