/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['title' => 'required', 'location' => 'required', 'duration' => 'required', 'details' => 'required']); Course::create($request->all()); Session::flash('message', 'Successfully Stored your Data!'); return redirect()->back(); }
public function run() { DB::table('courses')->delete(); Course::create(['course_code' => 5660, 'course_name' => "Legal", 'course_type' => "Pre-Requisite", 'description' => "This is a core Course"]); Course::create(['course_code' => 4665, 'course_name' => "JAVA", 'course_type' => "Track", 'description' => "This is a Track Course"]); Course::create(['course_code' => 5656, 'course_name' => "Android", 'course_type' => "Track", 'description' => "This is a Track Course"]); }
public function run() { DB::table('courses')->delete(); for ($i = 0; $i < 10; $i++) { Course::create(['id' => 'id ' . $i, 'id_1' => 'id_1' . $i, 'id_2' => 'id_2' . $i, 'id_3' => 'id_3' . $i, 'id_4' => 'id_4' . $i, 'name' => 'name' . $i, 'author' => 'author' . $i, 'introduction' => 'introduction' . $i, 'body' => 'body' . $i, 'pay_type' => 'pay_type' . $i, 'score' => 'score' . $i, 'ava_dir' => $i, 'vid_dir' => 'vid_dir' . $i]); } }
public function store(CourseRequest $request) { $name = $request->name; $url = UrlSanitizer::sanitize($name); $request["url"] = $url; $curso = Course::create($request->all()); return redirect()->route('stages.index', ['course_url' => $url]); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(CourseRequest $request) { $lect = User::where('id', '=', $request['lecturer_id'])->firstOrFail(); $dept = Department::where('id', '=', $lect->department_id)->firstOrFail(); $request['department_id'] = $dept->id; Course::create($request->all()); Flash::success('The Course has been created.'); return redirect()->route('course.index'); }
public function store(Request $request, $teacher_id) { $teacher = Teacher::find($teacher_id); if ($teacher) { $this->validateRequest($request); $course = Course::create(['title' => $request->get('title'), 'description' => $request->get('description'), 'value' => $request->get('value'), 'teacher_id' => $teacher_id]); return $this->createSuccessResponse("The course with id {$course->id} has been created and associated with the teacher with id {$teacher->id}", 201); } return $this->createErrorResponse("The teacher with id {$teacher_id} does not exists", 404); }
/** * Run the database seeds. * * @return void */ public function run() { // DB::table('courses')->delete(); $courses = array('Mathematics', 'English', 'Physics', 'Chemistry', 'Biology', 'Further Mathematics', 'Geography', 'Physical Education', 'Literature', 'History', 'Government', 'Fine Arts', 'Social Science', 'Integrated Science', 'Introduction Tecnology', 'Technical Drawing', 'Computer Science'); $grades = array('JS 1', 'JS 2', 'JS 3', 'SS 1', 'SS 2', 'SS 3', 'A Levels'); for ($c = 0; $c < count($courses); $c++) { Course::create(array('course_name' => $courses[$c])); } }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store() { if ($user = Sentinel::check()) { $input = Request::all(); Course::create($input); return redirect('/'); } else { return redirect('/'); } }
public function store(Request $request) { $rules = ['name' => 'required|unique:grades|min:4|max:255', 'description' => 'min:4|max:255']; $messages = ['name.required' => 'Es necesario definir un nombre.', 'name.unique' => 'Los cursos deben tener un nombre único.', 'name.min' => 'Ingrese un nombre adecuado.', 'description.min' => 'Ingrese una descripción adecuada.']; $v = Validator::make($request->all(), $rules, $messages); if ($v->fails()) { return back()->withErrors($v)->withInput(); } Course::create($request->all()); return back()->with('success', 'Curso registrado exitosamente.'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(CoursesRequest $request) { $course = Course::create($request->all()); $pathToCourse = storage_path() . '/courses/'; echo $pathToCourse; if (!File::isDirectory($pathToCourse)) { File::makeDirectory($pathToCourse); } File::makeDirectory($pathToCourse . $course->slug); $course->path_to_material = $pathToCourse . $course->slug; $course->save(); return redirect('courses'); }
public function postStore() { if (Request::ajax()) { $inputData = Input::all(); $hasExisting = Course::where('name', $inputData['name'])->get(); if (count($hasExisting) < 1) { $newRecord = Course::create($inputData); return $newRecord; } else { return 0; } } }
public function run() { Course::create(['id' => 1, 'name' => 'Cálculo diferencial']); Course::create(['id' => 3, 'name' => 'Física mecánica']); Course::create(['id' => 4, 'name' => 'Cátedra Francisco José de Caldas']); Course::create(['id' => 7, 'name' => 'Cálculo intetegral']); Course::create(['id' => 9, 'name' => 'Algebra lineal']); Course::create(['id' => 13, 'name' => 'Física II: electromagentismo']); Course::create(['id' => 88, 'name' => 'Ecuaciones diferenciales']); Course::create(['id' => 1054, 'name' => 'Producción y comprensión de textos I']); Course::create(['id' => 1056, 'name' => 'Producción y comprensión de textos II']); Course::create(['id' => 1060, 'name' => 'Ciencia tecnología y sociedad']); Course::create(['id' => 1072, 'name' => 'Administración ']); Course::create(['id' => 1075, 'name' => 'Ética y sociedad']); Course::create(['id' => 1213, 'name' => 'Lenguaje de programació']); Course::create(['id' => 1330, 'name' => 'Aplicaciones computacionales']); Course::create(['id' => 1503, 'name' => 'Contabilidad general']); Course::create(['id' => 1507, 'name' => 'Introducción a algoritmos']); Course::create(['id' => 1508, 'name' => 'Lógica matemática']); Course::create(['id' => 1509, 'name' => 'Fundamentos de organización ']); Course::create(['id' => 1510, 'name' => 'Fundamentos de economía']); Course::create(['id' => 1511, 'name' => 'TIC\'s en las organizaciones']); Course::create(['id' => 1512, 'name' => 'Matemáticas especiales']); Course::create(['id' => 1513, 'name' => 'Estructuras de datos']); Course::create(['id' => 1514, 'name' => 'Progración orientada a objetos']); Course::create(['id' => 1515, 'name' => 'Análisis y métodos numéricos']); Course::create(['id' => 1518, 'name' => 'Programación multimnivel']); Course::create(['id' => 1519, 'name' => 'Bases de datos']); Course::create(['id' => 1524, 'name' => 'Programación avanzada']); Course::create(['id' => 1525, 'name' => 'Bases de datos avanzadas']); Course::create(['id' => 1526, 'name' => 'Diseño lógico']); Course::create(['id' => 1531, 'name' => 'Análisis de sistemas']); Course::create(['id' => 1532, 'name' => 'Inteligencia artificial']); Course::create(['id' => 1533, 'name' => 'Sistemas operacionales']); Course::create(['id' => 1534, 'name' => 'Electiva socio humanística I']); Course::create(['id' => 1535, 'name' => 'Transmisión de datos']); Course::create(['id' => 1536, 'name' => 'Programación web']); Course::create(['id' => 1537, 'name' => 'Taller de investigació']); Course::create(['id' => 1538, 'name' => 'Ingeniería de software']); Course::create(['id' => 1539, 'name' => 'Arquitectura de computadores']); Course::create(['id' => 1540, 'name' => 'Globalizació']); Course::create(['id' => 1541, 'name' => 'Fundamentos de telemática']); Course::create(['id' => 1542, 'name' => 'Programación por componentes']); Course::create(['id' => 1670, 'name' => 'Trabajo de grado I']); Course::create(['id' => 7202, 'name' => 'Aplicaciones para internet']); Course::create(['id' => 7213, 'name' => 'Teoría de la informació']); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { // validate // read more on validation at http://laravel.com/docs/validation $rules = array('course_code' => 'required|numeric|unique:courses,course_code', 'course_name' => 'required', 'course_type' => 'required'); $input = $request->all(); $validator = Validator::make($input, $rules); // process the login if ($validator->fails()) { return redirect('courses/create')->withErrors($validator)->withInput($input); } else { // store $course = Course::create($input); // redirect Session::flash('message', 'Successfully created course'); return redirect('courses'); } }
/** * Add a new course * * @param Request $request * @return mixed */ public function addCourse(Request $request) { $this->validate($request, ['courseCode' => 'required|unique:courses', 'courseName' => 'required', 'semNo' => 'required|numeric|min:1', 'lectures' => 'required|numeric|min:0', 'tutorials' => 'required|numeric|min:0', 'practicals' => 'required|numeric|min:0', 'credits' => 'required|numeric|min:1'], ['unique' => 'This course is already present in the database']); if ($request->has('departmentElective') && $request->has('openElective')) { return redirect()->back()->with('errors', 'A course can not be an open and department elective at same time'); } else { if ($request->has('departmentElective')) { $departmentElective = true; } else { $departmentElective = false; } if ($request->has('openElective')) { $openElective = true; } else { $openElective = false; } } $course = ['courseCode' => $request['courseCode'], 'dCode' => Auth::guard('departmentStaff')->user()->dCode, 'courseName' => $request['courseName'], 'openElective' => $openElective, 'departmentElective' => $departmentElective, 'semNo' => $request['semNo'], 'lectures' => $request['lectures'], 'tutorials' => $request['tutorials'], 'practicals' => $request['practicals'], 'credits' => $request['credits']]; // Save the course Course::create($course); return redirect()->back()->with('status', 'Success'); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); // $this->call(UserTableSeeder::class); // $this->call(ClassTableSeeder::class); //Optional just to clear table // DB::table('answers')->delete(); // DB::table('questions')->delete(); // DB::table('classes')->delete(); // DB::table('users')->delete(); $student1 = User::create(['name' => 'Scotty Gomez', 'email' => str_random(2) . '@gmail.com', 'password' => bcrypt('secret'), 'type' => 'student']); $student2 = User::create(['name' => 'Misha Dowd', 'email' => str_random(2) . '@gmail.com', 'password' => bcrypt('secret'), 'type' => 'student']); $lecturer = User::create(['name' => 'Dr. Andre Chen', 'email' => str_random(2) . '@gmail.com', 'password' => bcrypt('secret'), 'type' => 'lecturer']); $this->command->info('User Created!'); $course = Course::create(['name' => 'Math', 'term' => 'Fall2020', 'lecturer_id' => $lecturer->id]); $this->command->info('Course Created!'); $quiz = Quiz::create(['course_id' => $course->id, 'description' => 'A Quiz to Test Your Might!', 'quizTime' => '20', 'startDate' => '10.29.2015', 'endDate' => '10.30.2015']); $this->command->info('Quiz Created!'); //Questions $q = Question::create(['prompt' => 'What is the sqare root of 4?', 'difficulty' => 'easy']); $q1 = Question::create(['prompt' => 'What is 2 X 3?', 'difficulty' => 'easy']); $this->command->info('2 Questions Created!'); //Answers $a = Answer::create(['text' => '6', 'image' => NULL]); $a1 = Answer::create(['text' => '2', 'image' => NULL]); $a2 = Answer::create(['text' => '6', 'image' => NULL]); $a11 = Answer::create(['text' => '5', 'image' => NULL]); $this->command->info('All 4 Answers Created!'); // Adding User to Course $course->users()->sync([$student1->id, $student2->id]); // Syncing Quiz to Questions $quiz->questions()->sync([$q->id, $q1->id]); // Syncing (Binding Qustion to Answer) $q->answers()->sync([$a->id, $a1->id]); $q1->answers()->sync([$a2->id, $a11->id]); $this->command->info('Everything Created and Linked!'); Model::reguard(); }
public function run() { // non-NSCC $python1 = Course::create(['code' => 'PYTHON I', 'name' => 'Intro to Interactive Programming in Python', 'alias' => 'python1', 'importance' => 3, 'grade' => 97.2, 'completion_date' => '2013-11-19', 'topic_list' => 'Python Language, CokeSkulptor site, Objects, GUI Libraries, Game Mechanics', 'description' => "This is an online course from Rice University offered by Coursera.org. The course teaches Python from scratch in an online editor you can find at CodeSkulptor.org."]); $python2 = Course::create(['code' => 'PYTHON II', 'name' => 'Principles of Computing (in Python)', 'alias' => 'python2', 'importance' => 6, 'grade' => 100.0, 'completion_date' => '2014-04-19', 'topic_list' => 'Python Language, Game Algorithms, MiniMax method, Breadth vs Depth First Search', 'description' => "A second online course in Python from Rice University, via Coursera.org. This course got deeper into some heavy computing, creating AI game opponents that search game trees, etc."]); $bachelors = Course::create(['code' => 'BSc Mathematics', 'name' => 'Bachelors Degree from University of Saskatchewan', 'alias' => 'bachelors', 'importance' => 3, 'completion_date' => '2000-04-30', 'topic_list' => 'Advanced Linear Algebra, Multivariate Calculus, Statistics Survey, Galois Theory, Mathematical Induction', 'description' => "I have a 4 year Bachelors Degree from the University of Saskatchewan, majoring in Mathematics. This education gave me my foundation in general numeracy and logic that I find so helpful in day-to-day software development, and layed the groundwork for my subsequent Masters Degree."]); $masters = Course::create(['code' => 'MPMath', 'name' => 'Masters Degree - Pure Math Dept at University of Waterloo', 'alias' => 'masters', 'importance' => 8, 'completion_date' => '2003-04-30', 'topic_list' => 'Mathematical Logic, Combinatorics and Large Number Factoring, Algorithm Analysis, Graph Theory, Axiomatization Normalization and Decidability', 'description' => "My two year Masters was at the Pure Mathematics dept of Canada's best Math school the University of Waterloo. During my degree I touched on some topics of direct interest in Computer Science, such as Cryptography and large data-set analysis. However, my work focussed on very abstract logical structures, which gives me facility (and even affection) for algorithmic techniques like Recursion, Weighted Randomization, Asymptotic or Linear Approach, Parametrization, etc. Though I chose to leave academic mathematics after this degree, I finished it with Distinction, and I'm able to use skills learned there as a resource."]); // year 1, term 1: $web = Course::create(['code' => 'WEBD 1000', 'name' => 'Website Development', 'alias' => 'web', 'importance' => 0, 'grade' => 98.0, 'completion_date' => '2014-12-19', 'topic_list' => 'XML, HTML 5, CSS 3, Web Layout Best Practices, Javascript Snippets', 'description' => "This was my introductory web-coding course, where we learned to write Static Web Sites in HTML and CSS. We investigated some frameworks, but primarily created projects for this class from scratch."]); $network = Course::create(['code' => 'NETW 1100', 'name' => 'Introduction to Networking', 'alias' => 'network', 'importance' => 0, 'grade' => 100.0, 'completion_date' => '2014-12-19', 'topic_list' => 'OSI Model, TCP/IP, IPv4 and IPv6, Network Architecture', 'description' => "This course provided a solid introduction to Networking concepts, and rough familiarity with the common protocols in common use."]); $dbIntro = Course::create(['code' => 'DBAS 1001', 'name' => 'Introduction to Databases', 'alias' => 'dbIntro', 'importance' => 0, 'grade' => 99.0, 'completion_date' => '2014-12-19', 'topic_list' => 'Relational Databases, Toad Data Modeler, MS Access, Database Design', 'description' => "In this Introductory Database course, I learned the fundamentals of relational databases and database design. The course included use of VMWare, Toad Data Modeler, and MS Access."]); // year 1, term 2: $design = Course::create(['code' => 'APPD 1001', 'name' => 'User Interface Design', 'alias' => 'design', 'importance' => 0, 'grade' => 99.0, 'completion_date' => '2015-04-30', 'topic_list' => 'UI Best Practices, Mobile UI, Navigation Hierarchies, Adobe Products, Interface Testing', 'description' => "In this course I learned to design interfaces for functional as well as visual appeal. We investigated functional layout of existing applications and looked at alternatives that may be preferred by users."]); $db = Course::create(['code' => 'DBAS 1100', 'name' => 'Database Development', 'alias' => 'db', 'importance' => 5, 'grade' => 100.0, 'completion_date' => '2015-04-30', 'topic_list' => 'Scripting and Querying, Entity Relationships, SQL functions, Inner/Outer Joins, Scalable Design', 'description' => "In this course I learned how to design an Efficient, Scalable database. We learned to query easy-to-read information from across multiple tables using Joins and SQL functions."]); $linux = Course::create(['code' => 'OSYS 1000', 'name' => 'Operating Systems: Unix/Linux', 'alias' => 'linux', 'importance' => 2, 'grade' => 100.0, 'completion_date' => '2015-04-30', 'topic_list' => 'Installation Hierarchy, Shell Commands, Package Management, Scripting, VI/VIM Editor, Virtualization, Linux Networking', 'description' => "This course introduced me the linux family of operating systems. I learned 'day-to-day' use and some scripting to handle large file structures. I also became familiar with the VIM text editor, and a small amount of Perl scripting."]); $oopIntro = Course::create(['code' => 'PROG 1400', 'name' => 'Intro to Object Oriented Programming', 'alias' => 'oopIntro', 'importance' => 0, 'grade' => 99.0, 'completion_date' => '2015-04-30', 'topic_list' => 'Object Inheritance, Abstraction, Polymorphism, Overrides and Implementation, Java Swing Applications', 'description' => "In this course we used Eclipse to create Java Swing applications making use of Object Oriented Programming. Two notable projects were a screensaver implementing collision detection and smooth motion, and a combat simulation game with objects representing combatants and weapons of various sorts."]); $saad = Course::create(['code' => 'SAAD 1001', 'name' => 'System Analysis and Design', 'alias' => 'saad', 'importance' => 2, 'grade' => 97.0, 'completion_date' => '2015-04-30', 'topic_list' => 'Unified Modeling Language, Software Development Lifecycle, Use Cases, Test Cases, Sequence Diagrams, Class Diagrams', 'description' => "In this course I learned the Unified Modeling Language suite of documents, including testing docs, use cases, and class and sequence diagrams. Agile methodologies and scrum were touched on."]); // year 2, term 1: $android = Course::create(['code' => 'APPD 2000', 'name' => 'Android Application Development', 'alias' => 'android', 'importance' => 4, 'grade' => 97.0, 'completion_date' => '2015-12-18', 'topic_list' => 'Mobile Interface Design, Activities and Intents, Data Persistence, SQLite, SDK Considerations', 'description' => "I learned to create simple Android Apps using the Android Studio IDE. Coding in Java, we covered the Activity Lifecycle, Intents, Library Widgets, and Fragments. Several working Apps were created, runnable both on device emulators and various physical devices."]); $php = Course::create(['code' => 'INET 2005', 'name' => 'Web Application Development', 'alias' => 'php', 'importance' => 7, 'grade' => 100.0, 'completion_date' => '2015-12-18', 'topic_list' => 'Php language, Php Frameworks (Laravel), Restful Architecture, Secure Login, MVC Architecture, N-tier Architecture, Ajax', 'description' => "I learned all the necessary pieces to create working Php Web Applications either from scratch or using a framework. CRUD apps were a focus, and the final project was the creation of a full Content Management System with administrative Web-interface for backend work."]); $management = Course::create(['code' => 'INFT 2100', 'name' => 'Project Management', 'alias' => 'management', 'importance' => 3, 'grade' => 100.0, 'completion_date' => '2015-12-18', 'topic_list' => 'Agile Workflows, Scrum, Version Control, UML Documentation, Risk Management, Estimation, MS Project', 'description' => "In Project Management I learned common practices and workflows for working on larger project in Information Technology. The course included research and applying learned techniques to school projects."]); $cplus = Course::create(['code' => 'PROG 2100', 'name' => 'Programming C++', 'alias' => 'cplus', 'importance' => 6, 'grade' => 99.0, 'completion_date' => '2015-12-18', 'topic_list' => 'C++ Language, Memory Management, Efficient Computation, Minimax Algorithm', 'description' => "In the C++ course I learned the principles of Memory Management, how to apply Destructors/Copy Constructors/Assignment Overrides to catch Memory Leaks, and how to use poiters to cut down on unnecessary duplication of objects. The assignments included some Algorithm design, and the Minimax Strategy for turn based games."]); $j2ee = Course::create(['code' => 'WEBD 3102', 'name' => 'J2EE: Java Web Applications', 'alias' => 'j2ee', 'importance' => 5, 'grade' => 100.0, 'completion_date' => '2015-12-18', 'topic_list' => 'Apache Servers, Eclipse Mars, Servlets and Filters, .jsp Files, Tag Libraries, Concurrency', 'description' => "In this course, I learned the building blocks of a Java Web Application, and how to apply them to an Apache server from the Eclipse Mars IDE. Topics included backend Java Models, Servlet Controllers, Filters, .jsp Views, and Session vs Request Lifecycle."]); //////////////////////////////////// // Associate skills with each course //////////////////////////////////// $skills = Skill::lists('id', 'alias'); $python1->skills()->attach([$skills['python'], $skills['math'], $skills['algorithm']]); $python2->skills()->attach([$skills['python'], $skills['math'], $skills['algorithm']]); $android->skills()->attach([$skills['java'], $skills['android'], $skills['sqlite'], $skills['ui']]); $php->skills()->attach([$skills['php'], $skills['laravel'], $skills['js'], $skills['database'], $skills['git'], $skills['mvc'], $skills['phpstorm'], $skills['bash'], $skills['ajax']]); $management->skills()->attach([$skills['agile'], $skills['scrum'], $skills['uml'], $skills['office'], $skills['comm'], $skills['elearn']]); $cplus->skills()->attach([$skills['cplus'], $skills['vstudio'], $skills['algorithm'], $skills['oop'], $skills['uml'], $skills['elearn']]); $j2ee->skills()->attach([$skills['j2ee'], $skills['java'], $skills['eclipse'], $skills['mvc'], $skills['elearn']]); $design->skills()->attach([$skills['ui'], $skills['comm'], $skills['css']]); $db->skills()->attach([$skills['database'], $skills['sql'], $skills['mysql'], $skills['vmware']]); $linux->skills()->attach([$skills['bash'], $skills['vim'], $skills['putty']]); $oopIntro->skills()->attach([$skills['oop'], $skills['java'], $skills['eclipse'], $skills['algorithm'], $skills['math']]); $saad->skills()->attach([$skills['uml'], $skills['office'], $skills['agile'], $skills['scrum'], $skills['algorithm']]); $web->skills()->attach([$skills['html'], $skills['css'], $skills['js']]); $network->skills()->attach([$skills['elearn'], $skills['math'], $skills['algorithm']]); $dbIntro->skills()->attach([$skills['office'], $skills['algorithm'], $skills['vmware']]); $bachelors->skills()->attach([$skills['math'], $skills['algorithm'], $skills['comm']]); $masters->skills()->attach([$skills['math'], $skills['algorithm'], $skills['comm']]); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { Course::create($request->all()); return redirect()->route('courses.index')->with('message', 'Item created successfully.'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $course = Course::create($request->all()); return redirect()->route('courses.index')->with('flash', ['level' => 'success', 'message' => 'Added "' . $course->name . '".']); }
/** * Store a csv created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function import(Request $request) { if ($request->file('csv-file')->isValid()) { $csv_file = $request->file('csv-file'); if ("text/csv" == $csv_file->getClientMimeType()) { $dest_path = storage_path('temp'); $file_name = time() . '_' . str_replace(" ", "_", $csv_file->getClientOriginalName()); $csv_file->move($dest_path, $file_name); $fname = $dest_path . '/' . $file_name; $file = fopen($fname, "r"); $flash_message = []; $flash_error = 0; while (!feof($file)) { $tmp_data = fgetcsv($file); $item['department_id'] = !empty($tmp_data[0]) ? $tmp_data[0] : ''; $department = Department::where('code', '=', $item['department_id'])->first(); if ($department) { $item['department_id'] = $department->id; } $item['code'] = !empty($tmp_data[1]) ? $tmp_data[1] : ''; $item['name'] = !empty($tmp_data[2]) ? $tmp_data[2] : ''; $item['description'] = !empty($tmp_data[3]) ? $tmp_data[3] : ''; $v = Validator::make($item, ['department_id' => 'required|integer|min:1', 'code' => 'required|unique:courses|max:20', 'name' => 'required|max:254']); if (!$v->fails()) { Course::create($item); $flash_message['success'][] = '[' . $item['code'] . '] ' . $item['name']; } else { $flash_error++; $flash_message['error'] = $flash_error; } } \Session::flash('flash_message', $flash_message); fclose($file); chmod($fname, 0777); unlink($fname); } } return redirect('/courses'); }
/** * Run the database seeds. * * @return void */ public function run() { Course::create(['name' => 'Matemáticas', 'description' => 'Curso de matemáticas básicas.']); }
public function store(RegisterCourse $request) { Course::create($request->all()); }
/** * Run the migrations. * * @return void */ public function up() { // Create departement : "autre" Department::create(['name' => 'Autre', 'short_name' => 'PeiP']); // Create departement : DI Department::create(['name' => 'Département Informatique', 'short_name' => 'DI']); // Create departement : DMS Department::create(['name' => 'Département Mécanique', 'short_name' => 'DMS']); // Create user : Admin (lvl 3) User::create(['first_name' => 'Admin', 'last_name' => 'Admin', 'email' => 'admin@admin', 'school_year' => 0, 'department_id' => 1, 'password' => bcrypt('admincmt'), 'level_id' => 4, 'slug' => 'admin-admin-2']); // Create user : Teacher (lvl 2) User::create(['first_name' => 'Teacher', 'last_name' => 'Teacher', 'email' => 'teacher@teacher', 'school_year' => 0, 'department_id' => 1, 'password' => bcrypt('teachercmt'), 'level_id' => 3, 'slug' => 'teacher-teacher-3']); // Create user : band_creator (lvl 1) User::create(['first_name' => 'Band', 'last_name' => 'Creator', 'email' => 'band@creator', 'school_year' => 0, 'department_id' => 1, 'password' => bcrypt('membercmt'), 'level_id' => 2, 'slug' => 'band-creator-5,']); // Create user : Member (lvl 0) User::create(['first_name' => 'Member', 'last_name' => 'Member', 'email' => 'member@member', 'school_year' => 0, 'department_id' => 1, 'password' => bcrypt('membercmt'), 'level_id' => 1, 'slug' => 'member-member-4']); // Create Article 'Cours de guitare' Article::create(['title' => 'Cours de guitare', 'subtitle' => 'Article concernant le cours de guitare', 'content' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam purus tortor, efficitur ut iaculis ut, tincidunt vel elit. Morbi malesuada ipsum eu fermentum consequat. Duis aliquam, massa et bibendum facilisis, nulla nibh ultricies ante, a rutrum augue tellus quis erat. Curabitur aliquam ipsum gravida, interdum mauris non, blandit justo. Donec non mollis orci, a accumsan ligula. Nullam quis sapien elementum neque egestas lacinia</p>', 'user_id' => 2, 'slug' => 'cours-de-guitare-1', 'category_id' => 3, 'validated' => 1]); // Create Article 'Cours de piano' Article::create(['title' => 'Cours de piano', 'subtitle' => 'Article concernant le cours de piano', 'content' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam purus tortor, efficitur ut iaculis ut, tincidunt vel elit. Morbi malesuada ipsum eu fermentum consequat. Duis aliquam, massa et bibendum facilisis, nulla nibh ultricies ante, a rutrum augue tellus quis erat. Curabitur aliquam ipsum gravida, interdum mauris non, blandit justo. Donec non mollis orci, a accumsan ligula. Nullam quis sapien elementum neque egestas lacinia</p>', 'user_id' => 3, 'slug' => 'cours-de-piano-2', 'category_id' => 3, 'validated' => 1]); // Create guitar course Course::create(['name' => 'Cours de guitare', 'day' => 1, 'start' => '18:30:00', 'end' => '20:00:00', 'infos' => 'Cours de guitare du lundi soir.', 'slug' => 'cours-de-guitare-lundi-1', 'instrument_id' => 2, 'article_id' => 1, 'user_id' => 2]); // Create piano course Course::create(['name' => 'Cours de piano', 'day' => 3, 'start' => '18:30:00', 'end' => '20:00:00', 'infos' => 'Cours de piano du mardi soir.', 'slug' => 'cours-de-piano-mardi-2', 'instrument_id' => 3, 'article_id' => 2, 'user_id' => 3]); // Create Band 'The Band' Band::create(['name' => 'The Band', 'infos' => 'premier groupe de test', 'user_id' => 1, 'validated' => 1, 'slug' => 'the-band-1', 'article_id' => 2]); // Create band 'Second Band' Band::create(['name' => 'Second Band', 'infos' => 'deuxieme groupe de test', 'user_id' => 2, 'validated' => 1, 'slug' => 'second-band-2', 'article_id' => 1]); // Create News 'test news' News::create(['title' => 'test news', 'content' => '<p>Contenu de la première news de test</p>', 'user_id' => 1, 'slug' => 'test-news-1']); // Create News 'test second news' News::create(['title' => 'test seconde news', 'content' => '<p>Contenu de la deuxieme news de test</p>', 'user_id' => 2, 'slug' => 'test-seconde-news-1']); // Create announcement 'test d'une annonce' Announcement::create(['user_id' => 1, 'title' => 'test d\'une annonce', 'slug' => 'test-annonce-1', 'validated' => 1, 'subject' => 'Annonce pour tester', 'category_id' => 1, 'content' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque in malesuada leo. Suspendisse ut dapibus urna. Nunc mattis velit vel varius luctus. Fusce ornare arcu nec odio egestas, et lacinia sapien laoreet. Maecenas odio dui, fringilla non sapien euismod, volutpat porta sapien. Suspendisse mauris quam, maximus quis tempus non, feugiat in tellus. Sed non quam aliquet, sollicitudin risus nec, mollis turpis. Donec interdum tincidunt efficitur. Nam efficitur enim a leo pellentesque, venenatis sollicitudin lacus suscipit. Ut eu nunc eget lacus vehicula gravida. Fusce vitae ante bibendum, maximus nisl quis, lacinia metus. In pharetra placerat lacus, sed fringilla ex imperdiet vel. Nulla mollis risus tellus, a ultricies tellus tempor cursus. Quisque viverra nunc ipsum, a ullamcorper dui porttitor eu. Suspendisse nec nunc ut mi dignissim ultrices.</p> <p>In libero sem, dictum in venenatis sit amet, dictum id quam. Aliquam id ligula luctus, lobortis felis eget, sollicitudin nulla. Suspendisse tempus aliquet volutpat. Integer lacinia sem ac libero faucibus cursus. Morbi mauris massa, interdum vel placerat sit amet, rutrum eget turpis. Mauris convallis semper sem, eu pharetra tortor sagittis non. Praesent auctor justo nulla, in rhoncus ipsum porta ut. Mauris bibendum fringilla accumsan. Proin bibendum eros eros. Aliquam vulputate, nisi vitae tristique lacinia, leo risus volutpat augue, vel ultricies lorem urna vitae erat. Vestibulum varius, libero eget sollicitudin luctus, lacus massa molestie purus, quis blandit felis sem at dui.</p>']); // Create announcement 'test d'une seconde annonce' Announcement::create(['user_id' => 2, 'content' => '<p>contenu de la deuxieme annonce</p>', 'title' => 'test d\'une seconde annonce', 'slug' => 'test-seconde-annonce-2', 'validated' => 1, 'subject' => 'Deuxieme annonce pour tester', 'category_id' => 1]); // Create announcement unvalidated Announcement::create(['user_id' => 3, 'content' => '<p>azre</p>', 'title' => 'azr', 'slug' => 'test-annonce-invalidee-3', 'validated' => 0, 'subject' => 'Annonce invalidée pour tester', 'category_id' => 1]); // Create comment on announcement #1 Comment::create(['announcement_id' => 1, 'user_id' => 1, 'content' => '<p>Nam efficitur enim a leo pellentesque, venenatis sollicitudin lacus suscipit. Ut eu nunc eget lacus vehicula gravida. Fusce vitae ante bibendum, maximus nisl quis, lacinia metus. In pharetra placerat lacus, sed fringilla ex imperdiet vel. Nulla mollis risus tellus, a ultricies tellus tempor cursus. Quisque viverra nunc ipsum, a ullamcorper dui porttitor eu. Suspendisse nec nunc ut mi dignissim ultrices.</p> <p>In libero sem, dictum in venenatis sit amet, dictum id quam. Aliquam id ligula luctus, lobortis felis eget, sollicitudin nulla. Suspendisse tempus aliquet volutpat. Integer lacinia sem ac libero faucibus cursus.</p>']); // Create comment on announcement #1 Comment::create(['announcement_id' => 1, 'user_id' => 2, 'content' => '<p>In libero sem, dictum in venenatis sit amet, dictum id quam. Aliquam id ligula luctus, lobortis felis eget, sollicitudin nulla. Suspendisse tempus aliquet volutpat. Integer lacinia sem ac libero faucibus cursus.</p> <p>Nam efficitur enim a leo pellentesque, venenatis sollicitudin lacus suscipit. Ut eu nunc eget lacus vehicula gravida. Fusce vitae ante bibendum, maximus nisl quis, lacinia metus. In pharetra placerat lacus, sed fringilla ex imperdiet vel. Nulla mollis risus tellus, a ultricies tellus tempor cursus. Quisque viverra nunc ipsum, a ullamcorper dui porttitor eu. Suspendisse nec nunc ut mi dignissim ultrices.</p>']); // Create comment on announcement #2 Comment::create(['announcement_id' => 2, 'user_id' => 1, 'content' => '<p>commentaire annonce 2</p>']); // Create Article 'premier article' Article::create(['title' => 'premier article', 'subtitle' => 'test d\'un premier article', 'content' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam purus tortor, efficitur ut iaculis ut, tincidunt vel elit. Morbi malesuada ipsum eu fermentum consequat. Duis aliquam, massa et bibendum facilisis, nulla nibh ultricies ante, a rutrum augue tellus quis erat. Curabitur aliquam ipsum gravida, interdum mauris non, blandit justo. Donec non mollis orci, a accumsan ligula. Nullam quis sapien elementum neque egestas lacinia</p>', 'user_id' => 1, 'slug' => 'premier-article-3', 'category_id' => 2, 'validated' => 1]); // Create Article 'deuxieme article' Article::create(['title' => 'deuxieme article', 'subtitle' => 'test d\'un deuxieme article', 'content' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam purus tortor, efficitur ut iaculis ut, tincidunt vel elit. Morbi malesuada ipsum eu fermentum consequat. Duis aliquam, massa et bibendum facilisis, nulla nibh ultricies ante, a rutrum augue tellus quis erat. Curabitur aliquam ipsum gravida, interdum mauris non, blandit justo. Donec non mollis orci, a accumsan ligula. Nullam quis sapien elementum neque egestas lacinia</p>', 'user_id' => 2, 'slug' => 'deuxieme-article-4', 'category_id' => 1]); // Create Event 'concert de The Band' Event::create(['location' => '23 avenue de la Team Musique', 'day' => 6, 'start' => '18:00:00', 'end' => '00:00:00', 'infos' => 'infos du premier event', 'name' => 'Concert de The Band', 'slug' => 'concert-the-band', 'user_id' => 1, 'date' => '2016-03-27', 'article_id' => 1]); // Create Event 'concert de ouf' Event::create(['location' => '186 avenue de la Team Musique', 'day' => 5, 'start' => '17:00:00', 'end' => '23:00:00', 'infos' => 'infos du deuxieme event', 'name' => 'Concert de ouf', 'slug' => 'concert-de-ouf', 'user_id' => 2, 'date' => '2016-04-12', 'article_id' => 2]); // Associate Band 1 to Event 1 BandEvent::create(['band_id' => 1, 'event_id' => 1]); // Associate band 1 to event 2 BandEvent::create(['band_id' => 1, 'event_id' => 2]); // Associate band 2 to event 2 BandEvent::create(['band_id' => 2, 'event_id' => 2]); // Associate Members to Bands BandUser::create(['user_id' => 1, 'band_id' => 1, 'instrument_id' => 1]); BandUser::create(['user_id' => 2, 'band_id' => 1, 'instrument_id' => 2]); BandUser::create(['user_id' => 3, 'band_id' => 1, 'instrument_id' => 3]); BandUser::create(['user_id' => 2, 'band_id' => 2, 'instrument_id' => 5]); BandUser::create(['user_id' => 3, 'band_id' => 2, 'instrument_id' => 10]); // Associate Users to Courses as Students CourseUser::create(['user_id' => '1', 'course_id' => 1, 'validated' => 1, 'level' => 0]); CourseUser::create(['user_id' => '3', 'course_id' => 1, 'validated' => 1, 'level' => 0]); CourseUser::create(['user_id' => '1', 'course_id' => 2, 'validated' => 1, 'level' => 0]); CourseUser::create(['user_id' => '4', 'course_id' => 2, 'validated' => 0, 'level' => 0]); // Associate Users to Courses as Teachers CourseUser::create(['user_id' => '3', 'course_id' => 1, 'validated' => 1, 'level' => 1]); CourseUser::create(['user_id' => '2', 'course_id' => 1, 'validated' => 1, 'level' => 1]); CourseUser::create(['user_id' => '2', 'course_id' => 2, 'validated' => 1, 'level' => 1]); CourseUser::create(['user_id' => '4', 'course_id' => 1, 'validated' => 0, 'level' => 1]); // Course Modification tests CourseModification::create(['author_id' => 1, 'user_id' => 1, 'course_id' => 1, 'value' => 0]); CourseModification::create(['author_id' => 2, 'user_id' => 2, 'course_id' => 1, 'value' => 1]); CourseModification::create(['author_id' => 1, 'user_id' => 3, 'course_id' => 2, 'value' => 2]); CourseModification::create(['author_id' => 3, 'user_id' => 2, 'course_id' => 2, 'value' => 3]); }
/** * Add a new course * * @param Request $request * @return mixed */ public function addCourse(Request $request) { $this->validate($request, ['courseCode' => 'required|unique:courses', 'courseName' => 'required']); $course = ['courseCode' => $request['courseCode'], 'dCode' => $request['dCode'], 'courseName' => $request['courseName']]; // Save the course Course::create($course); return redirect()->back()->with('status', 'success'); }
public function add_course(Request $request) { $validator = $this->course_validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } $inst_id = Institution::where('admin_id', \Auth::user()->id)->first()->id; $categ_id = CourseCategory::where('categ_name', $request->category)->first()->id; $course = Course::create(['course_name' => $request->name, 'course_description' => $request->description, 'course_image' => $request->image, 'prof_id' => $request->professor, 'category_id' => $categ_id, 'inst_id' => $inst_id]); $imageName = "course_" . $course->id . '.' . Input::file('image')->getClientOriginalExtension(); Input::file('image')->move(base_path() . '/public/images/course/', $imageName); $course->course_image = $imageName; $course->save(); return redirect('institution/courses')->with('status', 'You have successfully added a course!'); }