/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request\PresentationRequest $request * @return \Illuminate\Http\Response */ public function store(PresentationRequest $request) { if (!current_conference()) { flash()->error("You can't create a presentation yet!"); return redirect(route('user.show')); } $fields = $request->all(); $students = $fields['student_name']; if (empty($students[0])) { flash()->error("At least one student is required!"); return back()->withInput(); } unset($fields['student_name']); $user = Auth::user(); $presentation = new Presentation($fields); $presentation->owner = $user->id; $presentation->conference_id = get_current_conference_id(); if ($user->is_admin()) { $presentation->status = "A"; } else { $presentation->status = "S"; } if ($presentation->save()) { $this->save_students($students, $presentation->id); flash()->success("Presentation saved."); } else { flash()->error("Presentation couldn't be saved"); } return redirect()->route('user.show'); }
function old(Request $request) { $id = $request['id']; if ($id == null) { $id = get_current_conference_id(); } $conferences = Conference::where('id', '<>', get_current_conference_id())->orderBy('id', 'desc')->get(); $chosen_conf = Conference::where('id', '=', $id)->first(); $presentations = Presentation::where('conference_id', '=', $id)->where('status', '=', 'A')->orderBy('course_id')->get(); return view('conferences.old', compact('conferences', 'chosen_conf', 'presentations')); }
function current_conference_published() { $id = get_current_conference_id(); $current_conference = Conference::find($id); return $current_conference->published; }
/** * Display the current user. * * @return \Illuminate\Http\Response */ public function show() { $user = Auth::user(); $presentations = $user->presentations()->where('conference_id', '=', get_current_conference_id())->orderBy('updated_at', 'desc')->get(); return view('user.show', compact('presentations')); }
public function preview() { $rooms = Room::where("available", true)->get(); $days = Timeslot::orderBy("id", 'desc')->first()->day; $presentations = Presentation::where('conference_id', '=', get_current_conference_id())->whereNotNull('timeslot')->get(); $timeslots = Timeslot::where('conference_id', '=', get_current_conference_id())->get(); return view('timeslots.preview', compact('timeslots', 'rooms', 'presentations', 'days')); }
/* |-------------------------------------------------------------------------- | 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]; }); $factory->defineAs(App\User::class, 'admin', function ($faker) use($factory) { $user = $factory->raw(App\User::class); $user['role'] = "admin"; return $user; }); $factory->defineAs(App\User::class, 'professor', function ($faker) use($factory) { $user = $factory->raw(App\User::class); $user['role'] = "professor"; return $user; }); $factory->defineAs(App\Presentation::class, 'student_presentation', function (Faker\Generator $faker) { $types = [1, 2, 3, 4, 5]; $courses = [1, 2, 3]; $status = ["S", "P"]; $our_nominee = [true, false]; $presentation = ['professor_name' => $faker->name, 'owner' => 3, 'course_id' => $courses[array_rand($courses)], 'title' => $faker->sentence, 'type' => $types[array_rand($types)], 'abstract' => $faker->text, 'special_notes' => $faker->text, 'status' => $status[array_rand($status)], 'our_nominee' => $our_nominee[array_rand($our_nominee)], 'conference_id' => get_current_conference_id()]; return $presentation; });