/**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $model = $this->chung_loai->find($id);
     Logfileadmin::addData("Xóa", "Chủng Loại", $model->id, $model->tenchungloai);
     $this->chung_loai->find($id)->delete();
     return Redirect::route('chung_loais.index');
 }
 public function postChungloaisp()
 {
     if (Chung_loai::where('tenchungloai', '=', Input::get('tenchungloai'))->count() > 0) {
         return "false";
     } else {
         return "true";
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $chungloai = Chung_loai::get();
     $hang = Hang::get();
     $input = array_except(Input::all(), '_method');
     $validation = Validator::make($input, Loai::$rules);
     if ($validation->passes()) {
         $loai = $this->loai->find($id);
         //lay thong tin cu
         $oldinfo = Loai::where('id', '=', $loai->id)->get()->toArray();
         Logfileadmin::addData("Sửa", "Loại", $loai->id, Input::get('tenloai'), $oldinfo);
         $loai->update($input);
         return Redirect::route('loais.show', $id);
     }
     return Redirect::route('loais.edit', $id)->withInput()->withErrors($validation)->with('message', 'There were validation errors.')->with('chungloai', $chungloai)->with('hang', $hang);
 }
Example #4
0
    Route::get("logfile", function () {
        $logs = Logfileadmin::orderBy("created_at", "desc")->paginate(15);
        return View::make('logfile.logfile')->with('logs', $logs);
    });
});
Route::group(array("before" => "checkUser"), function () {
    Route::controller('dat_hang', 'DondathangController');
    Route::controller('nhap', 'NhapController');
    Route::controller('sanpham', 'SanphamController');
    Route::controller('gia', 'GiaController');
    Route::resource('hangs', 'HangsController');
    Route::resource('chung_loais', 'Chung_loaisController');
    Route::resource('nguoi_dungs', 'Nguoi_dungsController');
    Route::resource('loais', 'LoaisController');
    Route::resource('trangthais', 'TrangthaisController');
    Route::resource('vanchuyens', 'VanchuyensController');
});
Route::controller('check', 'CheckController');
//*****************************************************************************************************************88
//* Đăng Ký ********************************************************************************************
Route::controller('users', 'UsersController');
/************************************************************************************************/
// User *******************************************************************************************************
Route::get("/", function () {
    $chungloai = Chung_loai::all();
    $loai = Loai::all();
    $spHightView = DB::table('giaapdung')->orderBy('luotxem', 'desc')->limit(2)->get();
    $sps = DB::table('giaapdung')->orderBy('id', 'desc')->limit(12)->get();
    $allsp = DB::table('giaapdung')->orderBy('id', 'desc')->paginate(12);
    return View::make('users/home')->with('chungloais', $chungloai)->with('loais', $loai)->with('spHightViews', $spHightView)->with('sps', $sps)->with('allsp', $allsp);
});
 public function getDoiMatkhau()
 {
     if (Session::has('taikhoan')) {
         $chungloai = Chung_loai::all();
         $loai = Loai::all();
         return View::make('users.changepass')->with('chungloais', $chungloai)->with('loais', $loai);
     } else {
         return Redirect::to('/');
     }
 }