diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 812ccfd..267fc72 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -44,7 +44,7 @@ class DashboardController extends Controller $todo_completed_count = $this->all_completed_todos()['completed_count']; - return view('dashboard', compact( + return view('dashboard.index', compact( 'todos', 'incomplete_count', 'project_count', diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index f84bcbb..4dac2cd 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -8,9 +8,12 @@ use App\Models\Project; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; +use Illuminate\Http\JsonResponse; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use App\Models\User; +use Illuminate\Http\Resources\Json\JsonResource; +use Illuminate\Support\Facades\Response; class ProjectController extends Controller @@ -18,15 +21,23 @@ class ProjectController extends Controller /** * Display Listing of all Projects. */ - public function index(): Application|Factory|View + public function index(Request $request): Application|Factory|View|JsonResponse { $user = User::find(auth()->user()->id); - $projects = $user->projects; + $projects = $user->projects()->paginate(4); // Aggregate all todos for all projects $todos = $projects->map(function ($project) { return $project->todos; })->flatten(); + if ($request->ajax()){ + $view = view('project.load-projects', compact('projects'))->render(); + return Response::json([ + 'view' => $view, + 'nextPageUrl' => $projects->nextPageUrl(), + ]); + } + return view('project.index', [ 'projects' => $projects, 'todos' => $todos->whereNull('completed_at')->values(), diff --git a/app/Http/Livewire/Pomo/Pomos.php b/app/Http/Livewire/Pomo/Pomos.php index d76580d..525761b 100644 --- a/app/Http/Livewire/Pomo/Pomos.php +++ b/app/Http/Livewire/Pomo/Pomos.php @@ -12,6 +12,14 @@ use App\Models\{ class Pomos extends Component { + public $perPage = 10; + + public function loadMore() + { + $this->perPage += 10; + } + + public function render() { $user = User::find(auth()->id()); diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard/index.blade.php similarity index 82% rename from resources/views/dashboard.blade.php rename to resources/views/dashboard/index.blade.php index da3fc84..ce303a5 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard/index.blade.php @@ -105,16 +105,16 @@

- + - + -
+

Today's Todos ({{ $incomplete_count }}) @@ -122,42 +122,41 @@
@include('dashboard.load-todo')
-

- - - diff --git a/resources/views/livewire/dashboard/pomo-count.blade.php b/resources/views/livewire/dashboard/pomo-count.blade.php index dfdc3d0..461910b 100644 --- a/resources/views/livewire/dashboard/pomo-count.blade.php +++ b/resources/views/livewire/dashboard/pomo-count.blade.php @@ -1,6 +1,6 @@

- + + + + {{ $pomo->todo->title }} + + + + + {{ \Carbon\Carbon::createFromTimestamp($pomo->pomo_start)->format('Y-m-d H:i:s') }} + + + {{ \Carbon\Carbon::createFromTimestamp($pomo->pomo_end)->format('Y-m-d H:i:s') }} + + + + {{ + \Carbon\Carbon::createFromTimestamp($pomo->pomo_start)->diffInMinutes(\Carbon\Carbon::createFromTimestamp($pomo->pomo_end)) + }} + + + +
+ {{ $pomo->notes }} +
+ + + +
+
+ Edit +
+
+
+ @csrf + @method('DELETE') + +
+
+
+ + +@endforeach diff --git a/resources/views/livewire/pomo/pomos.blade.php b/resources/views/livewire/pomo/pomos.blade.php index d394efa..dfcf174 100644 --- a/resources/views/livewire/pomo/pomos.blade.php +++ b/resources/views/livewire/pomo/pomos.blade.php @@ -10,53 +10,8 @@ Actions - - @foreach ($pomos as $pomo) - - - - {{ $pomo->todo->title }} - - - - - {{ \Carbon\Carbon::createFromTimestamp($pomo->pomo_start)->format('Y-m-d H:i:s') }} - - - {{ \Carbon\Carbon::createFromTimestamp($pomo->pomo_end)->format('Y-m-d H:i:s') }} - - - - {{ - \Carbon\Carbon::createFromTimestamp($pomo->pomo_start)->diffInMinutes(\Carbon\Carbon::createFromTimestamp($pomo->pomo_end)) - }} - - - -
- {{ $pomo->notes }} -
- - - -
-
- Edit -
-
-
- @csrf - @method('DELETE') - -
-
-
- - - @endforeach + + @include('livewire.pomo.load-pomo')

diff --git a/resources/views/project/index.blade.php b/resources/views/project/index.blade.php index fe4a90b..509640a 100644 --- a/resources/views/project/index.blade.php +++ b/resources/views/project/index.blade.php @@ -11,53 +11,16 @@
-
- @foreach($projects as $project) -
- -
-
-
-

{{ $project->name }}

-

{{ $project->description }}

-
-
-
-
-
- @csrf - @method('DELETE') - - -
-
- @endforeach +
+ @include('project.load-projects')
+ + @include('todo.todo_list') diff --git a/resources/views/project/load-projects.blade.php b/resources/views/project/load-projects.blade.php new file mode 100644 index 0000000..d8d2e30 --- /dev/null +++ b/resources/views/project/load-projects.blade.php @@ -0,0 +1,42 @@ +@foreach($projects as $project) +
+ +
+
+
+

{{ $project->name }}

+

{{ $project->description }}

+
+
+
+
+
+ @csrf + @method('DELETE') + + +
+
+@endforeach diff --git a/routes/web.php b/routes/web.php index 6cb7bf1..9d9d86b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -19,7 +19,7 @@ use Illuminate\Support\Facades\Route; */ Route::get('/', function () { - return redirect(route('project.index')); + return redirect(route('dashboard')); }); Route::get('/dashboard', [DashboardController::class, 'index'])