Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/DanericNetwork/Biblio-App in…
Browse files Browse the repository at this point in the history
…to feature/dashboard-main-pagina

# Conflicts:
#	src/resources/vue/components/icon.vue
#	src/resources/vue/components/terminal-scan.vue
#	src/resources/vue/pages/index.vue
#	src/routes/web.php
  • Loading branch information
Timtendo12 committed Jan 24, 2024
2 parents 26ee2b7 + 8a4e439 commit 826b1fc
Show file tree
Hide file tree
Showing 41 changed files with 1,916 additions and 648 deletions.
5 changes: 0 additions & 5 deletions docs/ERD_V-1_1.svg

This file was deleted.

12 changes: 12 additions & 0 deletions docs/ERD_V-1_2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120

Expand Down
8 changes: 8 additions & 0 deletions src/app/Enums/Imports/ImportSources.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace App\Enums\Imports;

enum ImportSources: string
{
case OPEN_LIBRARY = 'openlibrary';
}
55 changes: 55 additions & 0 deletions src/app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace App\Http\Controllers;

use App\Enums\ModifiedEnum;
use App\Models\Item;
use Inertia\Inertia;

class AdminController extends Controller
{
public function index()
{
return Inertia::render('admin/index', [
'userData' => [
'name' => 'John Doe',
],
'count' => [
'items' => 10,
'customers' => 20,
'reservations' => 30,
'invoices' => 40,
],
'chart1' => [
'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug'],
'series' => [1, 2, 3, 4, 5, 6, 7, 8]
],
'chart2' => [
'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug'],
'series' => [0, 1, 2, 3, 4, 5, 6, 7]
],
]);
}

public function items() {

$items = Item::where('modified_kind', '!=', ModifiedEnum::deleted)->paginate(10)->through(function ($item) {
return [
'id' => $item->id,
'name' => $item->name,
'description' => $item->description,
'author' => $item->author->name,
'category' => $item->category->category,
'age_rating' => $item->ageRating->rating,
'ISBN' => $item->ISBN,
'modified_kind' => $item->modified_kind,
'modified_user' => $item->modified_user,
'modified_at' => $item->modified_at,
];
});

return Inertia::render('admin/items/index', [
'items' => $items,
]);
}
}
10 changes: 10 additions & 0 deletions src/app/Http/Controllers/AuthorController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AuthorController extends Controller
{
//
}
3 changes: 1 addition & 2 deletions src/app/Http/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Inertia\Inertia;

class IndexController extends Controller
{
public function index() {
return Inertia::render('index');
return Inertia::render('index');
}
}
21 changes: 19 additions & 2 deletions src/app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Enums\ModifiedEnum;
use App\Enums\ResponseStatus;
use App\Http\Requests\ItemRequest;
use App\Http\Requests\SearchItemRequest;
use App\Models\Item;
use App\Traits\CommonTrait;

Expand Down Expand Up @@ -39,7 +40,7 @@ public function store(ItemRequest $request)
'type' => $validated['type'],
'name' => $validated['name'],
'description' => $validated['description'],
'category' => $validated['category'],
'category_id' => $validated['category_id'],
'ISBN' => $validated['ISBN'],
'rating' => $validated['rating'],
'borrowing_time' => $validated['borrowing_time'],
Expand Down Expand Up @@ -68,7 +69,7 @@ public function update(ItemRequest $request, Item $item)
'type' => $validated['type'],
'name' => $validated['name'],
'description' => $validated['description'],
'category' => $validated['category'],
'category_id' => $validated['category_id'],
'ISBN' => $validated['ISBN'],
'rating' => $validated['rating'],
'borrowing_time' => $validated['borrowing_time'],
Expand All @@ -95,4 +96,20 @@ public function destroy(Item $item)
null,
);
}

public function search(SearchItemRequest $request) {
$validated = $request->validated();
$search = $validated['search'];

$items = Item::where('name', 'like', "%{$search}%")
->orWhere('description', 'like', "%{$search}%")
->orWhere('ISBN', 'like', "%{$search}%")
->get();

return $this->CommonResponse(
ResponseStatus::success,
'Search results',
$items
);
}
}
20 changes: 20 additions & 0 deletions src/app/Http/Controllers/ReservationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
use App\Enums\ModifiedEnum;
use App\Enums\ResponseStatus;
use App\Http\Requests\ReserveRequest;
use App\Http\Requests\SearchReservationRequest;
use App\Models\Item;
use App\Models\Reservation;
use App\Models\User;
use App\Traits\CommonTrait;
use Illuminate\Http\Request;
use Laravel\SerializableClosure\UnsignedSerializableClosure;

class ReservationController extends Controller
{
Expand Down Expand Up @@ -98,4 +102,20 @@ public function destroy(Reservation $reservation)
null,
);
}

public function search(SearchReservationRequest $request)
{
$validated = $request->validated();
$search = $validated['search'];

$item = Item::where('name', 'like', "%{$search}%")->orWhere('ISBN', 'like', "%{$search}%")->first();
$user = User::where('last_name', 'like', "%{$search}%")->orWhere('email', 'like', "%{$search}%")->orWhere('zip_code', 'like', "%{$search}%")->first();

$reservations = Reservation::where('item_id', $item->id)->orWhere('user_id', $user->id)->get();

return $this->CommonResponse(ResponseStatus::success,
'Reservation found',
["reservations" => $reservations],
);
}
}
86 changes: 86 additions & 0 deletions src/app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Enums\ResponseStatus;
use App\Http\Requests\SearchUsersRequest;
use App\Models\User;
use App\Traits\CommonTrait;
use Inertia\Inertia;

class UserController extends Controller
{
use CommonTrait;

/**
* Display a listing of the resource.
*/
public function index()
{
// render page
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
// render page
}

/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*/
public function show(User $user)
{
// render page
}

/**
* Update the specified resource in storage.
*/
public function update()
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy()
{
//
}

/**
* Search users
*/
public function search(SearchUsersRequest $request) {
$validated = $request->validated();
$search = $validated['search'];

$users = User::where('last_name', 'like', "%{$search}%")
->orWhere('first_name', 'like', "%{$search}%")
->orWhere('email', 'like', "%{$search}%")
->orWhere('id', 'like', "%{$search}%")
->orWhereHas('libraryPasses', function($query) use ($search) {
$query->where('barcode', 'like', "%{$search}%");
})
->get();

return $this->CommonResponse(
ResponseStatus::success,
'Search results',
$users
);
}
}
30 changes: 30 additions & 0 deletions src/app/Http/Requests/SearchItemRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Requests;

use App\Models\Item;
use Illuminate\Foundation\Http\FormRequest;

class SearchItemRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
$user = auth()->user();
return $user->can('search', Item::class);
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'search' => 'required|string|max:255'
];
}
}
30 changes: 30 additions & 0 deletions src/app/Http/Requests/SearchReservationRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Requests;

use App\Models\Reservation;
use Illuminate\Foundation\Http\FormRequest;

class SearchReservationRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
$user = auth()->user();
return $user->can('search', Reservation::class);
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'search' => 'required|string|min:3|max:255',
];
}
}
30 changes: 30 additions & 0 deletions src/app/Http/Requests/SearchUsersRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Requests;

use App\Models\User;
use Illuminate\Foundation\Http\FormRequest;

class SearchUsersRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
$user = auth()->user();
return $user->can('search', User::class);
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'search' => 'required|string|max:255'
];
}
}
Loading

0 comments on commit 826b1fc

Please sign in to comment.