Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Prawy126 committed Jun 24, 2024
1 parent 2cc004b commit 7f8ca12
Show file tree
Hide file tree
Showing 64 changed files with 229 additions and 151 deletions.
1 change: 0 additions & 1 deletion Projekt/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
Expand Down
Binary file added Projekt/Dokumentacja.docx
Binary file not shown.
Binary file added Projekt/Dokumentacja.pdf
Binary file not shown.
39 changes: 32 additions & 7 deletions Projekt/app/Http/Controllers/AnnouncementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public function show($id)
]);
}

public function oferty()
public function oferts()
{
$cars = Announcement::with('photos')->get();

$recentBids = Bid::with('announcement')->orderBy('time', 'desc')->take(6)->get();

return view('cars.oferty', [
return view('cars.oferts', [
'cars' => $cars,

'recentBids' => $recentBids,
Expand Down Expand Up @@ -134,7 +134,7 @@ public function update(Request $request, $id)
'description' => 'nullable|string',
'min_price' => 'required|numeric|min:100',
'end_date' => 'required|date|after:now',
'images.*' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'images.*' => 'image|mimes:jpeg,png,jpg,gif,webp,svg|max:2048',
], [
'name.required' => 'Pole Marka jest wymagane.',
'name.string' => 'Pole Marka musi być ciągiem znaków.',
Expand All @@ -158,7 +158,7 @@ public function update(Request $request, $id)
'end_date.date' => 'Pole Data końcowa musi być prawidłową datą.',
'end_date.after' => 'Pole Data końcowa musi być datą po obecnej.',
'images.*.image' => 'Każdy plik musi być obrazem.',
'images.*.mimes' => 'Każdy plik musi być typu: jpeg, png, jpg, gif, svg.',
'images.*.mimes' => 'Każdy plik musi być typu: jpeg, png, jpg, webp, gif, svg.',
'images.*.max' => 'Każdy plik nie może być większy niż 2048 KB.',
]);

Expand Down Expand Up @@ -194,12 +194,37 @@ public function store(Request $request)
$validatedData = $request->validate([
'name' => 'required|string|max:255',
'brand' => 'required|string|max:255',
'year' => 'required|integer',
'mileage' => 'required|integer',
'year' => 'required|integer|digits:4|min:1976|max:' . date('Y'),
'mileage' => 'required|numeric|min:0',
'description' => 'nullable|string',
'end_date' => 'required|date',
'min_price' => 'required|numeric',
'min_price' => 'required|numeric|min:100',
'images.*' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
],[
'name.required' => 'Pole Marka jest wymagane.',
'name.string' => 'Pole Marka musi być ciągiem znaków.',
'name.max' => 'Pole Marka może mieć maksymalnie 30 znaków.',
'brand.required' => 'Pole Model jest wymagane.',
'brand.string' => 'Pole Model musi być ciągiem znaków.',
'brand.max' => 'Pole Model może mieć maksymalnie 30 znaków.',
'year.required' => 'Pole Rok produkcji jest wymagane.',
'year.integer' => 'Pole Rok produkcji musi być liczbą całkowitą.',
'year.digits' => 'Pole Rok produkcji musi mieć 4 cyfry.',
'year.min' => 'Pole Rok produkcji nie może być wcześniejsze niż 1976.',
'year.max' => 'Pole Rok produkcji nie może być późniejsze niż bieżący rok.',
'mileage.required' => 'Pole Przebieg jest wymagane.',
'mileage.numeric' => 'Pole Przebieg musi być liczbą.',
'mileage.min' => 'Pole Przebieg nie może być mniejsze niż 0.',
'description.string' => 'Pole Opis musi być ciągiem znaków.',
'min_price.required' => 'Pole Cena jest wymagane.',
'min_price.numeric' => 'Pole Cena musi być liczbą.',
'min_price.min' => 'Pole Cena nie może być mniejsze niż 100.',
'end_date.required' => 'Pole Data końcowa jest wymagane.',
'end_date.date' => 'Pole Data końcowa musi być prawidłową datą.',
'end_date.after' => 'Pole Data końcowa musi być datą po obecnej.',
'images.*.image' => 'Każdy plik musi być obrazem.',
'images.*.mimes' => 'Każdy plik musi być typu: jpeg, png, jpg, webp, gif, svg.',
'images.*.max' => 'Każdy plik nie może być większy niż 2048 KB.',
]);

$announcement = Announcement::create([
Expand Down
6 changes: 4 additions & 2 deletions Projekt/app/Http/Controllers/BidController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function store(Request $request, $announcementId)
->withErrors(['Nie możesz przebijać swojej własnej oferty.']);
}


Bid::create([
if(Auth::check()){
Bid::create([
'announcement_id' => $announcementId,
'user_id' => Auth::id(),
'amount' => $request->amount,
Expand All @@ -51,5 +51,7 @@ public function store(Request $request, $announcementId)

return redirect()->route('cars.show', ['id' => $announcementId])
->with('success', 'Twoja oferta została złożona.');
}
return view('errors.401');
}
}
13 changes: 0 additions & 13 deletions Projekt/app/Http/Controllers/BidsController.php

This file was deleted.

7 changes: 7 additions & 0 deletions Projekt/archiwizacja.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
git init
git config --local user.name "student"
git config --local user.email "[email protected]"
git add --all
git commit -m "Lab"
git archive --format=zip HEAD -o ../MP125151_AI1_Projekt.zip
pause
10 changes: 1 addition & 9 deletions Projekt/bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,11 @@
return $renderException($e, $request, 'errors.403', 'Forbidden', 403);
});

$exceptions->render(function (UnauthorizedHttpException $e, Request $request) use ($renderException) {
return $renderException($e, $request, 'errors.401', 'Unauthorized', 401);
});

$exceptions->render(function (BadRequestHttpException $e, Request $request) use ($renderException) {
return $renderException($e, $request, 'errors.400', 'Bad Request', 400);
});

$exceptions->render(function (QueryException $e, Request $request) use ($renderException) {
return $renderException($e, $request, 'errors.500', 'Internal Server Error', 500);
});
})
->withMiddleware(function (Middleware $middleware) {
// Dodaj swoje middleware tutaj

})
->create();
2 changes: 1 addition & 1 deletion Projekt/database/seeders/AnnouncementSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function run(): void
'year' => 2000,
'mileage' => 321.23,
'description' => 'Samochód w bardzo dobrym stanie pierwszy właściciel.',
'end_date' => '2024-06-27 18:27',
'end_date' => '2024-05-27 18:27',
'is_end' => false,
'min_price' => 200
],
Expand Down
4 changes: 2 additions & 2 deletions Projekt/database/seeders/PhotoSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function run(): void

[
'announcement_id' => 1,
'photo_name' => 'img/AUDI2.png'
'photo_name' => 'img/AUDI2.webp'
],

[
Expand Down Expand Up @@ -75,7 +75,7 @@ public function run(): void
],
[
'announcement_id' => 5,
'photo_name' => 'img/TOYOTA4.jpg'
'photo_name' => 'img/TOYOTA4.webp'
],
[
'announcement_id' => 6,
Expand Down
Binary file added Projekt/public/storage/img/AUDI1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/AUDI2.webp
Binary file not shown.
Binary file added Projekt/public/storage/img/BMW.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/BMW1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/BMW2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/FOCUS.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/FOCUS2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/FOCUS3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/GOLF4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/GOLF4_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/GOLF4_2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/MERCEDES_C_CLASS.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/TOYOTA1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/TOYOTA2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/TOYOTA3.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/TOYOTA4.webp
Binary file not shown.
Binary file added Projekt/public/storage/img/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projekt/public/storage/img/samochod1.png
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 Projekt/resources/views/admin/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class="btn btn-sm btn-warning">Edytuj</a>
<div class="col-md-6">
<div class="card">
<div class="card-header bg-success text-white">
<h2>Liczba ogłoszeń na użytkownika</h2>
<h2>Liczba ogłoszeń użytkowników</h2>
</div>
<div class="card-body">
<canvas id="userAnnouncementsChart"></canvas>
Expand Down
82 changes: 41 additions & 41 deletions Projekt/resources/views/admin/edit_announcement.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,50 @@
@include('shared.head', ['pageTitle'=> 'Admin'])

@include("shared.navbar")

<body>
<div class="container mt-5">
<div class="row">
<div class="col-md-8 offset-md-2">
<div class="card">
<div class="card-header bg-primary text-white">
<h2>Edytuj ogłoszenie</h2>
</div>
<div class="card-body">
<form action="{{ route('admin.updateAnnouncement', $announcement->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="name" class="form-label">Marka</label>
<input type="text" class="form-control" id="name" name="name" value="{{ old('name', $announcement->name) }}" required>
</div>
<div class="mb-3">
<label for="brand" class="form-label">Model</label>
<input type="text" class="form-control" id="brand" name="brand" value="{{ old('brand', $announcement->brand) }}" required>
</div>
<div class="mb-3">
<label for="year" class="form-label">Rok produkcji</label>
<input type="number" class="form-control" id="year" name="year" value="{{ old('year', $announcement->year) }}" required>
</div>
<div class="mb-3">
<label for="mileage" class="form-label">Przebieg</label>
<input type="number" class="form-control" id="mileage" name="mileage" value="{{ old('mileage', $announcement->mileage) }}" required>
</div>
<div class="mb-3">
<label for="min_price" class="form-label">Cena</label>
<input type="number" class="form-control" id="price" name="min_price" value="{{ old('min_price', $announcement->min_price) }}" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Opis</label>
<textarea class="form-control" id="description" name="description" rows="5" required>{{ old('description', $announcement->description) }}</textarea>
</div>
<button type="submit" class="btn btn-success">Zapisz zmiany</button>
<a href="{{ route('admin.dashboard') }}" class="btn btn-secondary">Anuluj</a>
</form>
<div class="container mt-5">
<div class="row">
<div class="col-md-8 offset-md-2">
<div class="card">
<div class="card-header bg-primary text-white">
<h2>Edytuj ogłoszenie</h2>
</div>
<div class="card-body">
<form action="{{ route('admin.updateAnnouncement', $announcement->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="name" class="form-label">Marka</label>
<input type="text" class="form-control" id="name" name="name" value="{{ old('name', $announcement->name) }}" required maxlength="255">
</div>
<div class="mb-3">
<label for="brand" class="form-label">Model</label>
<input type="text" class="form-control" id="brand" name="brand" value="{{ old('brand', $announcement->brand) }}" required maxlength="255">
</div>
<div class="mb-3">
<label for="year" class="form-label">Rok produkcji</label>
<input type="number" class="form-control" id="year" name="year" value="{{ old('year', $announcement->year) }}" required min="1976" max="{{ date('Y') }}">
</div>
<div class="mb-3">
<label for="mileage" class="form-label">Przebieg</label>
<input type="number" class="form-control" id="mileage" name="mileage" value="{{ old('mileage', $announcement->mileage) }}" required min="0">
</div>
<div class="mb-3">
<label for="min_price" class="form-label">Cena</label>
<input type="number" class="form-control" id="price" name="min_price" value="{{ old('min_price', $announcement->min_price) }}" required min="0.01" step="0.01">
</div>
<div class="mb-3">
<label for="description" class="form-label">Opis</label>
<textarea class="form-control" id="description" name="description" rows="5" required maxlength="1000">{{ old('description', $announcement->description) }}</textarea>
</div>
<button type="submit" class="btn btn-success">Zapisz zmiany</button>
<a href="{{ route('admin.dashboard') }}" class="btn btn-secondary">Anuluj</a>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
@include('shared.footer')
@include('shared.footer')
</body>

14 changes: 7 additions & 7 deletions Projekt/resources/views/admin/edit_user.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,32 @@
<div class="mb-3">
<label for="name" class="form-label">Imię</label>
<input type="text" class="form-control" id="name" name="name"
value="{{ old('name', $user->name) }}" required>
value="{{ old('name', $user->name) }}" required maxlength="255">
</div>
<div class="mb-3">
<label for="surname" class="form-label">Nazwisko</label>
<input type="text" class="form-control" id="surname" name="surname"
value="{{ old('surname', $user->surname) }}" required>
value="{{ old('surname', $user->surname) }}" required maxlength="255">
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" name="email"
value="{{ old('email', $user->email) }}" required>
value="{{ old('email', $user->email) }}" required maxlength="255">
</div>
<div class="mb-3">
<label for="address" class="form-label">Adres</label>
<input type="text" class="form-control" id="address" name="address"
value="{{ old('address', $user->address) }}" required>
value="{{ old('address', $user->address) }}" required maxlength="255">
</div>
<div class="mb-3">
<label for="phone_number" class="form-label">Numer telefonu</label>
<input type="text" class="form-control" id="phone_number" name="phone_number"
value="{{ old('phone_number', $user->phone_number) }}" required>
<input type="tel" class="form-control" id="phone_number" name="phone_number"
value="{{ old('phone_number', $user->phone_number) }}" required pattern="[0-9]{9,15}">
</div>
<div class="mb-3">
<label for="role" class="form-label">Rola</label>
<input type="text" class="form-control" id="role" name="role"
value="{{ old('role', $user->role) }}" required>
value="{{ old('role', $user->role) }}" required maxlength="50">
</div>
<button type="submit" class="btn btn-success">Zapisz zmiany</button>
<a href="{{ route('admin.dashboard') }}" class="btn btn-secondary">Anuluj</a>
Expand Down
Loading

0 comments on commit 7f8ca12

Please sign in to comment.