コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $courses = App\Course::all();
     factory(App\Content::class, 100)->make()->each(function ($content) use($courses) {
         $content->course()->associate($courses->random());
         $content->save();
     });
 }
コード例 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $courses = App\Course::all();
     factory(App\Question::class, 100)->make()->each(function ($question) use($courses) {
         $course = $courses->random();
         $question->course()->associate($course);
         $question->user()->associate($course->users->random());
         $question->save();
     });
 }
コード例 #3
0
ファイル: routes.php プロジェクト: somayahegab/coursatak
<?php

/*
|--------------------------------------------------------------------------
| 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('/', function () {
    $courses = App\Course::all();
    return view('layouts.home', compact('courses'));
});
Route::get('courseregister', ['middleware' => ['auth'], function () {
    $courses = App\Course::all();
    return view('layouts.courseregister', compact('courses'));
}]);
Route::get('login', function () {
    return view('auth.login');
});
Route::get('register', function () {
    return view('auth.register');
});
Route::post('login', 'usercontroller@register');
コード例 #4
0
    $firs_name = $faker->firstName;
    $last_name = $faker->lastName;
    return ['identification' => $faker->unique()->numberBetween(5000000, 39999999), 'first_name' => $firs_name, 'last_name' => $last_name, 'avatar' => 'vendor/AdminTheme/images/avatar/default.png', 'type' => $faker->randomElement(['teacher', 'student']), 'email' => $faker->unique()->email, 'password' => '123456'];
});
$factory->define(App\Course::class, function ($faker) {
    return ['title' => $faker->sentence(3), 'description' => $faker->paragraph(10), 'image' => $faker->imageUrl(660, 260), 'user_id' => App\User::all()->random()->id];
});
$factory->define(App\Unit::class, function ($faker) {
    return ['pos' => $faker->randomNumber(1), 'title' => $faker->sentence(5), 'description' => $faker->paragraph(10), 'image' => $faker->imageUrl(660, 260), 'user_id' => App\User::all()->random()->id, 'course_id' => App\Course::all()->random()->id];
});
$factory->define(App\Lesson::class, function ($faker) {
    return ['pos' => $faker->randomNumber(1), 'title' => $faker->sentence(5), 'content' => $faker->paragraph(10), 'user_id' => App\User::all()->random()->id, 'unit_id' => App\Unit::all()->random()->id];
});
$factory->define(App\Question::class, function ($faker) {
    return ['title' => $faker->sentence(2) . '?', 'unit_id' => App\Unit::all()->random()->id, 'user_id' => App\User::all()->random()->id];
});
$factory->define(App\Answer::class, function ($faker) {
    return ['content' => $faker->sentence(5), 'correct' => rand(0, 1), 'question_id' => App\Question::all()->random()->id, 'user_id' => App\User::all()->random()->id];
});
$factory->define(App\Comment::class, function ($faker) {
    return ['content' => $faker->paragraph(5), 'user_id' => App\User::all()->random()->id, 'lesson_id' => App\Lesson::all()->random()->id];
});
$factory->define(App\Reply::class, function ($faker) {
    return ['content' => $faker->paragraph(5), 'user_id' => App\User::all()->random()->id, 'comment_id' => App\Comment::all()->random()->id];
});
$factory->define(App\Evaluation::class, function ($faker) {
    return ['value' => $faker->numberBetween(15, 20), 'min_value' => $faker->numberBetween(50, 85), 'max_question' => $faker->numberBetween(5, 6), 'unit_id' => App\Unit::all()->random()->id, 'user_id' => App\User::all()->random()->id];
});
$factory->define(App\CourseUser::class, function ($faker) {
    return ['course_id' => App\Course::all()->random()->id, 'user_id' => App\User::all()->random()->id];
});