Initial commit - Car Rental Management System

This commit is contained in:
Innovator 2026-02-19 22:05:20 +00:00
commit f72173377a
100 changed files with 15201 additions and 0 deletions

18
.editorconfig Normal file
View File

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[compose.yaml]
indent_size = 4

65
.env.example Normal file
View File

@ -0,0 +1,65 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database
# PHP_CLI_SERVER_WORKERS=4
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
CACHE_STORE=database
# CACHE_PREFIX=
MEMCACHED_HOST=127.0.0.1
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"

11
.gitattributes vendored Normal file
View File

@ -0,0 +1,11 @@
* text=auto eol=lf
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore

24
.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
*.log
.DS_Store
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
/.fleet
/.idea
/.nova
/.phpunit.cache
/.vscode
/.zed
/auth.json
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/storage/pail
/vendor
Homestead.json
Homestead.yaml
Thumbs.db

59
README.md Normal file
View File

@ -0,0 +1,59 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
<p align="center">
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
### Premium Partners
- **[Vehikl](https://vehikl.com)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
- **[Redberry](https://redberry.international/laravel-development)**
- **[Active Logic](https://activelogic.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

View File

@ -0,0 +1,73 @@
<?php
namespace App\Http\Controllers;
use App\Models\Car;
use Illuminate\Http\Request;
class CarController extends Controller
{
public function index()
{
$cars = Car::all();
return view('cars.index', compact('cars'));
}
public function create()
{
return view('cars.create');
}
public function store(Request $request)
{
$request->validate([
'brand' => 'required',
'model' => 'required',
'year' => 'required',
'license_plate' => 'required|unique:cars',
'color' => 'required',
'daily_rate' => 'required|numeric'
]);
Car::create($request->all());
return redirect()->route('cars.index')->with('success', 'Car added successfully!');
}
public function show(Car $car)
{
$car->load('rentals', 'services');
return view('cars.show', compact('car'));
}
public function edit(Car $car)
{
return view('cars.edit', compact('car'));
}
public function update(Request $request, Car $car)
{
$request->validate([
'brand' => 'required',
'model' => 'required',
'year' => 'required',
'license_plate' => 'required|unique:cars,license_plate,' . $car->id,
'color' => 'required',
'daily_rate' => 'required|numeric'
]);
$car->update($request->all());
return redirect()->route('cars.index')->with('success', 'Car updated successfully!');
}
public function destroy(Car $car)
{
$car->delete();
return redirect()->route('cars.index')->with('success', 'Car deleted successfully!');
}
public function updateStatus(Request $request, Car $car, $status)
{
$car->update(['status' => $status]);
return redirect()->back()->with('success', 'Status updated!');
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace App\Http\Controllers;
abstract class Controller
{
//
}

View File

@ -0,0 +1,75 @@
<?php
namespace App\Http\Controllers;
use App\Models\Customer;
use Illuminate\Http\Request;
class CustomerController extends Controller
{
public function index()
{
$customers = Customer::all();
return view('customers.index', compact('customers'));
}
public function create()
{
return view('customers.create');
}
public function store(Request $request)
{
$request->validate([
'name' => 'required',
'email' => 'required|email|unique:customers',
'phone' => 'required',
'address' => 'required',
'license_number' => 'required',
'license_expiry' => 'required|date',
'dob' => 'required|date'
]);
$customer = Customer::create($request->all());
// If AJAX request, return JSON
if ($request->expectsJson()) {
return response()->json(['id' => $customer->id, 'name' => $customer->name]);
}
return redirect()->route('customers.index')->with('success', 'Customer added successfully!');
}
public function show(Customer $customer)
{
$customer->load('rentals');
return view('customers.show', compact('customer'));
}
public function edit(Customer $customer)
{
return view('customers.edit', compact('customer'));
}
public function update(Request $request, Customer $customer)
{
$request->validate([
'name' => 'required',
'email' => 'required|email|unique:customers,email,' . $customer->id,
'phone' => 'required',
'address' => 'required',
'license_number' => 'required',
'license_expiry' => 'required|date',
'dob' => 'required|date'
]);
$customer->update($request->all());
return redirect()->route('customers.index')->with('success', 'Customer updated successfully!');
}
public function destroy(Customer $customer)
{
$customer->delete();
return redirect()->route('customers.index')->with('success', 'Customer deleted successfully!');
}
}

View File

@ -0,0 +1,97 @@
<?php
namespace App\Http\Controllers;
use App\Models\Car;
use App\Models\Customer;
use App\Models\Rental;
use App\Models\Service;
use App\Models\Payment;
use Carbon\Carbon;
class DashboardController extends Controller
{
public function index()
{
// Basic stats
$totalCars = Car::count();
$availableCars = Car::where('status', 'available')->count();
$rentedCars = Car::where('status', 'rented')->count();
$maintenanceCars = Car::where('status', 'maintenance')->count();
$totalCustomers = Customer::count();
$activeCustomers = Customer::where('status', 'active')->count();
$totalRentals = Rental::count();
$activeRentals = Rental::where('status', 'active')->count();
$pendingRentals = Rental::where('status', 'pending')->count();
// Revenue stats
$totalRevenue = Payment::where('status', 'completed')->sum('amount');
$monthlyRevenue = Payment::where('status', 'completed')
->whereMonth('created_at', Carbon::now()->month)
->sum('amount');
// Service stats
$totalServices = Service::count();
$totalServiceCost = Service::sum('cost');
$pendingServices = Service::where('status', '!=', 'completed')->count();
// Recent data
$recentRentals = Rental::with(['car', 'customer'])->latest()->take(5)->get();
$recentServices = Service::with('car')->latest()->take(5)->get();
// Chart data - rentals per month (last 6 months)
$monthlyRentals = [];
$monthlyRevenueChart = [];
for ($i = 5; $i >= 0; $i--) {
$month = Carbon::now()->subMonths($i);
$monthlyRentals[] = Rental::whereMonth('created_at', $month->month)
->whereYear('created_at', $month->year)
->count();
$monthlyRevenueChart[] = Payment::where('status', 'completed')
->whereMonth('created_at', $month->month)
->whereYear('created_at', $month->year)
->sum('amount');
}
// Car status distribution for pie chart
$carStatusData = [
'available' => Car::where('status', 'available')->count(),
'rented' => Car::where('status', 'rented')->count(),
'maintenance' => Car::where('status', 'maintenance')->count(),
];
// Cars grouped by status for modal
$carsByStatus = [
'available' => Car::where('status', 'available')->get(),
'rented' => Car::where('status', 'rented')->get(),
'maintenance' => Car::where('status', 'maintenance')->get(),
];
// Top rented cars
$topCars = Rental::select('car_id')
->groupBy('car_id')
->orderByRaw('COUNT(*) DESC')
->take(5)
->get()
->map(function ($rental) {
$car = Car::find($rental->car_id);
$count = Rental::where('car_id', $rental->car_id)->count();
return [
'car' => $car,
'rentals_count' => $count
];
});
return view('dashboard', compact(
'totalCars', 'availableCars', 'rentedCars', 'maintenanceCars',
'totalCustomers', 'activeCustomers',
'totalRentals', 'activeRentals', 'pendingRentals',
'totalRevenue', 'monthlyRevenue',
'totalServices', 'totalServiceCost', 'pendingServices',
'recentRentals', 'recentServices',
'monthlyRentals', 'monthlyRevenueChart', 'carStatusData', 'carsByStatus', 'topCars'
));
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Http\Controllers;
use App\Models\Payment;
use App\Models\Rental;
use Illuminate\Http\Request;
class PaymentController extends Controller
{
public function index()
{
$payments = Payment::with('rental')->get();
return view('payments.index', compact('payments'));
}
public function create()
{
$rentals = Rental::all();
return view('payments.create', compact('rentals'));
}
public function store(Request $request)
{
$request->validate([
'rental_id' => 'required',
'amount' => 'required|numeric',
'method' => 'required',
'status' => 'required'
]);
Payment::create($request->all());
return redirect()->route('payments.index')->with('success', 'Payment recorded successfully!');
}
public function show(Payment $payment)
{
$payment->load('rental');
return view('payments.show', compact('payment'));
}
public function edit(Payment $payment)
{
$rentals = Rental::all();
return view('payments.edit', compact('payment', 'rentals'));
}
public function update(Request $request, Payment $payment)
{
$request->validate([
'rental_id' => 'required',
'amount' => 'required|numeric',
'method' => 'required',
'status' => 'required'
]);
$payment->update($request->all());
return redirect()->route('payments.index')->with('success', 'Payment updated successfully!');
}
public function destroy(Payment $payment)
{
$payment->delete();
return redirect()->route('payments.index')->with('success', 'Payment deleted successfully!');
}
}

View File

@ -0,0 +1,91 @@
<?php
namespace App\Http\Controllers;
use App\Models\Car;
use App\Models\Customer;
use App\Models\Rental;
use App\Models\Payment;
use Illuminate\Http\Request;
use PDF;
use Carbon\Carbon;
class QuickRentalController extends Controller
{
public function getCustomers()
{
$customers = Customer::where('status', 'active')->get(['id', 'name', 'email', 'phone', 'license_number']);
return response()->json($customers);
}
public function getCars()
{
$cars = Car::where('status', 'available')->get();
return response()->json($cars);
}
public function store(Request $request)
{
// Validate the request
$request->validate([
'customer_id' => 'required',
'car_id' => 'required',
'rental_type' => 'required',
'start_date' => 'required|date',
'end_date' => 'required|date|after:start_date',
'total_amount' => 'required|numeric',
'advance_payment' => 'nullable|numeric',
]);
// Create rental
$rental = Rental::create([
'customer_id' => $request->customer_id,
'car_id' => $request->car_id,
'rental_type' => $request->rental_type,
'start_date' => $request->start_date,
'pickup_time' => $request->pickup_time,
'end_date' => $request->end_date,
'return_time' => $request->return_time,
'total_amount' => $request->total_amount,
'advance_payment' => $request->advance_payment ?? 0,
'status' => 'active',
'notes' => $request->notes,
'customer_signature' => $request->customer_signature,
]);
// Update car status
Car::find($request->car_id)->update(['status' => 'rented']);
// Create advance payment if paid
if ($request->advance_payment > 0) {
Payment::create([
'rental_id' => $rental->id,
'amount' => $request->advance_payment,
'method' => $request->payment_method ?? 'cash',
'status' => 'completed',
]);
}
return response()->json([
'success' => true,
'rental_id' => $rental->id,
]);
}
public function generateContract($rentalId)
{
$rental = Rental::with(['car', 'customer', 'payments'])->findOrFail($rentalId);
$pdf = PDF::loadView('contracts.rental', [
'rental' => $rental,
'company' => [
'name' => 'On The Road',
'address' => 'Manama, Bahrain',
'phone' => '+973-00000000',
'email' => 'info@ontheroad.bh',
]
]);
return $pdf->download('rental-contract-' . $rental->id . '.pdf');
}
}

View File

@ -0,0 +1,121 @@
<?php
namespace App\Http\Controllers;
use App\Models\Car;
use App\Models\Customer;
use App\Models\Rental;
use App\Models\Payment;
use Illuminate\Http\Request;
use Carbon\Carbon;
class RentalController extends Controller
{
public function index()
{
$rentals = Rental::with(['car', 'customer'])->get();
return view('rentals.index', compact('rentals'));
}
public function create()
{
$cars = Car::where('status', 'available')->get();
$customers = Customer::where('status', 'active')->get();
return view('rentals.create', compact('cars', 'customers'));
}
public function store(Request $request)
{
$request->validate([
'car_id' => 'required',
'customer_id' => 'required',
'rental_type' => 'required',
'start_date' => 'required|date',
'pickup_time' => 'nullable',
'end_date' => 'required|date|after:start_date',
'return_time' => 'nullable',
'total_amount' => 'required|numeric',
'advance_payment' => 'nullable|numeric'
]);
$rental = Rental::create($request->all());
// Update car status
Car::find($request->car_id)->update(['status' => 'rented']);
// Create payment if advance is paid
if ($request->advance_payment > 0) {
Payment::create([
'rental_id' => $rental->id,
'amount' => $request->advance_payment,
'method' => 'cash',
'status' => 'completed'
]);
}
return redirect()->route('rentals.index')->with('success', 'Rental created successfully!');
}
public function show(Rental $rental)
{
$rental->load(['car', 'customer', 'payments']);
return view('rentals.show', compact('rental'));
}
public function edit(Rental $rental)
{
$cars = Car::all();
$customers = Customer::all();
return view('rentals.edit', compact('rental', 'cars', 'customers'));
}
public function update(Request $request, Rental $rental)
{
$request->validate([
'car_id' => 'required',
'customer_id' => 'required',
'rental_type' => 'required',
'start_date' => 'required|date',
'end_date' => 'required|date|after:start_date',
'total_amount' => 'required|numeric'
]);
$rental->update($request->all());
return redirect()->route('rentals.index')->with('success', 'Rental updated successfully!');
}
public function destroy(Rental $rental)
{
// Reset car status
Car::find($rental->car_id)->update(['status' => 'available']);
$rental->delete();
return redirect()->route('rentals.index')->with('success', 'Rental deleted successfully!');
}
public function updateStatus(Request $request, Rental $rental, $status)
{
$rental->update(['status' => $status]);
if ($status == 'completed' || $status == 'cancelled') {
Car::find($rental->car_id)->update(['status' => 'available']);
} elseif ($status == 'active') {
Car::find($rental->car_id)->update(['status' => 'rented']);
}
return redirect()->back()->with('success', 'Status updated!');
}
public function contract(Rental $rental)
{
$rental->load(['car', 'customer']);
return view('contracts.rental', compact('rental'));
}
public function downloadContract(Rental $rental)
{
$rental->load(['car', 'customer']);
$pdf = \PDF::loadView('contracts.rental', compact('rental'));
return $pdf->download('contract-' . str_pad($rental->id, 6, '0', STR_PAD_LEFT) . '.pdf');
}
}

View File

@ -0,0 +1,74 @@
<?php
namespace App\Http\Controllers;
use App\Models\Car;
use App\Models\Service;
use Illuminate\Http\Request;
class ServiceController extends Controller
{
public function index()
{
$services = Service::with('car')->get();
return view('services.index', compact('services'));
}
public function create()
{
$cars = Car::all();
return view('services.create', compact('cars'));
}
public function store(Request $request)
{
$request->validate([
'car_id' => 'required',
'type' => 'required',
'description' => 'required',
'cost' => 'required|numeric',
'service_date' => 'required|date'
]);
Service::create($request->all());
// If it's a maintenance service, update car status
if ($request->type == 'repair') {
Car::find($request->car_id)->update(['status' => 'maintenance']);
}
return redirect()->route('services.index')->with('success', 'Service recorded successfully!');
}
public function show(Service $service)
{
$service->load('car');
return view('services.show', compact('service'));
}
public function edit(Service $service)
{
$cars = Car::all();
return view('services.edit', compact('service', 'cars'));
}
public function update(Request $request, Service $service)
{
$request->validate([
'car_id' => 'required',
'type' => 'required',
'description' => 'required',
'cost' => 'required|numeric',
'service_date' => 'required|date'
]);
$service->update($request->all());
return redirect()->route('services.index')->with('success', 'Service updated successfully!');
}
public function destroy(Service $service)
{
$service->delete();
return redirect()->route('services.index')->with('success', 'Service deleted successfully!');
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Artisan;
class SettingsController extends Controller
{
public function index()
{
$settings = config('settings');
return view('settings.index', compact('settings'));
}
public function update(Request $request)
{
$request->validate([
'company_name' => 'required|string|max:100',
'company_tagline' => 'nullable|string|max:200',
'phone' => 'nullable|string|max:50',
'email' => 'nullable|email|max:100',
'address' => 'nullable|string|max:200',
]);
$config = [
'company_name' => $request->company_name,
'company_tagline' => $request->company_tagline ?? 'Car Rental Management System',
'logo' => config('settings.logo'),
'phone' => $request->phone ?? '',
'email' => $request->email ?? '',
'address' => $request->address ?? '',
];
$configContent = "<?php\n\nreturn [\n";
foreach ($config as $key => $value) {
$configContent .= " '$key' => " . var_export($value, true) . ",\n";
}
$configContent .= "];\n";
File::put(config_path('settings.php'), $configContent);
// Clear config cache
Artisan::call('config:clear');
return redirect()->route('settings.index')->with('success', 'Settings updated successfully!');
}
public function uploadLogo(Request $request)
{
$request->validate([
'logo' => 'required|image|mimes:png,jpg,jpeg,gif,svg|max:2048',
]);
$file = $request->file('logo');
$filename = 'logo.' . $file->getClientOriginalExtension();
// Delete old logo
$oldLogo = public_path(config('settings.logo'));
if (File::exists($oldLogo) && strpos(config('settings.logo'), 'logo.') !== false) {
File::delete($oldLogo);
}
$file->move(public_path('/uploads'), $filename);
// Update config
$config = config('settings');
$config['logo'] = '/uploads/' . $filename;
$configContent = "<?php\n\nreturn [\n";
foreach ($config as $key => $value) {
$configContent .= " '$key' => " . var_export($value, true) . ",\n";
}
$configContent .= "];\n";
File::put(config_path('settings.php'), $configContent);
Artisan::call('config:clear');
return redirect()->route('settings.index')->with('success', 'Logo uploaded successfully!');
}
}

20
app/Models/Car.php Normal file
View File

@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Car extends Model
{
protected $fillable = ['brand', 'model', 'year', 'license_plate', 'color', 'daily_rate', 'status', 'image', 'mileage', 'notes'];
public function rentals()
{
return $this->hasMany(Rental::class);
}
public function services()
{
return $this->hasMany(Service::class);
}
}

15
app/Models/Customer.php Normal file
View File

@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Customer extends Model
{
protected $fillable = ['name', 'email', 'phone', 'address', 'license_number', 'license_expiry', 'dob', 'status', 'notes'];
public function rentals()
{
return $this->hasMany(Rental::class);
}
}

15
app/Models/Payment.php Normal file
View File

@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Payment extends Model
{
protected $fillable = ['rental_id', 'amount', 'method', 'status', 'transaction_id', 'notes'];
public function rental()
{
return $this->belongsTo(Rental::class);
}
}

32
app/Models/Rental.php Normal file
View File

@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Rental extends Model
{
protected $fillable = ['car_id', 'customer_id', 'start_date', 'end_date', 'total_amount', 'advance_payment', 'status', 'notes', 'rental_type', 'pickup_time', 'return_time', 'customer_signature'];
protected $casts = [
'start_date' => 'date',
'end_date' => 'date',
'pickup_time' => 'datetime:H:i',
'return_time' => 'datetime:H:i',
];
public function car()
{
return $this->belongsTo(Car::class);
}
public function customer()
{
return $this->belongsTo(Customer::class);
}
public function payments()
{
return $this->hasMany(Payment::class);
}
}

20
app/Models/Service.php Normal file
View File

@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Service extends Model
{
protected $fillable = ['car_id', 'type', 'description', 'cost', 'service_date', 'next_service_date', 'mileage_at_service', 'status'];
protected $casts = [
'service_date' => 'date',
'next_service_date' => 'date',
];
public function car()
{
return $this->belongsTo(Car::class);
}
}

48
app/Models/User.php Normal file
View File

@ -0,0 +1,48 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}

18
artisan Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php
use Illuminate\Foundation\Application;
use Symfony\Component\Console\Input\ArgvInput;
define('LARAVEL_START', microtime(true));
// Register the Composer autoloader...
require __DIR__.'/vendor/autoload.php';
// Bootstrap Laravel and handle the command...
/** @var Application $app */
$app = require_once __DIR__.'/bootstrap/app.php';
$status = $app->handleCommand(new ArgvInput);
exit($status);

18
bootstrap/app.php Normal file
View File

@ -0,0 +1,18 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
//
})
->withExceptions(function (Exceptions $exceptions): void {
//
})->create();

2
bootstrap/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

5
bootstrap/providers.php Normal file
View File

@ -0,0 +1,5 @@
<?php
return [
App\Providers\AppServiceProvider::class,
];

87
composer.json Normal file
View File

@ -0,0 +1,87 @@
{
"$schema": "https://getcomposer.org/schema.json",
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"license": "MIT",
"require": {
"php": "^8.2",
"barryvdh/laravel-dompdf": "^3.1",
"laravel/framework": "^12.0",
"laravel/tinker": "^2.10.1"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pail": "^1.2.2",
"laravel/pint": "^1.24",
"laravel/sail": "^1.41",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"phpunit/phpunit": "^11.5.3"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"setup": [
"composer install",
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php artisan key:generate",
"@php artisan migrate --force",
"npm install",
"npm run build"
],
"dev": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
],
"test": [
"@php artisan config:clear --ansi",
"@php artisan test"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
],
"pre-package-uninstall": [
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}

8911
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

126
config/app.php Normal file
View File

@ -0,0 +1,126 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application, which will be used when the
| framework needs to place the application's name in a notification or
| other UI elements where an application name needs to be displayed.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| the application so that it's available within Artisan commands.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. The timezone
| is set to "UTC" by default as it is suitable for most use cases.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by Laravel's translation / localization methods. This option can be
| set to any locale for which you plan to have translation strings.
|
*/
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is utilized by Laravel's encryption services and should be set
| to a random, 32 character string to ensure that all encrypted values
| are secure. You should do this prior to deploying the application.
|
*/
'cipher' => 'AES-256-CBC',
'key' => env('APP_KEY'),
'previous_keys' => [
...array_filter(
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
),
],
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],
];

115
config/auth.php Normal file
View File

@ -0,0 +1,115 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option defines the default authentication "guard" and password
| reset "broker" for your application. You may change these values
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => env('AUTH_GUARD', 'web'),
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| which utilizes session storage plus the Eloquent user provider.
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| If you have multiple user tables or models you may configure multiple
| providers to represent the model / table. These providers may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => env('AUTH_MODEL', App\Models\User::class),
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| These configuration options specify the behavior of Laravel's password
| reset functionality, including the table utilized for token storage
| and the user provider that is invoked to actually retrieve users.
|
| The expiry time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
| The throttle setting is the number of seconds a user must wait before
| generating more password reset tokens. This prevents the user from
| quickly generating a very large amount of password reset tokens.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the number of seconds before a password confirmation
| window expires and users are asked to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
];

117
config/cache.php Normal file
View File

@ -0,0 +1,117 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache store that will be used by the
| framework. This connection is utilized if another isn't explicitly
| specified when running a cache operation inside the application.
|
*/
'default' => env('CACHE_STORE', 'database'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "array", "database", "file", "memcached",
| "redis", "dynamodb", "octane",
| "failover", "null"
|
*/
'stores' => [
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'connection' => env('DB_CACHE_CONNECTION'),
'table' => env('DB_CACHE_TABLE', 'cache'),
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
'lock_path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
'failover' => [
'driver' => 'failover',
'stores' => [
'database',
'array',
],
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
| stores, there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
];

183
config/database.php Normal file
View File

@ -0,0 +1,183 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for database operations. This is
| the connection which will be utilized unless another connection
| is explicitly specified when you execute a query / statement.
|
*/
'default' => env('DB_CONNECTION', 'sqlite'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Below are all of the database connections defined for your application.
| An example configuration is provided for each database system which
| is supported by Laravel. You're free to add / remove connections.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DB_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
'busy_timeout' => null,
'journal_mode' => null,
'synchronous' => null,
'transaction_mode' => 'DEFERRED',
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
(PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'mariadb' => [
'driver' => 'mariadb',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
(PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => env('DB_SSLMODE', 'prefer'),
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DB_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run on the database.
|
*/
'migrations' => [
'table' => 'migrations',
'update_date_on_publish' => true,
],
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as Memcached. You may define your connection settings here.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
'persistent' => env('REDIS_PERSISTENT', false),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
],
];

80
config/filesystems.php Normal file
View File

@ -0,0 +1,80 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application for file storage.
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Below you may configure as many filesystem disks as necessary, and you
| may even configure multiple disks for the same driver. Examples for
| most supported storage drivers are configured here for reference.
|
| Supported drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app/private'),
'serve' => true,
'throw' => false,
'report' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];

132
config/logging.php Normal file
View File

@ -0,0 +1,132 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use Monolog\Processor\PsrLogMessageProcessor;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that is utilized to write
| messages to your logs. The value provided here should match one of
| the channels present in the list of "channels" configured below.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
],
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Laravel
| utilizes the Monolog PHP logging library, which includes a variety
| of powerful log handlers and formatters that you're free to use.
|
| Available drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog", "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => env('LOG_DAILY_DAYS', 14),
'replace_placeholders' => true,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
'level' => env('LOG_LEVEL', 'critical'),
'replace_placeholders' => true,
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
'processors' => [PsrLogMessageProcessor::class],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'handler_with' => [
'stream' => 'php://stderr',
],
'formatter' => env('LOG_STDERR_FORMATTER'),
'processors' => [PsrLogMessageProcessor::class],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
'replace_placeholders' => true,
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];

118
config/mail.php Normal file
View File

@ -0,0 +1,118 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send all email
| messages unless another mailer is explicitly specified when sending
| the message. All additional mailers can be configured within the
| "mailers" array. Examples of each type of mailer are provided.
|
*/
'default' => env('MAIL_MAILER', 'log'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers that can be used
| when delivering an email. You may specify which one you're using for
| your mailers below. You may also add additional mailers if needed.
|
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
| "postmark", "resend", "log", "array",
| "failover", "roundrobin"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'scheme' => env('MAIL_SCHEME'),
'url' => env('MAIL_URL'),
'host' => env('MAIL_HOST', '127.0.0.1'),
'port' => env('MAIL_PORT', 2525),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
],
'ses' => [
'transport' => 'ses',
],
'postmark' => [
'transport' => 'postmark',
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
// 'client' => [
// 'timeout' => 5,
// ],
],
'resend' => [
'transport' => 'resend',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
'retry_after' => 60,
],
'roundrobin' => [
'transport' => 'roundrobin',
'mailers' => [
'ses',
'postmark',
],
'retry_after' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all emails sent by your application to be sent from
| the same address. Here you may specify a name and address that is
| used globally for all emails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
];

129
config/queue.php Normal file
View File

@ -0,0 +1,129 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue supports a variety of backends via a single, unified
| API, giving you convenient access to each backend using identical
| syntax for each. The default queue connection is defined below.
|
*/
'default' => env('QUEUE_CONNECTION', 'database'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection options for every queue backend
| used by your application. An example configuration is provided for
| each backend supported by Laravel. You're also free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
| "deferred", "background", "failover", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'connection' => env('DB_QUEUE_CONNECTION'),
'table' => env('DB_QUEUE_TABLE', 'jobs'),
'queue' => env('DB_QUEUE', 'default'),
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
'queue' => env('BEANSTALKD_QUEUE', 'default'),
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
'block_for' => null,
'after_commit' => false,
],
'deferred' => [
'driver' => 'deferred',
],
'background' => [
'driver' => 'background',
],
'failover' => [
'driver' => 'failover',
'connections' => [
'database',
'deferred',
],
],
],
/*
|--------------------------------------------------------------------------
| Job Batching
|--------------------------------------------------------------------------
|
| The following options configure the database and table that store job
| batching information. These options can be updated to any database
| connection and table which has been defined by your application.
|
*/
'batching' => [
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'job_batches',
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control how and where failed jobs are stored. Laravel ships with
| support for storing failed jobs in a simple file or in a database.
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'failed_jobs',
],
];

38
config/services.php Normal file
View File

@ -0,0 +1,38 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Mailgun, Postmark, AWS and more. This file provides the de facto
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
'postmark' => [
'key' => env('POSTMARK_API_KEY'),
],
'resend' => [
'key' => env('RESEND_API_KEY'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'slack' => [
'notifications' => [
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
],
],
];

217
config/session.php Normal file
View File

@ -0,0 +1,217 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option determines the default session driver that is utilized for
| incoming requests. Laravel supports a variety of storage options to
| persist session data. Database storage is a great default choice.
|
| Supported: "file", "cookie", "database", "memcached",
| "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'database'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to expire immediately when the browser is closed then you may
| indicate that via the expire_on_close configuration option.
|
*/
'lifetime' => (int) env('SESSION_LIFETIME', 120),
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it's stored. All encryption is performed
| automatically by Laravel and you may use the session like normal.
|
*/
'encrypt' => env('SESSION_ENCRYPT', false),
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When utilizing the "file" session driver, the session files are placed
| on disk. The default storage location is defined here; however, you
| are free to provide another location where they should be stored.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION'),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table to
| be used to store sessions. Of course, a sensible default is defined
| for you; however, you're welcome to change this to another table.
|
*/
'table' => env('SESSION_TABLE', 'sessions'),
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| When using one of the framework's cache driven session backends, you may
| define the cache store which should be used to store the session data
| between requests. This must match one of your defined cache stores.
|
| Affects: "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE'),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the session cookie that is created by
| the framework. Typically, you should not need to change this value
| since doing so does not grant a meaningful security improvement.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application, but you're free to change this when necessary.
|
*/
'path' => env('SESSION_PATH', '/'),
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| This value determines the domain and subdomains the session cookie is
| available to. By default, the cookie will be available to the root
| domain without subdomains. Typically, this shouldn't be changed.
|
*/
'domain' => env('SESSION_DOMAIN'),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you when it can't be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. It's unlikely you should disable this option.
|
*/
'http_only' => env('SESSION_HTTP_ONLY', true),
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" to permit secure cross-site requests.
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => env('SESSION_SAME_SITE', 'lax'),
/*
|--------------------------------------------------------------------------
| Partitioned Cookies
|--------------------------------------------------------------------------
|
| Setting this value to true will tie the cookie to the top-level site for
| a cross-site context. Partitioned cookies are accepted by the browser
| when flagged "secure" and the Same-Site attribute is set to "none".
|
*/
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
];

10
config/settings.php Normal file
View File

@ -0,0 +1,10 @@
<?php
return [
'company_name' => 'On The Road',
'company_tagline' => 'Car Rental Management System',
'logo' => '/uploads/logo.jpeg',
'phone' => '+973-00000000',
'email' => 'info@ontheroad.bh',
'address' => 'Manama, Bahrain',
];

1
database/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.sqlite*

View File

@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('cars', function (Blueprint $table) {
$table->id();
$table->string('brand');
$table->string('model');
$table->string('year');
$table->string('license_plate')->unique();
$table->string('color');
$table->decimal('daily_rate', 10, 2);
$table->enum('status', ['available', 'rented', 'maintenance', 'sold'])->default('available');
$table->string('image')->nullable();
$table->integer('mileage')->default(0);
$table->text('notes')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('cars');
}
};

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('customers', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('phone');
$table->string('address');
$table->string('license_number');
$table->date('license_expiry');
$table->date('dob');
$table->enum('status', ['active', 'inactive', 'blocked'])->default('active');
$table->text('notes')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('customers');
}
};

View File

@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('rentals', function (Blueprint $table) {
$table->id();
$table->foreignId('car_id')->constrained()->onDelete('cascade');
$table->foreignId('customer_id')->constrained()->onDelete('cascade');
$table->date('start_date');
$table->date('end_date');
$table->decimal('total_amount', 10, 2);
$table->decimal('advance_payment', 10, 2)->default(0);
$table->enum('status', ['pending', 'active', 'completed', 'cancelled'])->default('pending');
$table->text('notes')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('rentals');
}
};

View File

@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('services', function (Blueprint $table) {
$table->id();
$table->foreignId('car_id')->constrained()->onDelete('cascade');
$table->enum('type', ['oil_change', 'tire_rotation', 'brake_service', 'general_checkup', 'repair', 'insurance', 'other']);
$table->text('description');
$table->decimal('cost', 10, 2);
$table->date('service_date');
$table->date('next_service_date')->nullable();
$table->integer('mileage_at_service')->nullable();
$table->enum('status', ['scheduled', 'in_progress', 'completed'])->default('completed');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('services');
}
};

View File

@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('payments', function (Blueprint $table) {
$table->id();
$table->foreignId('rental_id')->constrained()->onDelete('cascade');
$table->decimal('amount', 10, 2);
$table->enum('method', ['cash', 'card', 'bank_transfer', 'online', 'other']);
$table->enum('status', ['pending', 'completed', 'failed', 'refunded'])->default('completed');
$table->string('transaction_id')->nullable();
$table->text('notes')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('payments');
}
};

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('rentals', function (Blueprint $table) {
$table->enum('rental_type', ['daily', 'weekly', 'monthly', 'lease'])->default('daily')->after('end_date');
});
}
public function down(): void
{
Schema::table('rentals', function (Blueprint $table) {
$table->dropColumn('rental_type');
});
}
};

View File

@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('rentals', function (Blueprint $table) {
$table->time('pickup_time')->nullable()->after('start_date');
$table->time('return_time')->nullable()->after('end_date');
});
}
public function down(): void
{
Schema::table('rentals', function (Blueprint $table) {
$table->dropColumn(['pickup_time', 'return_time']);
});
}
};

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('rentals', function (Blueprint $table) {
$table->text('customer_signature')->nullable()->after('notes');
});
}
public function down(): void
{
Schema::table('rentals', function (Blueprint $table) {
$table->dropColumn('customer_signature');
});
}
};

View File

@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
}
}

17
package.json Normal file
View File

@ -0,0 +1,17 @@
{
"$schema": "https://www.schemastore.org/package.json",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite"
},
"devDependencies": {
"@tailwindcss/vite": "^4.0.0",
"axios": "^1.11.0",
"concurrently": "^9.0.1",
"laravel-vite-plugin": "^2.0.0",
"tailwindcss": "^4.0.0",
"vite": "^7.0.7"
}
}

35
phpunit.xml Normal file
View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>app</directory>
</include>
</source>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="BROADCAST_CONNECTION" value="null"/>
<env name="CACHE_STORE" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<env name="TELESCOPE_ENABLED" value="false"/>
<env name="NIGHTWATCH_ENABLED" value="false"/>
</php>
</phpunit>

25
public/.htaccess Normal file
View File

@ -0,0 +1,25 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Handle X-XSRF-Token Header
RewriteCond %{HTTP:x-xsrf-token} .
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

0
public/favicon.ico Normal file
View File

20
public/index.php Normal file
View File

@ -0,0 +1,20 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';
// Bootstrap Laravel and handle the request...
/** @var Application $app */
$app = require_once __DIR__.'/../bootstrap/app.php';
$app->handleRequest(Request::capture());

2
public/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-agent: *
Disallow:

BIN
public/uploads/logo.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

11
resources/css/app.css Normal file
View File

@ -0,0 +1,11 @@
@import 'tailwindcss';
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
@source '../../storage/framework/views/*.php';
@source '../**/*.blade.php';
@source '../**/*.js';
@theme {
--font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol', 'Noto Color Emoji';
}

1
resources/js/app.js Normal file
View File

@ -0,0 +1 @@
import './bootstrap';

4
resources/js/bootstrap.js vendored Normal file
View File

@ -0,0 +1,4 @@
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

View File

@ -0,0 +1,63 @@
@extends('layouts.app')
@section('title', 'Add Car')
@section('content')
<div class="mb-8">
<a href="{{ route('cars.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Fleet
</a>
<h2 class="text-3xl font-bold text-gray-800">Add New Car</h2>
<p class="text-gray-500">Add a new car to your fleet</p>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
<form action="{{ route('cars.store') }}" method="POST">
@csrf
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Brand</label>
<input type="text" name="brand" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Model</label>
<input type="text" name="model" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Year</label>
<input type="text" name="year" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">License Plate</label>
<input type="text" name="license_plate" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Color</label>
<input type="text" name="color" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Daily Rate (BHD)</label>
<input type="number" name="daily_rate" step="0.01" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Status</label>
<select name="status" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="available">Available</option>
<option value="maintenance">Maintenance</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Mileage</label>
<input type="number" name="mileage" value="0" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div class="md:col-span-2">
<label class="block text-sm font-medium text-gray-700 mb-2">Notes</label>
<textarea name="notes" rows="3" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
</div>
</div>
<div class="mt-6">
<button type="submit" class="bg-blue-600 text-white px-8 py-3 rounded-xl hover:bg-blue-700">Add Car</button>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,64 @@
@extends('layouts.app')
@section('title', 'Edit Car')
@section('content')
<div class="mb-8">
<a href="{{ route('cars.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Fleet
</a>
<h2 class="text-3xl font-bold text-gray-800">Edit Car</h2>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
<form action="{{ route('cars.update', $car) }}" method="POST">
@csrf
@method('PUT')
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Brand</label>
<input type="text" name="brand" value="{{ $car->brand }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Model</label>
<input type="text" name="model" value="{{ $car->model }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Year</label>
<input type="text" name="year" value="{{ $car->year }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">License Plate</label>
<input type="text" name="license_plate" value="{{ $car->license_plate }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Color</label>
<input type="text" name="color" value="{{ $car->color }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Daily Rate (BHD)</label>
<input type="number" name="daily_rate" step="0.01" value="{{ $car->daily_rate }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Status</label>
<select name="status" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="available" {{ $car->status == 'available' ? 'selected' : '' }}>Available</option>
<option value="rented" {{ $car->status == 'rented' ? 'selected' : '' }}>Rented</option>
<option value="maintenance" {{ $car->status == 'maintenance' ? 'selected' : '' }}>Maintenance</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Mileage</label>
<input type="number" name="mileage" value="{{ $car->mileage }}" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div class="md:col-span-2">
<label class="block text-sm font-medium text-gray-700 mb-2">Notes</label>
<textarea name="notes" rows="3" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500">{{ $car->notes }}</textarea>
</div>
</div>
<div class="mt-6">
<button type="submit" class="bg-blue-600 text-white px-8 py-3 rounded-xl hover:bg-blue-700">Update Car</button>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,74 @@
@extends('layouts.app')
@section('title', 'Fleet')
@section('content')
<div class="flex justify-between items-center mb-6">
<div>
<h2 class="text-xl font-bold text-gray-800">Fleet Management</h2>
<p class="text-gray-500 text-sm">Manage your car fleet</p>
</div>
<a href="{{ route('cars.create') }}" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 flex items-center gap-2 text-sm font-medium">
<i class="fas fa-plus"></i> Add Car
</a>
</div>
@if(session('success'))
<div class="bg-green-50 border border-green-200 text-green-700 px-4 py-3 rounded-lg mb-4 text-sm">
{{ session('success') }}
</div>
@endif
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<table class="w-full">
<thead class="bg-gray-50 border-b border-gray-200">
<tr>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">Car</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">License Plate</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">Daily Rate</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">Status</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@forelse($cars as $car)
<tr class="hover:bg-gray-50">
<td class="px-5 py-4">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-blue-100 flex items-center justify-center">
<i class="fas fa-car text-blue-600"></i>
</div>
<div>
<p class="font-medium text-gray-800">{{ $car->brand }} {{ $car->model }}</p>
<p class="text-sm text-gray-500">{{ $car->year }} {{ $car->color }}</p>
</div>
</div>
</td>
<td class="px-5 py-4 text-gray-600 text-sm">{{ $car->license_plate }}</td>
<td class="px-5 py-4 text-gray-600 text-sm"> BHD {{ number_format($car->daily_rate, 0) }}/day</td>
<td class="px-5 py-4">
<span class="px-2.5 py-1 rounded-full text-xs font-medium
{{ $car->status == 'available' ? 'bg-green-100 text-green-700' :
($car->status == 'rented' ? 'bg-amber-100 text-amber-700' : 'bg-red-100 text-red-700') }}">
{{ ucfirst($car->status) }}
</span>
</td>
<td class="px-5 py-4">
<a href="{{ route('cars.show', $car) }}" class="text-blue-600 hover:text-blue-800 mr-3 text-sm"><i class="fas fa-eye"></i></a>
<a href="{{ route('cars.edit', $car) }}" class="text-gray-600 hover:text-gray-800 mr-3 text-sm"><i class="fas fa-edit"></i></a>
<form action="{{ route('cars.destroy', $car) }}" method="POST" class="inline">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-800 text-sm" onclick="return confirm('Are you sure?')"><i class="fas fa-trash"></i></button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="5" class="px-5 py-8 text-center text-gray-500">No cars yet. Add your first car!</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@endsection

View File

@ -0,0 +1,101 @@
@extends('layouts.app')
@section('title', $car->brand . ' ' . $car->model)
@section('content')
<div class="mb-8">
<a href="{{ route('cars.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Fleet
</a>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Car Details -->
<div class="lg:col-span-2">
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
<div class="flex items-center gap-4 mb-6">
<div class="w-16 h-16 rounded-xl bg-gradient-to-br from-blue-400 to-blue-600 flex items-center justify-center">
<i class="fas fa-car text-white text-2xl"></i>
</div>
<div>
<h2 class="text-2xl font-bold text-gray-800">{{ $car->brand }} {{ $car->model }}</h2>
<p class="text-gray-500">{{ $car->year }} {{ $car->color }} {{ $car->license_plate }}</p>
</div>
</div>
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
<div class="bg-gray-50 rounded-lg p-4 text-center">
<p class="text-sm text-gray-500">Daily Rate</p>
<p class="text-xl font-bold text-gray-800"> BHD {{ number_format($car->daily_rate, 0) }}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4 text-center">
<p class="text-sm text-gray-500">Mileage</p>
<p class="text-xl font-bold text-gray-800">{{ number_format($car->mileage) }} km</p>
</div>
<div class="bg-gray-50 rounded-lg p-4 text-center">
<p class="text-sm text-gray-500">Status</p>
<span class="px-3 py-1 rounded-full text-sm font-medium
{{ $car->status == 'available' ? 'bg-green-100 text-green-700' :
($car->status == 'rented' ? 'bg-amber-100 text-amber-700' : 'bg-red-100 text-red-700') }}">
{{ ucfirst($car->status) }}
</span>
</div>
</div>
@if($car->notes)
<div class="border-t pt-4">
<p class="text-sm text-gray-500 mb-1">Notes</p>
<p class="text-gray-700">{{ $car->notes }}</p>
</div>
@endif
</div>
</div>
<!-- Quick Actions -->
<div>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-6">
<h3 class="font-semibold text-gray-800 mb-4">Quick Actions</h3>
<a href="{{ route('rentals.create') }}?car_id={{ $car->id }}" class="block w-full bg-amber-500 text-white text-center py-3 rounded-xl mb-3 hover:bg-amber-600">New Rental</a>
<a href="{{ route('services.create') }}?car_id={{ $car->id }}" class="block w-full bg-purple-500 text-white text-center py-3 rounded-xl mb-3 hover:bg-purple-600">Schedule Service</a>
<a href="{{ route('cars.edit', $car) }}" class="block w-full bg-gray-100 text-gray-700 text-center py-3 rounded-xl hover:bg-gray-200">Edit Car</a>
</div>
</div>
</div>
<!-- Rentals & Services -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mt-6">
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-6">
<h3 class="font-semibold text-gray-800 mb-4">Recent Rentals</h3>
@forelse($car->rentals->take(5) as $rental)
<div class="flex justify-between items-center py-3 border-b last:border-0">
<div>
<p class="font-medium text-gray-800">{{ $rental->customer->name }}</p>
<p class="text-sm text-gray-500">{{ $rental->start_date->format('M d') }} - {{ $rental->end_date->format('M d, Y') }}</p>
</div>
<span class="px-2 py-1 rounded text-xs font-medium
{{ $rental->status == 'active' ? 'bg-green-100 text-green-700' :
($rental->status == 'pending' ? 'bg-amber-100 text-amber-700' : 'bg-gray-100 text-gray-700') }}">
{{ $rental->status }}
</span>
</div>
@empty
<p class="text-gray-500 text-center py-4">No rentals yet</p>
@endforelse
</div>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-6">
<h3 class="font-semibold text-gray-800 mb-4">Service History</h3>
@forelse($car->services->take(5) as $service)
<div class="flex justify-between items-center py-3 border-b last:border-0">
<div>
<p class="font-medium text-gray-800 capitalize">{{ str_replace('_', ' ', $service->type) }}</p>
<p class="text-sm text-gray-500">{{ $service->service_date->format('M d, Y') }}</p>
</div>
<span class="text-gray-800 font-medium"> BHD {{ number_format($service->cost, 0) }}</span>
</div>
@empty
<p class="text-gray-500 text-center py-4">No services yet</p>
@endforelse
</div>
</div>
@endsection

View File

@ -0,0 +1,148 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Rental Contract #{{ $rental->id }}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
@media print {
html, body { height: auto; overflow: visible; }
.container { page-break-after: avoid; page-break-inside: avoid; }
}
@page { size: A4; margin: 10mm; }
body { font-family: Arial, sans-serif; font-size: 11px; line-height: 1.4; color: #333; }
.container { max-width: 700px; margin: 0 auto; padding: 15px; page-break-after: auto; }
/* Header */
.header { text-align: center; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid #333; }
.logo { max-width: 150px; max-height: 50px; margin-bottom: 5px; }
.company-name { font-size: 18px; font-weight: bold; color: #1f2937; }
.company-tagline { font-size: 10px; color: #666; margin-bottom: 8px; }
.contract-title { font-size: 16px; font-weight: bold; margin-top: 8px; color: #374151; }
.contract-no { font-size: 10px; color: #6b7280; }
/* Sections */
.section { margin-bottom: 12px; }
.section-title { font-size: 12px; font-weight: bold; margin-bottom: 6px; color: #1f2937; border-bottom: 1px solid #e5e7eb; padding-bottom: 3px; }
.info-grid { display: table; width: 100%; }
.info-row { display: table-row; }
.info-label { display: table-cell; width: 35%; padding: 2px 8px 2px 0; color: #6b7280; }
.info-value { display: table-cell; padding: 2px 0; font-weight: 500; color: #1f2937; }
/* Two columns */
.two-col { display: table; width: 100%; }
.col { display: table-cell; width: 50%; padding: 5px; vertical-align: top; }
/* Box styles */
.box { background: #f9fafb; padding: 10px; text-align: center; margin-top: 10px; }
.amount { font-size: 20px; font-weight: bold; color: #1f2937; }
.amount-small { font-size: 14px; color: #6b7280; }
/* Signature */
.signatures { display: table; width: 100%; margin-top: 15px; }
.signature-box { display: table-cell; width: 50%; padding: 5px 15px; text-align: center; vertical-align: top; min-height: 70px; }
.signature-line { border-top: 1px solid #333; margin-top: 30px; padding-top: 5px; font-size: 10px; color: #6b7280; }
.sig-img { max-width: 150px; max-height: 50px; margin-bottom: 5px; }
/* Footer */
.footer { margin-top: 10px; padding-top: 8px; border-top: 1px solid #e5e7eb; text-align: center; font-size: 9px; color: #9ca3af; }
/* Status badge */
.status { display: inline-block; padding: 2px 8px; background: #22c55e; color: white; border-radius: 3px; font-size: 10px; }
</style>
</head>
<body>
<div class="container">
<!-- Header with Logo -->
<div class="header">
@if(config('settings.logo'))
<img src="{{ asset(config('settings.logo')) }}" alt="Logo" class="logo">
@else
<div class="logo">🚗</div>
@endif
<div class="company-name">{{ config('settings.company_name') }}</div>
<div class="company-tagline">{{ config('settings.company_tagline') }}</div>
<div class="contract-title">RENTAL CONTRACT</div>
<div class="contract-no">Contract No: #{{ str_pad($rental->id, 6, '0', STR_PAD_LEFT) }}</div>
</div>
<!-- Customer & Vehicle Info -->
<div class="two-col">
<div class="col">
<div class="section">
<div class="section-title">Customer Information</div>
<div class="info-grid">
<div class="info-row"><div class="info-label">Name:</div><div class="info-value">{{ $rental->customer->name }}</div></div>
<div class="info-row"><div class="info-label">Email:</div><div class="info-value">{{ $rental->customer->email }}</div></div>
<div class="info-row"><div class="info-label">Phone:</div><div class="info-value">{{ $rental->customer->phone }}</div></div>
<div class="info-row"><div class="info-label">License:</div><div class="info-value">{{ $rental->customer->license_number }}</div></div>
</div>
</div>
</div>
<div class="col">
<div class="section">
<div class="section-title">Vehicle Information</div>
<div class="info-grid">
<div class="info-row"><div class="info-label">Make & Model:</div><div class="info-value">{{ $rental->car->brand }} {{ $rental->car->model }}</div></div>
<div class="info-row"><div class="info-label">Year:</div><div class="info-value">{{ $rental->car->year }}</div></div>
<div class="info-row"><div class="info-label">Color:</div><div class="info-value">{{ $rental->car->color }}</div></div>
<div class="info-row"><div class="info-label">License Plate:</div><div class="info-value">{{ $rental->car->license_plate }}</div></div>
</div>
</div>
</div>
</div>
<!-- Rental Details -->
<div class="section">
<div class="section-title">Rental Details</div>
<div class="info-grid">
<div class="info-row"><div class="info-label">Rental Type:</div><div class="info-value" style="text-transform: capitalize;">{{ $rental->rental_type }}</div></div>
<div class="info-row"><div class="info-label">Pickup:</div><div class="info-value">{{ $rental->start_date->format('d M Y') }} @if($rental->pickup_time){{ $rental->pickup_time->format('H:i') }}@endif</div></div>
<div class="info-row"><div class="info-label">Return:</div><div class="info-value">{{ $rental->end_date->format('d M Y') }} @if($rental->return_time){{ $rental->return_time->format('H:i') }}@endif</div></div>
<div class="info-row"><div class="info-label">Status:</div><div class="info-value"><span class="status">{{ strtoupper($rental->status) }}</span></div></div>
</div>
</div>
<!-- Payment Summary -->
<div class="box">
<div>Total Rental Amount</div>
<div class="amount">{{ number_format($rental->total_amount, 3) }} BHD</div>
@if($rental->advance_payment > 0)
<div class="amount-small">
Advance Paid: {{ number_format($rental->advance_payment, 3) }} BHD |
Remaining: {{ number_format($rental->total_amount - $rental->advance_payment, 3) }} BHD
</div>
@endif
</div>
@if($rental->notes)
<div class="section">
<div class="section-title">Notes</div>
<p style="font-size: 10px; color: #6b7280;">{{ $rental->notes }}</p>
</div>
@endif
<!-- Signatures -->
<div class="signatures">
<div class="signature-box">
@if($rental->customer_signature)
<img src="{{ $rental->customer_signature }}" alt="Customer Signature" class="sig-img">
@else
<div style="height: 50px;"></div>
@endif
<div class="signature-line">Tenant Signature</div>
</div>
<div class="signature-box">
<div style="height: 50px;"></div>
<div class="signature-line">Company Representative</div>
</div>
</div>
<!-- Footer -->
<div class="footer">
<p>Generated by {{ config('settings.company_name') }} Car Rental Management System | {{ now()->format('d M Y H:i') }}</p>
<p>{{ config('settings.address') }} | {{ config('settings.phone') }} | {{ config('settings.email') }}</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,51 @@
@extends('layouts.app')
@section('title', 'Add Customer')
@section('content')
<div class="mb-8">
<a href="{{ route('customers.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Customers
</a>
<h2 class="text-3xl font-bold text-gray-800">Add New Customer</h2>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
<form action="{{ route('customers.store') }}" method="POST">
@csrf
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Full Name</label>
<input type="text" name="name" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Email</label>
<input type="email" name="email" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Phone</label>
<input type="text" name="phone" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">License Number</label>
<input type="text" name="license_number" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">License Expiry</label>
<input type="date" name="license_expiry" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Date of Birth</label>
<input type="date" name="dob" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div class="md:col-span-2">
<label class="block text-sm font-medium text-gray-700 mb-2">Address</label>
<input type="text" name="address" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
</div>
<div class="mt-6">
<button type="submit" class="bg-purple-600 text-white px-8 py-3 rounded-xl hover:bg-purple-700">Add Customer</button>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,60 @@
@extends('layouts.app')
@section('title', 'Edit Customer')
@section('content')
<div class="mb-8">
<a href="{{ route('customers.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Customers
</a>
<h2 class="text-3xl font-bold text-gray-800">Edit Customer</h2>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
<form action="{{ route('customers.update', $customer) }}" method="POST">
@csrf
@method('PUT')
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Full Name</label>
<input type="text" name="name" value="{{ $customer->name }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Email</label>
<input type="email" name="email" value="{{ $customer->email }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Phone</label>
<input type="text" name="phone" value="{{ $customer->phone }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">License Number</label>
<input type="text" name="license_number" value="{{ $customer->license_number }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">License Expiry</label>
<input type="date" name="license_expiry" value="{{ $customer->license_expiry }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Date of Birth</label>
<input type="date" name="dob" value="{{ $customer->dob }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Status</label>
<select name="status" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
<option value="active" {{ $customer->status == 'active' ? 'selected' : '' }}>Active</option>
<option value="inactive" {{ $customer->status == 'inactive' ? 'selected' : '' }}>Inactive</option>
<option value="blocked" {{ $customer->status == 'blocked' ? 'selected' : '' }}>Blocked</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Address</label>
<input type="text" name="address" value="{{ $customer->address }}" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
</div>
<div class="mt-6">
<button type="submit" class="bg-purple-600 text-white px-8 py-3 rounded-xl hover:bg-purple-700">Update Customer</button>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,67 @@
@extends('layouts.app')
@section('title', 'Customers')
@section('content')
<div class="flex justify-between items-center mb-6">
<div>
<h2 class="text-xl font-bold text-gray-800">Customers</h2>
<p class="text-gray-500 text-sm">Manage your customers</p>
</div>
<a href="{{ route('customers.create') }}" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 flex items-center gap-2 text-sm font-medium">
<i class="fas fa-plus"></i> Add Customer
</a>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<table class="w-full">
<thead class="bg-gray-50 border-b border-gray-200">
<tr>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Name</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Email</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Phone</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">License</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Status</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@forelse($customers as $customer)
<tr class="hover:bg-gray-50">
<td class="px-5 py-4">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-full bg-gray-200 flex items-center justify-center text-gray-600 font-semibold text-sm">
{{ substr($customer->name, 0, 1) }}
</div>
<p class="font-medium text-gray-800">{{ $customer->name }}</p>
</div>
</td>
<td class="px-5 py-4 text-gray-600 text-sm">{{ $customer->email }}</td>
<td class="px-5 py-4 text-gray-600 text-sm">{{ $customer->phone }}</td>
<td class="px-5 py-4 text-gray-600 text-sm">{{ $customer->license_number }}</td>
<td class="px-5 py-4">
<span class="px-2.5 py-1 rounded-full text-xs font-medium
{{ $customer->status == 'active' ? 'bg-green-100 text-green-700' :
($customer->status == 'inactive' ? 'bg-gray-100 text-gray-600' : 'bg-red-100 text-red-700') }}">
{{ ucfirst($customer->status) }}
</span>
</td>
<td class="px-5 py-4">
<a href="{{ route('customers.show', $customer) }}" class="text-blue-600 hover:text-blue-800 mr-3 text-sm"><i class="fas fa-eye"></i></a>
<a href="{{ route('customers.edit', $customer) }}" class="text-gray-600 hover:text-gray-800 mr-3 text-sm"><i class="fas fa-edit"></i></a>
<form action="{{ route('customers.destroy', $customer) }}" method="POST" class="inline">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-800 text-sm" onclick="return confirm('Are you sure?')"><i class="fas fa-trash"></i></button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="px-5 py-8 text-center text-gray-500">No customers yet</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@endsection

View File

@ -0,0 +1,82 @@
@extends('layouts.app')
@section('title', $customer->name)
@section('content')
<div class="mb-8">
<a href="{{ route('customers.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Customers
</a>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
<div class="flex items-center gap-4 mb-6">
<div class="w-16 h-16 rounded-full bg-gradient-to-br from-purple-400 to-pink-500 flex items-center justify-center text-white text-2xl font-bold">
{{ substr($customer->name, 0, 1) }}
</div>
<div>
<h2 class="text-2xl font-bold text-gray-800">{{ $customer->name }}</h2>
<span class="px-3 py-1 rounded-full text-sm font-medium
{{ $customer->status == 'active' ? 'bg-green-100 text-green-700' :
($customer->status == 'inactive' ? 'bg-gray-100 text-gray-700' : 'bg-red-100 text-red-700') }}">
{{ ucfirst($customer->status) }}
</span>
</div>
</div>
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
<div>
<p class="text-sm text-gray-500">Email</p>
<p class="font-medium text-gray-800">{{ $customer->email }}</p>
</div>
<div>
<p class="text-sm text-gray-500">Phone</p>
<p class="font-medium text-gray-800">{{ $customer->phone }}</p>
</div>
<div>
<p class="text-sm text-gray-500">License Number</p>
<p class="font-medium text-gray-800">{{ $customer->license_number }}</p>
</div>
<div>
<p class="text-sm text-gray-500">License Expiry</p>
<p class="font-medium text-gray-800">{{ $customer->license_expiry }}</p>
</div>
</div>
</div>
<div class="mt-6">
<h3 class="text-xl font-bold text-gray-800 mb-4">Rental History</h3>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
<table class="w-full">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Car</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Dates</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Amount</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Status</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@forelse($customer->rentals as $rental)
<tr>
<td class="px-6 py-4">{{ $rental->car->brand }} {{ $rental->car->model }}</td>
<td class="px-6 py-4">{{ $rental->start_date->format('M d') }} - {{ $rental->end_date->format('M d, Y') }}</td>
<td class="px-6 py-4"> BHD {{ number_format($rental->total_amount, 0) }}</td>
<td class="px-6 py-4">
<span class="px-2 py-1 rounded text-xs font-medium
{{ $rental->status == 'active' ? 'bg-green-100 text-green-700' :
($rental->status == 'pending' ? 'bg-amber-100 text-amber-700' : 'bg-gray-100 text-gray-700') }}">
{{ $rental->status }}
</span>
</td>
</tr>
@empty
<tr>
<td colspan="4" class="px-6 py-8 text-center text-gray-500">No rentals yet</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
@endsection

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title') - On The Road</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<script>
// Check for saved dark mode preference
if (localStorage.getItem('darkMode') === 'true' || (!localStorage.getItem('darkMode') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
}
</script>
</head>
<body class="bg-gray-100 dark:bg-slate-900 transition-colors">
<!-- Sidebar -->
<div class="fixed left-0 top-0 h-full w-64 bg-slate-800 dark:bg-slate-950 border-r border-slate-700">
<div class="p-5 border-b border-slate-700">
<h1 class="text-xl font-bold text-white flex items-center gap-2">
<i class="fas fa-road text-blue-400"></i>
On The Road
</h1>
<p class="text-slate-400 text-xs mt-1">Car Rental Management</p>
</div>
<nav class="mt-3 px-3">
<a href="{{ route('dashboard') }}" class="flex items-center gap-3 px-4 py-2.5 rounded-lg {{ request()->routeIs('dashboard') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }}">
<i class="fas fa-chart-line w-5"></i> Dashboard
</a>
<a href="{{ route('cars.index') }}" class="flex items-center gap-3 px-4 py-2.5 rounded-lg {{ request()->routeIs('cars.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-car w-5"></i> Fleet
</a>
<a href="{{ route('customers.index') }}" class="flex items-center gap-3 px-4 py-2.5 rounded-lg {{ request()->routeIs('customers.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-users w-5"></i> Customers
</a>
<a href="{{ route('rentals.index') }}" class="flex items-center gap-3 px-4 py-2.5 rounded-lg {{ request()->routeIs('rentals.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-calendar-check w-5"></i> Rentals
</a>
<a href="{{ route('services.index') }}" class="flex items-center gap-3 px-4 py-2.5 rounded-lg {{ request()->routeIs('services.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-tools w-5"></i> Services
</a>
<a href="{{ route('payments.index') }}" class="flex items-center gap-3 px-4 py-2.5 rounded-lg {{ request()->routeIs('payments.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-credit-card w-5"></i> Payments
</a>
</nav>
<!-- Dark Mode Toggle -->
<div class="absolute bottom-4 left-0 right-0 px-3">
<button onclick="toggleDarkMode()" class="w-full flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-slate-700 hover:bg-slate-600 text-white text-sm">
<i class="fas fa-moon" id="darkModeIcon"></i>
<span id="darkModeText">Dark Mode</span>
</button>
</div>
</div>
<!-- Main Content -->
<div class="ml-64 p-8">
@yield('content')
</div>
<script>
function toggleDarkMode() {
document.documentElement.classList.toggle('dark');
localStorage.setItem('darkMode', document.documentElement.classList.contains('dark'));
updateDarkModeButton();
}
function updateDarkModeButton() {
const isDark = document.documentElement.classList.contains('dark');
document.getElementById('darkModeIcon').className = isDark ? 'fas fa-sun w-5' : 'fas fa-moon w-5';
document.getElementById('darkModeText').textContent = isDark ? 'Light Mode' : 'Dark Mode';
}
// Initialize button state
updateDarkModeButton();
</script>
</body>
</html>

View File

@ -0,0 +1,58 @@
@extends('layouts.app')
@section('title', 'Record Payment')
@section('content')
<div class="mb-8">
<a href="{{ route('payments.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Payments
</a>
<h2 class="text-3xl font-bold text-gray-800">Record Payment</h2>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
<form action="{{ route('payments.store') }}" method="POST">
@csrf
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Rental</label>
<select name="rental_id" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-cyan-500">
<option value="">Select a rental</option>
@foreach($rentals as $rental)
<option value="{{ $rental->id }}">{{ $rental->car->brand }} {{ $rental->car->model }} - {{ $rental->customer->name }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Amount (BHD)</label>
<input type="number" name="amount" step="0.01" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-cyan-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Method</label>
<select name="method" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-cyan-500">
<option value="cash">Cash</option>
<option value="card">Card</option>
<option value="bank_transfer">Bank Transfer</option>
<option value="online">Online</option>
<option value="other">Other</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Status</label>
<select name="status" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-cyan-500">
<option value="completed">Completed</option>
<option value="pending">Pending</option>
<option value="failed">Failed</option>
</select>
</div>
<div class="md:col-span-2">
<label class="block text-sm font-medium text-gray-700 mb-2">Transaction ID (Optional)</label>
<input type="text" name="transaction_id" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-cyan-500">
</div>
</div>
<div class="mt-6">
<button type="submit" class="bg-cyan-600 text-white px-8 py-3 rounded-xl hover:bg-cyan-700">Record Payment</button>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,50 @@
@extends('layouts.app')
@section('title', 'Payments')
@section('content')
<div class="flex justify-between items-center mb-6">
<div>
<h2 class="text-xl font-bold text-gray-800">Payments</h2>
<p class="text-gray-500 text-sm">Track payments</p>
</div>
<a href="{{ route('payments.create') }}" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 flex items-center gap-2 text-sm font-medium">
<i class="fas fa-plus"></i> Record Payment
</a>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<table class="w-full">
<thead class="bg-gray-50 border-b border-gray-200">
<tr>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Rental</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Amount</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Method</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Status</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Date</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@forelse($payments as $payment)
<tr class="hover:bg-gray-50">
<td class="px-5 py-4 text-gray-800 text-sm">{{ $payment->rental->car->brand }} {{ $payment->rental->car->model }}</td>
<td class="px-5 py-4 font-medium text-gray-800 text-sm"> BHD {{ number_format($payment->amount, 0) }}</td>
<td class="px-5 py-4 text-gray-600 text-sm capitalize">{{ $payment->method }}</td>
<td class="px-5 py-4">
<span class="px-2.5 py-1 rounded-full text-xs font-medium
{{ $payment->status == 'completed' ? 'bg-green-100 text-green-700' :
($payment->status == 'pending' ? 'bg-amber-100 text-amber-700' : 'bg-red-100 text-red-700') }}">
{{ ucfirst($payment->status) }}
</span>
</td>
<td class="px-5 py-4 text-gray-600 text-sm">{{ $payment->created_at->format('M d, Y') }}</td>
</tr>
@empty
<tr>
<td colspan="5" class="px-5 py-8 text-center text-gray-500">No payments recorded</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@endsection

View File

@ -0,0 +1,65 @@
@extends('layouts.app')
@section('title', 'Payment Details')
@section('content')
<div class="mb-6">
<a href="{{ route('payments.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Payments
</a>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold text-gray-800">Payment #{{ $payment->id }}</h2>
<span class="px-3 py-1 rounded-full text-sm font-medium
{{ $payment->status == 'completed' ? 'bg-green-100 text-green-700' :
($payment->status == 'pending' ? 'bg-amber-100 text-amber-700' : 'bg-red-100 text-red-700') }}">
{{ ucfirst($payment->status) }}
</span>
</div>
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Amount</p>
<p class="text-2xl font-bold text-gray-800"> BHD {{ number_format($payment->amount, 0) }}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Method</p>
<p class="font-semibold text-gray-800 capitalize">{{ $payment->method }}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Rental</p>
<a href="{{ route('rentals.show', $payment->rental) }}" class="font-semibold text-blue-600 hover:underline">
{{ $payment->rental->car->brand }} {{ $payment->rental->car->model }}
</a>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Date</p>
<p class="font-semibold text-gray-800">{{ $payment->created_at->format('M d, Y') }}</p>
</div>
</div>
@if($payment->transaction_id)
<div class="border-t pt-4">
<p class="text-gray-500 text-sm mb-1">Transaction ID</p>
<p class="text-gray-700 font-mono">{{ $payment->transaction_id }}</p>
</div>
@endif
@if($payment->notes)
<div class="border-t pt-4 mt-4">
<p class="text-gray-500 text-sm mb-1">Notes</p>
<p class="text-gray-700">{{ $payment->notes }}</p>
</div>
@endif
<div class="flex gap-3 mt-6">
<form action="{{ route('payments.destroy', $payment) }}" method="POST">
@csrf
@method('DELETE')
<button type="submit" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 text-sm" onclick="return confirm('Delete this payment?')">Delete Payment</button>
</form>
</div>
</div>
@endsection

View File

@ -0,0 +1,143 @@
@extends('layouts.app')
@section('title', 'New Rental')
@section('content')
<div class="mb-8">
<a href="{{ route('rentals.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Rentals
</a>
<h2 class="text-3xl font-bold text-gray-800">New Rental</h2>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
<form action="{{ route('rentals.store') }}" method="POST" id="rentalForm">
@csrf
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Car</label>
<select name="car_id" id="carSelect" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-amber-500">
<option value="">Select a car</option>
@foreach($cars as $car)
<option value="{{ $car->id }}" data-daily-rate="{{ $car->daily_rate }}">{{ $car->brand }} {{ $car->model }} - BHD {{ $car->daily_rate }}/day</option>
@endforeach
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Customer</label>
<select name="customer_id" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-amber-500">
<option value="">Select a customer</option>
@foreach($customers as $customer)
<option value="{{ $customer->id }}">{{ $customer->name }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Rental Type</label>
<select name="rental_type" id="rentalType" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-amber-500">
<option value="daily" data-days="1">Daily</option>
<option value="weekly" data-days="7">Weekly</option>
<option value="monthly" data-days="30">Monthly</option>
<option value="lease" data-days="365">Lease (1 Year)</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Start Date</label>
<input type="date" name="start_date" id="startDate" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-amber-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Pickup Time</label>
<input type="time" name="pickup_time" id="pickupTime" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-amber-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">End Date</label>
<input type="date" name="end_date" id="endDate" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-amber-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Return Time</label>
<input type="time" name="return_time" id="returnTime" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-amber-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Total Amount (BHD)</label>
<input type="number" name="total_amount" id="totalAmount" step="0.01" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-amber-500" readonly>
<p class="text-xs text-gray-500 mt-1" id="priceInfo">Select a car to see pricing</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Advance Payment (BHD)</label>
<input type="number" name="advance_payment" id="advancePayment" step="0.01" value="0" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-amber-500">
</div>
<div class="md:col-span-2">
<label class="block text-sm font-medium text-gray-700 mb-2">Notes</label>
<textarea name="notes" rows="3" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-amber-500"></textarea>
</div>
</div>
<div class="mt-6">
<button type="submit" class="bg-amber-600 text-white px-8 py-3 rounded-xl hover:bg-amber-700">Create Rental</button>
</div>
</form>
</div>
<script>
const carSelect = document.getElementById('carSelect');
const rentalType = document.getElementById('rentalType');
const startDate = document.getElementById('startDate');
const endDate = document.getElementById('endDate');
const totalAmount = document.getElementById('totalAmount');
const priceInfo = document.getElementById('priceInfo');
const advancePayment = document.getElementById('advancePayment');
// Pricing multipliers for each rental type
const pricing = {
daily: 1,
weekly: 0.9, // 10% discount
monthly: 0.8, // 20% discount
lease: 0.7 // 30% discount
};
function calculatePrice() {
const selectedOption = carSelect.options[carSelect.selectedIndex];
const dailyRate = parseFloat(selectedOption.dataset.dailyRate) || 0;
const rentalTypeOption = rentalType.options[rentalType.selectedIndex];
const days = parseInt(rentalTypeOption.dataset.days) || 1;
if (!dailyRate || !days) {
priceInfo.textContent = 'Select a car and rental type to see pricing';
return;
}
const multiplier = pricing[rentalType.value];
let total = 0;
let infoText = '';
if (rentalType.value === 'lease') {
total = dailyRate * days * multiplier;
infoText = `Lease (365 days) @ BHD ${dailyRate}/day with ${(1-multiplier)*100}% discount`;
} else {
// Calculate based on actual dates if available
if (startDate.value && endDate.value) {
const start = new Date(startDate.value);
const end = new Date(endDate.value);
const diffTime = Math.abs(end - start);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1;
total = dailyRate * diffDays * multiplier;
infoText = `${diffDays} days @ BHD ${dailyRate}/day with ${(1-multiplier)*100}% discount`;
} else {
total = dailyRate * days * multiplier;
infoText = `${days} days @ BHD ${dailyRate}/day with ${(1-multiplier)*100}% discount`;
}
}
totalAmount.value = total.toFixed(2);
priceInfo.textContent = infoText;
// Auto-set advance payment to 50% of total
advancePayment.value = (total * 0.5).toFixed(2);
}
carSelect.addEventListener('change', calculatePrice);
rentalType.addEventListener('change', calculatePrice);
startDate.addEventListener('change', calculatePrice);
endDate.addEventListener('change', calculatePrice);
</script>
@endsection

View File

@ -0,0 +1,126 @@
@extends('layouts.app')
@section('title', 'Rentals')
@section('content')
<div class="flex justify-between items-center mb-6">
<div>
<h2 class="text-xl font-bold text-gray-800">Rentals</h2>
<p class="text-gray-500 text-sm">Manage rentals</p>
</div>
<a href="{{ route('rentals.create') }}" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 flex items-center gap-2 text-sm font-medium">
<i class="fas fa-plus"></i> New Rental
</a>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<table class="w-full">
<thead class="bg-gray-50 border-b border-gray-200">
<tr>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Car</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Type</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Customer</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Dates</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Amount</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Status</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@forelse($rentals as $rental)
<tr class="hover:bg-gray-50">
<td class="px-5 py-4 text-gray-800 text-sm">{{ $rental->car->brand }} {{ $rental->car->model }}</td>
<td class="px-5 py-4">
<span class="px-2 py-1 rounded text-xs font-medium bg-blue-100 text-blue-700 capitalize">{{ $rental->rental_type }}</span>
</td>
<td class="px-5 py-4 text-gray-600 text-sm">{{ $rental->customer->name }}</td>
<td class="px-5 py-4 text-gray-600 text-sm">
@if($rental->pickup_time)
{{ $rental->start_date->format('M d') }} {{ $rental->pickup_time->format('H:i') }}
@else
{{ $rental->start_date->format('M d') }}
@endif
-
@if($rental->return_time)
{{ $rental->end_date->format('M d') }} {{ $rental->return_time->format('H:i') }}
@else
{{ $rental->end_date->format('M d, Y') }}
@endif
</td>
<td class="px-5 py-4 text-gray-800 font-medium text-sm"> BHD {{ number_format($rental->total_amount, 0) }}</td>
<td class="px-5 py-4">
<span class="px-2.5 py-1 rounded-full text-xs font-medium
{{ $rental->status == 'active' ? 'bg-green-100 text-green-700' :
($rental->status == 'pending' ? 'bg-amber-100 text-amber-700' : 'bg-gray-100 text-gray-600') }}">
{{ ucfirst($rental->status) }}
</span>
</td>
<td class="px-5 py-4">
<button type="button" class="text-blue-600 hover:text-blue-800 mr-2 text-sm" title="View Contract" onclick="showContractModal({{ $rental->id }})"><i class="fas fa-file-alt"></i></button>
<a href="{{ route('rentals.contract.download', $rental) }}" class="text-red-600 hover:text-red-800 mr-3 text-sm" title="Download PDF"><i class="fas fa-file-pdf"></i></a>
<a href="{{ route('rentals.show', $rental) }}" class="text-green-600 hover:text-green-800 mr-3 text-sm"><i class="fas fa-eye"></i></a>
<a href="{{ route('rentals.updateStatus', [$rental, 'completed']) }}"
class="text-green-600 hover:text-green-800 mr-2 text-sm"
title="Complete"
onclick="return confirm('Mark this rental as completed?')">
<i class="fas fa-check"></i>
</a>
<form action="{{ route('rentals.destroy', $rental) }}" method="POST" class="inline">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-800 text-sm" onclick="return confirm('Cancel this rental?')"><i class="fas fa-trash"></i></button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="7" class="px-5 py-8 text-center text-gray-500">No rentals yet</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<!-- Contract Modal -->
<div id="contractModal" class="fixed inset-0 bg-black bg-opacity-50 hidden z-50 flex items-center justify-center">
<div class="bg-white rounded-lg shadow-xl w-full max-w-4xl max-h-[90vh] overflow-hidden">
<div class="flex justify-between items-center px-6 py-4 border-b">
<h3 class="text-lg font-semibold">Rental Contract</h3>
<div>
<a id="modalDownloadBtn" href="#" class="text-red-600 hover:text-red-800 mr-4 text-sm"><i class="fas fa-download mr-1"></i> Download PDF</a>
<button type="button" onclick="closeContractModal()" class="text-gray-500 hover:text-gray-700"><i class="fas fa-times text-xl"></i></button>
</div>
</div>
<div class="p-0 overflow-auto max-h-[calc(90vh-80px)]">
<iframe id="contractFrame" src="" class="w-full h-[70vh] border-0"></iframe>
</div>
</div>
</div>
<script>
function showContractModal(rentalId) {
const modal = document.getElementById('contractModal');
const frame = document.getElementById('contractFrame');
const downloadBtn = document.getElementById('modalDownloadBtn');
frame.src = '/rentals/' + rentalId + '/contract';
downloadBtn.href = '/rentals/' + rentalId + '/contract/download';
modal.classList.remove('hidden');
}
function closeContractModal() {
document.getElementById('contractModal').classList.add('hidden');
document.getElementById('contractFrame').src = '';
}
// Close modal on outside click
document.getElementById('contractModal').addEventListener('click', function(e) {
if (e.target === this) closeContractModal();
});
// Close modal on Escape key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') closeContractModal();
});
</script>
@endsection

View File

@ -0,0 +1,187 @@
@extends('layouts.app')
@section('title', 'Rental Details')
@section('content')
<div class="mb-6">
<a href="{{ route('rentals.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Rentals
</a>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Rental Details -->
<div class="lg:col-span-2">
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<div class="flex items-center justify-between mb-6">
<div>
<h2 class="text-xl font-bold text-gray-800">Rental #{{ $rental->id }}</h2>
<span class="px-2 py-1 rounded text-xs font-medium bg-blue-100 text-blue-700 capitalize">{{ $rental->rental_type }}</span>
</div>
<div class="flex items-center gap-3">
<button type="button" onclick="showContractModal({{ $rental->id }})" class="text-blue-600 hover:text-blue-800 p-2" title="View Contract"><i class="fas fa-file-alt text-lg"></i></button>
<a href="{{ route('rentals.contract.download', $rental) }}" class="text-red-600 hover:text-red-800 p-2" title="Download PDF"><i class="fas fa-file-pdf text-lg"></i></a>
<span class="px-3 py-1 rounded-full text-sm font-medium
{{ $rental->status == 'active' ? 'bg-green-100 text-green-700' :
($rental->status == 'pending' ? 'bg-amber-100 text-amber-700' : 'bg-gray-100 text-gray-600') }}">
{{ ucfirst($rental->status) }}
</span>
</div>
</div>
<div class="grid grid-cols-2 gap-4 mb-6">
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Car</p>
<p class="font-semibold text-gray-800">{{ $rental->car->brand }} {{ $rental->car->model }}</p>
<p class="text-gray-500 text-sm">{{ $rental->car->license_plate }}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Customer</p>
<p class="font-semibold text-gray-800">{{ $rental->customer->name }}</p>
<p class="text-gray-500 text-sm">{{ $rental->customer->phone }}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Start Date</p>
<p class="font-semibold text-gray-800">
{{ $rental->start_date->format('M d, Y') }}
@if($rental->pickup_time)
<span class="text-blue-600">@ {{ $rental->pickup_time->format('H:i') }}</span>
@endif
</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">End Date</p>
<p class="font-semibold text-gray-800">
{{ $rental->end_date->format('M d, Y') }}
@if($rental->return_time)
<span class="text-blue-600">@ {{ $rental->return_time->format('H:i') }}</span>
@endif
</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Total Amount</p>
<p class="font-semibold text-gray-800"> BHD {{ number_format($rental->total_amount, 0) }}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Advance Payment</p>
<p class="font-semibold text-gray-800"> BHD {{ number_format($rental->advance_payment, 0) }}</p>
</div>
</div>
@if($rental->notes)
<div class="border-t pt-4">
<p class="text-gray-500 text-sm mb-1">Notes</p>
<p class="text-gray-700">{{ $rental->notes }}</p>
</div>
@endif
<div class="flex gap-3 mt-6">
@if($rental->status != 'completed')
<a href="{{ route('rentals.updateStatus', [$rental, 'completed']) }}"
class="bg-green-600 text-white px-4 py-2 rounded-lg hover:bg-green-700 text-sm inline-block"
onclick="return confirm('Mark this rental as completed?')">
Mark Completed
</a>
@endif
<form action="{{ route('rentals.destroy', $rental) }}" method="POST">
@csrf
@method('DELETE')
<button type="submit" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 text-sm" onclick="return confirm('Cancel this rental?')">Cancel Rental</button>
</form>
</div>
</div>
</div>
<!-- Sidebar -->
<div>
<!-- Car Card -->
<a href="{{ route('cars.show', $rental->car) }}" class="block bg-white rounded-xl shadow-sm border border-gray-200 p-4 mb-4 hover:border-blue-400 transition">
<h3 class="font-semibold text-gray-800 mb-2">Car Details</h3>
<div class="flex items-center gap-3">
<div class="w-12 h-12 rounded-lg bg-blue-100 flex items-center justify-center">
<i class="fas fa-car text-blue-600"></i>
</div>
<div>
<p class="font-medium text-gray-800">{{ $rental->car->brand }} {{ $rental->car->model }}</p>
<p class="text-sm text-gray-500">{{ $rental->car->year }} {{ $rental->car->color }}</p>
</div>
</div>
</a>
<!-- Customer Card -->
<a href="{{ route('customers.show', $rental->customer) }}" class="block bg-white rounded-xl shadow-sm border border-gray-200 p-4 mb-4 hover:border-purple-400 transition">
<h3 class="font-semibold text-gray-800 mb-2">Customer Details</h3>
<div class="flex items-center gap-3">
<div class="w-12 h-12 rounded-full bg-gray-200 flex items-center justify-center">
<span class="text-gray-600 font-semibold">{{ substr($rental->customer->name, 0, 1) }}</span>
</div>
<div>
<p class="font-medium text-gray-800">{{ $rental->customer->name }}</p>
<p class="text-sm text-gray-500">{{ $rental->customer->phone }}</p>
</div>
</div>
</a>
<!-- Payments -->
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-4">
<h3 class="font-semibold text-gray-800 mb-3">Payments</h3>
@forelse($rental->payments as $payment)
<div class="flex justify-between items-center py-2 border-b last:border-0">
<div>
<p class="text-gray-800 text-sm"> BHD {{ number_format($payment->amount, 0) }}</p>
<p class="text-gray-500 text-xs">{{ $payment->method }}</p>
</div>
<span class="px-2 py-1 rounded text-xs font-medium
{{ $payment->status == 'completed' ? 'bg-green-100 text-green-700' : 'bg-amber-100 text-amber-700' }}">
{{ $payment->status }}
</span>
</div>
@empty
<p class="text-gray-500 text-sm">No payments yet</p>
@endforelse
<a href="{{ route('payments.create') }}?rental_id={{ $rental->id }}" class="block w-full bg-blue-600 text-white text-center py-2 rounded-lg mt-3 hover:bg-blue-700 text-sm">Add Payment</a>
</div>
</div>
</div>
<!-- Contract Modal -->
<div id="contractModal" class="fixed inset-0 bg-black bg-opacity-50 hidden z-50 flex items-center justify-center">
<div class="bg-white rounded-lg shadow-xl w-full max-w-4xl max-h-[90vh] overflow-hidden">
<div class="flex justify-between items-center px-6 py-4 border-b">
<h3 class="text-lg font-semibold">Rental Contract</h3>
<div>
<a id="modalDownloadBtn" href="#" class="text-red-600 hover:text-red-800 mr-4 text-sm"><i class="fas fa-download mr-1"></i> Download PDF</a>
<button type="button" onclick="closeContractModal()" class="text-gray-500 hover:text-gray-700"><i class="fas fa-times text-xl"></i></button>
</div>
</div>
<div class="p-0 overflow-auto max-h-[calc(90vh-80px)]">
<iframe id="contractFrame" src="" class="w-full h-[70vh] border-0"></iframe>
</div>
</div>
</div>
<script>
function showContractModal(rentalId) {
const modal = document.getElementById('contractModal');
const frame = document.getElementById('contractFrame');
const downloadBtn = document.getElementById('modalDownloadBtn');
frame.src = '/rentals/' + rentalId + '/contract';
downloadBtn.href = '/rentals/' + rentalId + '/contract/download';
modal.classList.remove('hidden');
}
function closeContractModal() {
document.getElementById('contractModal').classList.add('hidden');
document.getElementById('contractFrame').src = '';
}
document.getElementById('contractModal').addEventListener('click', function(e) {
if (e.target === this) closeContractModal();
});
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') closeContractModal();
});
</script>
@endsection

View File

@ -0,0 +1,56 @@
@extends('layouts.app')
@section('title', 'Schedule Service')
@section('content')
<div class="mb-8">
<a href="{{ route('services.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Services
</a>
<h2 class="text-3xl font-bold text-gray-800">Schedule Service</h2>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
<form action="{{ route('services.store') }}" method="POST">
@csrf
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Car</label>
<select name="car_id" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
<option value="">Select a car</option>
@foreach($cars as $car)
<option value="{{ $car->id }}">{{ $car->brand }} {{ $car->model }} ({{ $car->license_plate }})</option>
@endforeach
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Service Type</label>
<select name="type" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
<option value="oil_change">Oil Change</option>
<option value="tire_rotation">Tire Rotation</option>
<option value="brake_service">Brake Service</option>
<option value="general_checkup">General Checkup</option>
<option value="repair">Repair</option>
<option value="insurance">Insurance</option>
<option value="other">Other</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Service Date</label>
<input type="date" name="service_date" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Cost (BHD)</label>
<input type="number" name="cost" step="0.01" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500">
</div>
<div class="md:col-span-2">
<label class="block text-sm font-medium text-gray-700 mb-2">Description</label>
<textarea name="description" rows="3" required class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500"></textarea>
</div>
</div>
<div class="mt-6">
<button type="submit" class="bg-purple-600 text-white px-8 py-3 rounded-xl hover:bg-purple-700">Record Service</button>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,49 @@
@extends('layouts.app')
@section('title', 'Services')
@section('content')
<div class="flex justify-between items-center mb-6">
<div>
<h2 class="text-xl font-bold text-gray-800">Services</h2>
<p class="text-gray-500 text-sm">Track maintenance & services</p>
</div>
<a href="{{ route('services.create') }}" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 flex items-center gap-2 text-sm font-medium">
<i class="fas fa-plus"></i> Schedule Service
</a>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<table class="w-full">
<thead class="bg-gray-50 border-b border-gray-200">
<tr>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Car</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Type</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Date</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Cost</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Status</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@forelse($services as $service)
<tr class="hover:bg-gray-50">
<td class="px-5 py-4 text-gray-800 text-sm">{{ $service->car->brand }} {{ $service->car->model }}</td>
<td class="px-5 py-4 text-gray-600 text-sm capitalize">{{ str_replace('_', ' ', $service->type) }}</td>
<td class="px-5 py-4 text-gray-600 text-sm">{{ $service->service_date->format('M d, Y') }}</td>
<td class="px-5 py-4 text-gray-800 font-medium text-sm"> BHD {{ number_format($service->cost, 0) }}</td>
<td class="px-5 py-4">
<span class="px-2.5 py-1 rounded-full text-xs font-medium
{{ $service->status == 'completed' ? 'bg-green-100 text-green-700' : 'bg-amber-100 text-amber-700' }}">
{{ ucfirst($service->status) }}
</span>
</td>
</tr>
@empty
<tr>
<td colspan="5" class="px-5 py-8 text-center text-gray-500">No services recorded</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@endsection

View File

@ -0,0 +1,86 @@
@extends('layouts.app')
@section('title', 'Service Details')
@section('content')
<div class="mb-6">
<a href="{{ route('services.index') }}" class="text-blue-600 hover:text-blue-800 flex items-center gap-2 mb-4">
<i class="fas fa-arrow-left"></i> Back to Services
</a>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<div class="lg:col-span-2">
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold text-gray-800">Service #{{ $service->id }}</h2>
<span class="px-3 py-1 rounded-full text-sm font-medium
{{ $service->status == 'completed' ? 'bg-green-100 text-green-700' : 'bg-amber-100 text-amber-700' }}">
{{ ucfirst($service->status) }}
</span>
</div>
<div class="grid grid-cols-2 gap-4 mb-6">
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Car</p>
<p class="font-semibold text-gray-800">{{ $service->car->brand }} {{ $service->car->model }}</p>
<p class="text-gray-500 text-sm">{{ $service->car->license_plate }}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Service Type</p>
<p class="font-semibold text-gray-800 capitalize">{{ str_replace('_', ' ', $service->type) }}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Service Date</p>
<p class="font-semibold text-gray-800">{{ $service->service_date->format('M d, Y') }}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Cost</p>
<p class="font-semibold text-gray-800"> BHD {{ number_format($service->cost, 0) }}</p>
</div>
@if($service->next_service_date)
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Next Service</p>
<p class="font-semibold text-gray-800">{{ $service->next_service_date->format('M d, Y') }}</p>
</div>
@endif
@if($service->mileage_at_service)
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-gray-500 text-sm">Mileage</p>
<p class="font-semibold text-gray-800">{{ number_format($service->mileage_at_service) }} km</p>
</div>
@endif
</div>
<div class="border-t pt-4">
<p class="text-gray-500 text-sm mb-1">Description</p>
<p class="text-gray-700">{{ $service->description }}</p>
</div>
<div class="flex gap-3 mt-6">
<a href="{{ route('services.edit', $service) }}" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 text-sm">Edit Service</a>
<form action="{{ route('services.destroy', $service) }}" method="POST">
@csrf
@method('DELETE')
<button type="submit" class="bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 text-sm" onclick="return confirm('Delete this service?')">Delete Service</button>
</form>
</div>
</div>
</div>
<div>
<a href="{{ route('cars.show', $service->car) }}" class="block bg-white rounded-xl shadow-sm border border-gray-200 p-4 hover:border-blue-400 transition">
<h3 class="font-semibold text-gray-800 mb-2">Car Details</h3>
<div class="flex items-center gap-3">
<div class="w-12 h-12 rounded-lg bg-blue-100 flex items-center justify-center">
<i class="fas fa-car text-blue-600"></i>
</div>
<div>
<p class="font-medium text-gray-800">{{ $service->car->brand }} {{ $service->car->model }}</p>
<p class="text-sm text-gray-500">{{ $service->car->license_plate }}</p>
</div>
</div>
</a>
</div>
</div>
@endsection

View File

@ -0,0 +1,125 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Settings - {{ config('settings.company_name') }}</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<script>
if (localStorage.getItem('darkMode') === 'true' || (!localStorage.getItem('darkMode') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
}
</script>
</head>
<body class="bg-gray-100 dark:bg-slate-900 min-h-screen transition-colors">
<!-- Sidebar -->
<div class="fixed left-0 top-0 h-full w-64 bg-slate-800">
<div class="p-6 border-b border-slate-700">
<h1 class="text-xl font-bold text-white flex items-center gap-2">
<i class="fas fa-road text-blue-400"></i>
{{ config('settings.company_name') }}
</h1>
<p class="text-slate-400 text-xs mt-1">{{ config('settings.company_tagline') }}</p>
</div>
<nav class="mt-4 px-4">
<a href="{{ route('dashboard') }}" class="flex items-center gap-3 px-4 py-3 rounded-lg {{ request()->routeIs('dashboard') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }}">
<i class="fas fa-chart-line w-5"></i> Dashboard
</a>
<a href="{{ route('cars.index') }}" class="flex items-center gap-3 px-4 py-3 rounded-lg {{ request()->routeIs('cars.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-car w-5"></i> Fleet
</a>
<a href="{{ route('customers.index') }}" class="flex items-center gap-3 px-4 py-3 rounded-lg {{ request()->routeIs('customers.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-users w-5"></i> Customers
</a>
<a href="{{ route('rentals.index') }}" class="flex items-center gap-3 px-4 py-3 rounded-lg {{ request()->routeIs('rentals.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-calendar-check w-5"></i> Rentals
</a>
<a href="{{ route('services.index') }}" class="flex items-center gap-3 px-4 py-3 rounded-lg {{ request()->routeIs('services.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-tools w-5"></i> Services
</a>
<a href="{{ route('payments.index') }}" class="flex items-center gap-3 px-4 py-3 rounded-lg {{ request()->routeIs('payments.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-credit-card w-5"></i> Payments
</a>
<a href="{{ route('settings.index') }}" class="flex items-center gap-3 px-4 py-3 rounded-lg {{ request()->routeIs('settings.*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-700' }} mt-1">
<i class="fas fa-cog w-5"></i> Settings
</a>
</nav>
</div>
<!-- Main Content -->
<div class="ml-64 p-8">
<div class="max-w-2xl mx-auto">
<h2 class="text-2xl font-bold text-gray-800 dark:text-white mb-6">Settings</h2>
@if(session('success'))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4">
{{ session('success') }}
</div>
@endif
<!-- Logo Upload -->
<div class="bg-white dark:bg-slate-800 rounded-lg shadow p-6 mb-6">
<h3 class="text-lg font-semibold text-gray-800 dark:text-white mb-4">Company Logo</h3>
<div class="flex items-center gap-6">
<div class="w-32 h-32 bg-gray-100 dark:bg-slate-700 rounded-lg flex items-center justify-center overflow-hidden">
@if(config('settings.logo'))
<img src="{{ asset(config('settings.logo')) }}" alt="Logo" class="max-w-full max-h-full object-contain">
@else
<i class="fas fa-image text-4xl text-gray-400"></i>
@endif
</div>
<form action="{{ route('settings.logo') }}" method="POST" enctype="multipart/form-data" class="flex-1">
@csrf
<input type="file" name="logo" accept="image/*" class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100 mb-3">
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700">
<i class="fas fa-upload mr-2"></i> Upload Logo
</button>
<p class="text-xs text-gray-500 mt-2">PNG, JPG, GIF, SVG. Max 2MB. Recommended: 200x60px</p>
</form>
</div>
</div>
<!-- Company Info -->
<div class="bg-white dark:bg-slate-800 rounded-lg shadow p-6">
<h3 class="text-lg font-semibold text-gray-800 dark:text-white mb-4">Company Information</h3>
<form action="{{ route('settings.update') }}" method="POST">
@csrf
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Company Name</label>
<input type="text" name="company_name" value="{{ config('settings.company_name') }}" required
class="w-full px-4 py-2 border rounded-lg dark:bg-slate-700 dark:border-slate-600 dark:text-white">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Tagline</label>
<input type="text" name="company_tagline" value="{{ config('settings.company_tagline') }}"
class="w-full px-4 py-2 border rounded-lg dark:bg-slate-700 dark:border-slate-600 dark:text-white">
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Phone</label>
<input type="text" name="phone" value="{{ config('settings.phone') }}"
class="w-full px-4 py-2 border rounded-lg dark:bg-slate-700 dark:border-slate-600 dark:text-white">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Email</label>
<input type="email" name="email" value="{{ config('settings.email') }}"
class="w-full px-4 py-2 border rounded-lg dark:bg-slate-700 dark:border-slate-600 dark:text-white">
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Address</label>
<input type="text" name="address" value="{{ config('settings.address') }}"
class="w-full px-4 py-2 border rounded-lg dark:bg-slate-700 dark:border-slate-600 dark:text-white">
</div>
</div>
<button type="submit" class="mt-4 bg-blue-600 text-white px-6 py-2 rounded-lg hover:bg-blue-700">
<i class="fas fa-save mr-2"></i> Save Changes
</button>
</form>
</div>
</div>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

8
routes/console.php Normal file
View File

@ -0,0 +1,8 @@
<?php
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');

37
routes/web.php Normal file
View File

@ -0,0 +1,37 @@
<?php
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\CarController;
use App\Http\Controllers\CustomerController;
use App\Http\Controllers\RentalController;
use App\Http\Controllers\ServiceController;
use App\Http\Controllers\PaymentController;
use App\Http\Controllers\QuickRentalController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\SettingsController;
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
// Settings
Route::get('/settings', [SettingsController::class, 'index'])->name('settings.index');
Route::post('/settings', [SettingsController::class, 'update'])->name('settings.update');
Route::post('/settings/logo', [SettingsController::class, 'uploadLogo'])->name('settings.logo');
Route::resource('cars', CarController::class);
Route::resource('customers', CustomerController::class);
Route::resource('rentals', RentalController::class);
Route::resource('services', ServiceController::class);
Route::resource('payments', PaymentController::class);
// Quick Rental routes
Route::get('/quick-rental/customers', [QuickRentalController::class, 'getCustomers']);
Route::get('/quick-rental/cars', [QuickRentalController::class, 'getCars']);
Route::post('/quick-rental/store', [QuickRentalController::class, 'store']);
Route::get('/quick-rental/contract/{id}', [QuickRentalController::class, 'generateContract']);
// Quick actions
Route::match(['patch', 'get'], '/rentals/{rental}/status/{status}', [RentalController::class, 'updateStatus'])->name('rentals.updateStatus');
Route::get('/rentals/{rental}/contract', [RentalController::class, 'contract'])->name('rentals.contract');
Route::get('/rentals/{rental}/contract/download', [RentalController::class, 'downloadContract'])->name('rentals.contract.download');
Route::match(['patch', 'get'], '/cars/{car}/status/{status}', [CarController::class, 'updateStatus'])->name('cars.updateStatus');

4
storage/app/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*
!private/
!public/
!.gitignore

2
storage/app/private/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/app/public/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

9
storage/framework/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
compiled.php
config.php
down
events.scanned.php
maintenance.php
routes.php
routes.scanned.php
schedule-*
services.json

3
storage/framework/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*
!data/
!.gitignore

View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/framework/sessions/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/framework/testing/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/framework/views/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/logs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -0,0 +1,19 @@
<?php
namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');
$response->assertStatus(200);
}
}

10
tests/TestCase.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
//
}

View File

@ -0,0 +1,16 @@
<?php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}

18
vite.config.js Normal file
View File

@ -0,0 +1,18 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
tailwindcss(),
],
server: {
watch: {
ignored: ['**/storage/framework/views/**'],
},
},
});