* Edit relation docblocks of Contact model * Move activities to its own controller * Move reminders to its own controller * Move tasks to its own controller * Refactor Gift in preparation for the move * Move gifts into its own controller * Fix failing tests * Move debt to its own controllelr * Fix tests failing on PHP7 * Move significant others to its own controller * Move kids to its own controller * Move notes to its own controller * Some more adjustments & solving #277 And more query optimizations
133 lines
3.4 KiB
PHP
133 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\People;
|
|
|
|
use App\Contact;
|
|
use App\Reminder;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\People\RemindersRequest;
|
|
|
|
class RemindersController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @param Contact $contact
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index(Contact $contact)
|
|
{
|
|
return view('people.reminders.index')
|
|
->withContact($contact);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @param Contact $contact
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create(Contact $contact)
|
|
{
|
|
return view('people.reminders.add')
|
|
->withContact($contact)
|
|
->withReminder(new Reminder);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param RemindersRequest $request
|
|
* @param Contact $contact
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(RemindersRequest $request, Contact $contact)
|
|
{
|
|
$reminder = $contact->reminders()->create(
|
|
$request->only([
|
|
'title',
|
|
'next_expected_date',
|
|
'description',
|
|
'frequency_type',
|
|
'frequency_number'
|
|
])
|
|
+ ['account_id' => $contact->account_id]
|
|
);
|
|
|
|
$contact->logEvent('reminder', $reminder->id, 'create');
|
|
|
|
return redirect('/people/' . $contact->id)
|
|
->with('success', trans('people.reminders_create_success'));
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param Contact $contact
|
|
* @param Reminder $reminder
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show(Contact $contact, Reminder $reminder)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param Contact $contact
|
|
* @param Reminder $reminder
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit(Contact $contact, Reminder $reminder)
|
|
{
|
|
return view('people.reminders.edit')
|
|
->withContact($contact)
|
|
->withReminder($reminder);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param RemindersRequest $request
|
|
* @param Contact $contact
|
|
* @param Reminder $reminder
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(RemindersRequest $request, Contact $contact, Reminder $reminder)
|
|
{
|
|
$reminder->update(
|
|
$request->only([
|
|
'title',
|
|
'next_expected_date',
|
|
'description',
|
|
'frequency_type',
|
|
'frequency_number'
|
|
])
|
|
+ ['account_id' => $contact->account_id]
|
|
);
|
|
|
|
$contact->logEvent('reminder', $reminder->id, 'update');
|
|
|
|
return redirect('/people/' . $contact->id)
|
|
->with('success', trans('people.reminders_update_success'));
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param Contact $contact
|
|
* @param Reminder $reminder
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(Contact $contact, Reminder $reminder)
|
|
{
|
|
$reminder->delete();
|
|
|
|
$contact->events()->forObject($reminder)->get()->each->delete();
|
|
|
|
return redirect('/people/' . $contact->id)
|
|
->with('success', trans('people.reminders_delete_success'));
|
|
}
|
|
}
|