From 91964a282f1c665b835a14fe5edabc19a2b41d75 Mon Sep 17 00:00:00 2001 From: yunusemre Date: Sat, 16 May 2020 06:43:47 +0300 Subject: [PATCH] Donations page is added. --- app/Http/Controllers/DonationController.php | 6 ++++ app/Providers/RouteServiceProvider.php | 2 +- app/User.php | 8 ++++- resources/views/donations.blade.php | 35 +++++++++++++++++++++ routes/web.php | 1 + 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 resources/views/donations.blade.php diff --git a/app/Http/Controllers/DonationController.php b/app/Http/Controllers/DonationController.php index aa6ff36..cca2290 100644 --- a/app/Http/Controllers/DonationController.php +++ b/app/Http/Controllers/DonationController.php @@ -178,4 +178,10 @@ class DonationController extends Controller $donation = Donation::where('conversation_id', $conversation_id)->firstOrFail(); return view('success', compact('donation')); } + + public function all(Request $request) + { + $donations = $request->user()->donations()->latest()->paginate(); + return view('donations', compact('donations')); + } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 540d17b..a2eb998 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -21,7 +21,7 @@ class RouteServiceProvider extends ServiceProvider * * @var string */ - public const HOME = '/home'; + public const HOME = '/donations'; /** * Define your route model bindings, pattern filters, etc. diff --git a/app/User.php b/app/User.php index e79dab7..1d30267 100644 --- a/app/User.php +++ b/app/User.php @@ -5,7 +5,7 @@ namespace App; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; - +use App\Donation; class User extends Authenticatable { use Notifiable; @@ -36,4 +36,10 @@ class User extends Authenticatable protected $casts = [ 'email_verified_at' => 'datetime', ]; + + public function donations() + { + return $this->hasMany(Donation::class); + + } } diff --git a/resources/views/donations.blade.php b/resources/views/donations.blade.php new file mode 100644 index 0000000..9610d68 --- /dev/null +++ b/resources/views/donations.blade.php @@ -0,0 +1,35 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+ + + + + + + + + + + @foreach($donations as $donation) + + + + + + + @endforeach + +
AmountTransaction DateFrequencyNext Payment Date
{{$donation->amount}} {{$donation->currency}}{{$donation->created_at}}{{ucfirst($donation->frequency)}}{{$donation->next_payment_at}}
+
+ {{$donations->links()}} +
+
+
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index 2cd83d7..452b066 100644 --- a/routes/web.php +++ b/routes/web.php @@ -19,4 +19,5 @@ Route::get('/', 'DonationController@index')->name('donation.form'); Route::post('/make-donation', 'DonationController@donate')->name('donation.make'); Route::get('/success/{conversation_id}', 'DonationController@success')->name('donation.success'); Route::view('/privacy-policy', 'pages.privacypolicy')->name('pages.privacypolicy'); +Route::get('/donations', 'DonationController@all')->name('donations'); Route::get('/home', 'HomeController@index')->name('home');