public function getSuaSanpham($id)
 {
     $sanpham = Sanpham::find($id);
     $loais = Loai::get();
     if (is_null($sanpham)) {
         return Redirect::to('sanpham/xem-sanpham');
     } else {
         return View::make('sanpham.edit')->with('sp', $sanpham)->with('loais', $loais);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $sanpham = Sanpham::where('id_loai', '=', $id)->count();
     if ($sanpham > 0) {
         return Redirect::to('loais')->with('errorDelete', "Thất bại.Loại này đang tồn tại sản phẩm");
     }
     $model = $this->loai->find($id);
     Logfileadmin::addData("Xóa", "Loại", $model->id, $model->tenloai);
     $this->loai->find($id)->delete();
     return Redirect::route('loais.index');
 }
Example #3
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('/');
     }
 }