scriptotek /
bibrex
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Http\Controllers; |
||
| 4 | |||
| 5 | use App\Loan; |
||
| 6 | use App\Notifications\ExtendedDatabaseNotification; |
||
| 7 | use App\Notifications\FirstReminder; |
||
| 8 | use App\Notifications\ManualReminder; |
||
| 9 | use Illuminate\Http\Request; |
||
| 10 | use Illuminate\Http\Response; |
||
| 11 | use Illuminate\Support\Arr; |
||
| 12 | |||
| 13 | class NotificationsController extends Controller |
||
| 14 | { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Show a reminder. |
||
| 18 | * |
||
| 19 | * @param ExtendedDatabaseNotification $notification |
||
| 20 | * @return Response |
||
| 21 | */ |
||
| 22 | public function show(ExtendedDatabaseNotification $notification) |
||
| 23 | { |
||
| 24 | return response()->view('notifications.show', [ |
||
| 25 | 'type' => $notification->humanReadableType(), |
||
| 26 | 'loan' => $notification->loan, |
||
| 27 | 'email' => Arr::get($notification->data, 'email'), |
||
|
0 ignored issues
–
show
|
|||
| 28 | 'sent' => $notification->created_at, |
||
| 29 | ]); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Display a form to create the resource. |
||
| 34 | * |
||
| 35 | * @param Loan $loan |
||
| 36 | * @return Response |
||
| 37 | */ |
||
| 38 | public function create(Loan $loan) |
||
| 39 | { |
||
| 40 | $notification = new FirstReminder($loan); |
||
| 41 | $email = $notification->email->toArray(); |
||
| 42 | |||
| 43 | return response()->view('notifications.create', array( |
||
| 44 | 'loan' => $loan, |
||
| 45 | 'email' => $email, |
||
| 46 | )); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Sends a new reminder. |
||
| 51 | * |
||
| 52 | * @param Loan $loan |
||
| 53 | * @param Request $request |
||
| 54 | * @return Response |
||
| 55 | */ |
||
| 56 | public function send(Loan $loan, Request $request) |
||
| 57 | { |
||
| 58 | $loan->user->notify(new ManualReminder($loan, $request->input('subject'), $request->input('body'))); |
||
| 59 | |||
| 60 | return redirect() |
||
|
0 ignored issues
–
show
|
|||
| 61 | ->action('LoansController@getShow', $loan->id) |
||
| 62 | ->with('status', 'Påminnelsen ble sendt.'); |
||
| 63 | } |
||
| 64 | } |
||
| 65 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.