Exemplo n.º 1
0
 public function update()
 {
     $user = Auth::user();
     $request = Request::all();
     Fair::where('year', $request['year'])->update(array('name' => $request['name'], 'logo' => $request['logo']));
     $success = "成功修改" . $request['year'] . '年度的就業博覽會';
     return view('auth.fair_create', compact('user', 'success'));
 }
 public function index($year = null)
 {
     $user = Auth::user();
     if ($year == null) {
         $fairs = Fair::orderBy('year', 'desc')->first();
     } else {
         $fairs = Fair::where('year', $year)->first();
     }
     return view('auth.dashboard', compact('user', 'fairs'));
 }
Exemplo n.º 3
0
 public function store()
 {
     $user = Auth::user();
     $request = Request::all();
     if (!Fair::where('year', $request['year'])->get()->isEmpty()) {
         $same = Fair::where('year', $request['year'])->first();
         $error = '已經存在 ' . $same['year'] . ' 年度的就業博覽會:' . $same['name'];
         return view('auth.fair_create', compact('user', 'error'));
     }
     Fair::create($request);
     $success = "成功創建" . $request['year'] . '年度的就業博覽會:' . $request['name'];
     return view('auth.fair_create', compact('user', 'success'));
 }
Exemplo n.º 4
0
 public function store($year)
 {
     $fair = Fair::where('year', $year)->first();
     $posts = Post::where('fair_id', $fair['id'])->get();
     $request = Request::all();
     $store = Post::create($request);
     if ($store) {
         $success = "成功新增" . $request['title'] . '公告';
         return view('auth.post', compact('fair', 'posts', 'success'));
     } else {
         $error = '失敗';
         return view('auth.post', compact('fair', 'posts', 'error'));
     }
 }