我有一个索引页面,其中显示了所有模型,当您单击编辑时,您将转到编辑页面,在您更改某些内容后,您单击更新,您将被重定向到索引,一切都很好。
现在我已经制作了一个展示视图,在展示视图中我创建了相同的编辑按钮进入编辑页面,当您点击更新时,您将被重定向到索引页面,我不希望这样。我想将用户重定向到点击EDIT按钮的页面。
如何将用户重定向到他们实际点击编辑按钮的页面?
答案 0 :(得分:2)
您可以将会话中的网址保持为go two pages back in Laravel:
$links = session->has('links') ? session('links') : []; // Get data from session
array_unshift($links, $_SERVER['REQUEST_URI']); // Add current URI to an array
session(compact('links')); // Save an array to session
然后你可以回2页:
return redirect(session('links')[2]);
答案 1 :(得分:0)
您可以使用:
describe('Logging in', function()
{
beforeEach(angular.mock.module('corpusRoom'));
var ctrl, $scope, mockHttp, room, roomStateService;
beforeEach(function () {
room = 'mockRoom';
uid = 'fakeuid';
roomStateService =
{
roomName: function () {
return 'fakeRoom';
}
}
angular.mock.module(function ($provide) {
$provide.value('room', room);
$provide.value('uid', uid);
$provide.value('RoomStateService', roomStateService);
});
});
describe('Login controller', function () {
var loginService, $q;
beforeEach(inject(function($controller, $rootScope, _$route_, LoginService, _$q_, $httpBackend, RoomStateService)
{
$q = _$q_
loginService = LoginService;
roomStateService = RoomStateService;
mockHttp = $httpBackend;
$scope = $rootScope.$new();
mockHttp.whenGET('app/room/room.html').respond(200);
mockHttp.whenGET('app/other/notFound.html').respond(200);
ctrl = $controller('LoginController', {
LoginService: loginService,
RoomStateService: roomStateService
});
}));
it('should log out the user if already logged in', function (done) {
var deferredLoginStatus = $q.defer();
spyOn(loginService, 'loginStatus').and.returnValue(deferredLoginStatus);
spyOn(loginService, 'logout');
deferredLoginStatus.resolve({ isLoggedIn: true});
$scope.$apply();
expect(loginService.logout).toHaveBeenCalledTimes(1);
done();
})
});
});
它让你回归,因为它是如此明显。你可以在这里研究这个和其他帮助函数: