/** * Show course details * * @return Response */ public function postStart(Course\Course $course) { $section = $course->sections()->first(); auth()->user()->courses()->attach($course); auth()->user()->sections()->attach($section); return redirect()->route('front.section', [$course, $section, $section->slug()]); }
/** * Remove the specified resource from storage. * * @param Announcement $announcement * @return Response */ public function DeleteAnnouncement(Course\Course $course, Announcement\Announcement $announcement) { if (auth()->check() && ($course->isAuthTeacher() || auth()->user()->isAdmin())) { $this->dispatch(new announcement\Jobs\DeleteJob($announcement)); } return redirect()->route('front.course', $course); }
/** * Run the database seeds. * * @return void */ public function run() { \Model\Course\Course::truncate(); // factory(\Model\Course\Course::class, 10)->create(); \Model\Course\Course::create(['id' => 1, 'uid' => generate_id(), 'url' => 'http://eders.manas.edu.kg/enrol/index.php?id=9', 'image' => 'img/course/cover/tarih-600x400.jpg', 'code' => 'TAR-251', 'name' => 'Ата Мекен Тарыхы I', 'description' => 'Атамекен (Кыргыз Республикасынын) тарыхын окутууга киришүү Кыргызстандагы этникалык процесстер, кыргыз элинин жаралышы жана калыптанышы жөнүндө', 'approved' => true, 'published' => true, 'order' => 10]); \Model\Course\Course::create(['id' => 2, 'uid' => generate_id(), 'url' => null, 'image' => 'img/course/cover/ekoloji-600x400.jpg', 'code' => 'CEV-150', 'name' => 'Экология', 'description' => 'Киришүү. Экологиянын маселелери, изилдөө объектиси жана структурасы. Экологиянын дисциплиналар арасындагы мүнөзү', 'approved' => true, 'published' => true, 'order' => 20]); \Model\Course\Course::create(['id' => 3, 'uid' => generate_id(), 'url' => 'http://eders.manas.edu.kg/enrol/index.php?id=8', 'image' => 'img/course/cover/turk-uygralik-600x400.jpg', 'code' => 'TAR-202', 'name' => 'Dünya ve Türk Uygarlıkları', 'description' => 'Көчмөн цивлизациялардын өзгөчөлүктөрү', 'approved' => true, 'published' => true, 'order' => 30]); \Model\Course\Course::create(['id' => 4, 'uid' => generate_id(), 'url' => 'http://eders.manas.edu.kg/enrol/index.php?id=3', 'image' => 'img/course/cover/manas-600x400.jpg', 'code' => 'TUR-226', 'name' => 'Manasşinaslık', 'description' => '“Манас” эпосу – кыргыз рухунун туу чокусу', 'approved' => true, 'published' => true, 'order' => 40]); \Model\Course\Course::create(['id' => 5, 'uid' => generate_id(), 'url' => 'http://eders.manas.edu.kg/enrol/index.php?id=7', 'image' => 'img/course/cover/felsefe-600x400.jpg', 'code' => 'FIL-291', 'name' => 'Felsefe', 'description' => 'Felsefe Tarihi II (İslam ve Ortaçağ Felsefesi)', 'approved' => true, 'published' => true, 'order' => 50]); \Model\Course\Course::create(['id' => 6, 'uid' => generate_id(), 'url' => 'http://eders.manas.edu.kg/enrol/index.php?id=12', 'image' => 'img/course/cover/positif-bilimler-600x400.jpg', 'code' => 'FEN-102', 'name' => 'Pozitiv Bilim Kavramları', 'description' => 'Заманбап табият таануу илимдеринин концепциялары курсунун предмети. Коом, маданият жана илим.', 'approved' => true, 'published' => true, 'order' => 60]); \Model\Course\Course::create(['id' => 7, 'uid' => generate_id(), 'url' => 'http://eders.manas.edu.kg/enrol/index.php?id=2', 'image' => 'img/course/cover/tarih-2-600x400.jpg', 'code' => 'FEN-102', 'name' => 'Ata Meken Tarihi II (TR)', 'description' => 'Türkiye Cumhuriyeti Tarihi', 'approved' => true, 'published' => true, 'order' => 70]); \Model\Course\Course::create(['id' => 8, 'uid' => generate_id(), 'url' => null, 'image' => 'img/course/cover/ume-333-600x400.jpg', 'code' => 'UME3', 'name' => 'Programming Languages I', 'description' => 'Programming Languages I', 'approved' => true, 'published' => true, 'order' => 80]); \Model\Course\Course::create(['id' => 9, 'uid' => generate_id(), 'url' => null, 'image' => 'img/course/cover/java-600x400.jpg', 'code' => 'UME4', 'name' => 'Programming Languages II', 'description' => 'Introduction to Programming using Java', 'approved' => true, 'published' => true, 'order' => 90]); // $courses = \Model\Course\Course::lists('id'); // $users = \Model\User\User::whereIn('role', ['student', 'teacher'])->lists('id')->toArray(); \DB::table('user_course')->insert(['user_id' => 3, 'course_id' => 2]); \DB::table('user_course')->insert(['user_id' => 4, 'course_id' => 2]); $students = \Model\User\User::where('role', '=', 'student')->get(); // registering students to course $arr = []; foreach ($students as $student) { $arr[] = ['user_id' => $student->id(), 'course_id' => 2]; } \DB::table('user_course')->insert($arr); }
/** * Find a model by their id. * * @param $id * @return mixed */ public function findById($id) { return Course::findOrFail($id); }
| */ $factory->define(\Model\User\User::class, function ($faker) { $roles = explode(',', env('USER_ROLES')); return ['department_id' => [1, 2, 3, 4, 5, 6][rand(0, 5)], 'uid' => generate_id(), 'role' => $roles[rand(0, count($roles) - 1)], 'first_name' => $faker->unique()->firstName, 'last_name' => $faker->unique()->lastName, 'email' => strtolower($faker->unique()->email), 'phone' => "0 " . [55, 70, 77][rand(0, 2)] . rand(0, 9) . " " . rand(0, 9) . rand(0, 9) . " " . rand(0, 9) . rand(0, 9) . " " . rand(0, 9) . rand(0, 9), 'password' => '123', 'approved' => true]; }); $factory->define(\Model\Category\Category::class, function ($faker) { return ['uid' => generate_id(), 'name_en' => 'en ' . $faker->word, 'name_kg' => 'kg ' . $faker->word, 'name_ru' => 'ru ' . $faker->word, 'name_tr' => 'tr ' . $faker->word, 'description_en' => 'en ' . $faker->sentence(rand(3, 12)), 'description_kg' => 'kg ' . $faker->sentence(rand(3, 12)), 'description_ru' => 'ru ' . $faker->sentence(rand(3, 12)), 'description_tr' => 'tr ' . $faker->sentence(rand(3, 12))]; }); $factory->define(\Model\Course\Course::class, function ($faker) { $users = \Model\User\User::all(); $user = random_array($users); return ['uid' => generate_id(), 'code' => 'BIL-' . rand(100, 600), 'name' => $faker->unique()->word, 'description' => $faker->sentence(rand(3, 12)), 'approved' => true, 'published' => true]; }); $factory->define(\Model\Section\Section::class, function ($faker) { $courses = \Model\Course\Course::all(); $course = random_array($courses); return ['course_id' => $course->id(), 'name' => $faker->unique()->word, 'description' => $faker->sentence(rand(3, 12)), 'published' => true]; }); $factory->define(\Model\Note\Note::class, function ($faker) { $sections = \Model\Section\Section::all(); $section = random_array($sections); $users = \Model\User\User::all(); $user = random_array($users); return ['section_id' => $section->id(), 'name' => $faker->unique()->word, 'description' => $faker->sentence(rand(3, 12)), 'published' => true]; }); $factory->define(\Model\Question\Question::class, function ($faker) { // $exams = \Model\Exam\Exam::all(); // $exam = random_array($exams); $sections = \Model\Section\Section::where('course_id', '=', 2)->get(); //course_id = 2 is ekloji course