Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use route function everywhere #1568

Merged
merged 11 commits into from
Jul 22, 2018
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function render($request, Exception $e)
// hopefully catches those pesky token expiries
// and send them back to login.
if ($e instanceof TokenMismatchException) {
return redirect('login');
return redirect()->route('login');
}

return parent::render($request, $e);
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/ActivitiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function store(ActivitiesRequest $request, Contact $contact)
// Log a journal entry
(new JournalEntry)->add($activity);

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.activities_add_success'));
}

Expand Down Expand Up @@ -141,7 +141,7 @@ public function update(ActivitiesRequest $request, Activity $activity, Contact $
$newContact->logEvent('activity', $activity->id, 'create');
}

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.activities_update_success'));
}

Expand All @@ -163,7 +163,7 @@ public function destroy(Activity $activity, Contact $contact)

$activity->delete();

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.activities_delete_success'));
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Auth/EmailChangeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function showLoginFormSpecial(Request $request)
->with('email', $user->email);
}

return redirect('/');
return redirect()->route('login');
}

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ protected function validateAndEmailChange(EmailChangeRequest $request)
*/
protected function sendChangedResponse($response)
{
return redirect('/')
return redirect()->route('login')
->with('status', trans($response));
}

Expand All @@ -115,7 +115,7 @@ protected function sendChangedResponse($response)
*/
protected function sendChangedFailedResponse($response)
{
return redirect('/')
return redirect()->route('login')
->withErrors(trans($response));
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function showLoginOrRegister()
{
$first = ! Account::hasAny();
if ($first) {
return redirect('/register');
return redirect()->route('register');
}

return $this->showLoginForm();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected function registered(Request $request, $user)

$this->guard()->login($user);

return redirect(route('login'));
return redirect()->route('login');
}
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/Validate2faController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function index(Request $request)
return redirect(urldecode($request->get('url')));
}

return redirect('/');
return redirect()->route('login');
}

public static function loginCallback()
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ComplianceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public function store(Request $request)
{
auth()->user()->acceptPolicy(\Request::ip());

return redirect('/dashboard');
return redirect()->route('dashboard.index');
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Contacts/CallsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function store(CallsRequest $request, Contact $contact)

$contact->updateLastCalledInfo($call);

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.calls_add_success'));
}

Expand All @@ -46,7 +46,7 @@ public function store(CallsRequest $request, Contact $contact)
public function destroy(Contact $contact, Call $call)
{
if ($contact->account_id != $call->account_id) {
return redirect('/people');
return redirect()->route('people.index');
}

$call->delete();
Expand All @@ -58,7 +58,7 @@ public function destroy(Contact $contact, Call $call)
$contact->save();
}

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.call_delete_success'));
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Contacts/DebtController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function store(DebtRequest $request, Contact $contact)

$contact->logEvent('debt', $debt->id, 'create');

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.debt_add_success'));
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public function update(DebtRequest $request, Contact $contact, Debt $debt)

$contact->logEvent('debt', $debt->id, 'update');

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.debt_edit_success'));
}

Expand All @@ -128,7 +128,7 @@ public function destroy(Contact $contact, Debt $debt)

$contact->events()->forObject($debt)->get()->each->delete();

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.debt_delete_success'));
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Contacts/GiftsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function store(GiftsRequest $request, Contact $contact)
{
$this->updateOrCreate($request, $contact);

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.gifts_add_success'));
}

Expand Down Expand Up @@ -120,7 +120,7 @@ public function update(GiftsRequest $request, Contact $contact, Gift $gift)
{
$this->updateOrCreate($request, $contact, $gift);

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.gifts_update_success'));
}

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Contacts/IntroductionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function update(IntroductionsRequest $request, Contact $contact)

$contact->logEvent('contact', $contact->id, 'update');

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.introductions_update_success'));
}

Expand All @@ -85,7 +85,7 @@ public function destroy(Contact $contact, Gift $gift)

$contact->events()->forObject($gift)->get()->each->delete();

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.gifts_delete_success'));
}
}
12 changes: 6 additions & 6 deletions app/Http/Controllers/Contacts/RelationshipsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function store(Request $request, Contact $contact)
$partner = Contact::findOrFail($request->get('existing_contact_id'));
$contact->setRelationship($partner, $request->get('relationship_type_id'));

return redirect('/people/'.$contact->id)
return redirect()->route('people.show', $contact)
->with('success', trans('people.relationship_form_add_success'));
}

Expand Down Expand Up @@ -158,7 +158,7 @@ public function store(Request $request, Contact $contact)
$partner->save();
}

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.relationship_form_add_success'));
}

Expand Down Expand Up @@ -288,7 +288,7 @@ public function update(Request $request, Contact $contact, Contact $otherContact
$otherContact->save();
}

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.relationship_form_add_success'));
}

Expand All @@ -302,11 +302,11 @@ public function update(Request $request, Contact $contact, Contact $otherContact
public function destroy(Contact $contact, Contact $otherContact)
{
if ($contact->account_id != auth()->user()->account_id) {
return redirect('/people/');
return redirect()->route('people.index');
}

if ($otherContact->account_id != auth()->user()->account_id) {
return redirect('/people/');
return redirect()->route('people.index');
}

$type = $contact->getRelationshipNatureWith($otherContact);
Expand All @@ -318,7 +318,7 @@ public function destroy(Contact $contact, Contact $otherContact)
$otherContact->deleteEverything();
}

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.relationship_form_deletion_success'));
}
}
12 changes: 5 additions & 7 deletions app/Http/Controllers/Contacts/RemindersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function store(RemindersRequest $request, Contact $contact)

$contact->logEvent('reminder', $reminder->id, 'create');

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.reminders_create_success'));
}

Expand Down Expand Up @@ -114,7 +114,7 @@ public function update(RemindersRequest $request, Contact $contact, Reminder $re

$contact->logEvent('reminder', $reminder->id, 'update');

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.reminders_update_success'));
}

Expand All @@ -124,20 +124,18 @@ public function update(RemindersRequest $request, Contact $contact, Reminder $re
* @param Reminder $reminder
* @return \Illuminate\Http\Response
*/
public function destroy(Contact $contact, $reminderId)
public function destroy(Contact $contact, Reminder $reminder)
{
$reminder = Reminder::findOrFail($reminderId);

if ($reminder->account_id != auth()->user()->account_id) {
return redirect('/people/');
return redirect()->route('people.index');
}

$reminder->purgeNotifications();
$reminder->delete();

$contact->events()->forObject($reminder)->get()->each->delete();

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.reminders_delete_success'));
}
}
10 changes: 5 additions & 5 deletions app/Http/Controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function show(Contact $contact)
// make sure we don't display a significant other if it's not set as a
// real contact
if ($contact->is_partial) {
return redirect('/people');
return redirect()->route('people.index');
}
$contact->load(['notes' => function ($query) {
$query->orderBy('updated_at', 'desc');
Expand Down Expand Up @@ -327,7 +327,7 @@ public function update(Request $request, Contact $contact)

$contact->updateGravatar();

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.information_edit_success'));
}

Expand All @@ -341,7 +341,7 @@ public function update(Request $request, Contact $contact)
public function delete(Request $request, Contact $contact)
{
if ($contact->account_id != auth()->user()->account_id) {
return redirect('/people/');
return redirect()->route('people.index');
}

Relationship::where('contact_is', $contact->id)->delete();
Expand Down Expand Up @@ -385,7 +385,7 @@ public function updateWork(Request $request, Contact $contact)

$contact->save();

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.work_edit_success'));
}

Expand Down Expand Up @@ -415,7 +415,7 @@ public function updateFoodPreferencies(Request $request, Contact $contact)

$contact->updateFoodPreferencies($food);

return redirect('/people/'.$contact->hashID())
return redirect()->route('people.show', $contact)
->with('success', trans('people.food_preferencies_add_success'));
}

Expand Down
Loading