Project Introduction
The Personal Finance Manager is a comprehensive software application designed to help individuals manage their finances effectively. This system aims to provide users with tools to track their income, expenses, savings, and investments, enabling them to make informed financial decisions. With the increasing complexity of personal finance management and the need for financial literacy, the Personal Finance Manager addresses these challenges by offering a user-friendly interface and robust functionalities.
The application features budgeting tools, expense tracking, financial goal setting, and reporting capabilities. Users can easily categorize their expenses, set budgets for different categories, and monitor their progress towards financial goals. Additionally, the system includes visual analytics to help users understand their spending habits and make adjustments as needed. By automating these processes, the Personal Finance Manager aims to empower users to take control of their financial health and achieve their financial objectives.
Project Objectives
- To develop an intuitive interface for users to manage their personal finances easily.
- To implement budgeting tools that allow users to set and track spending limits.
- To provide expense tracking features for categorizing and monitoring expenditures.
- To enable users to set financial goals and track their progress over time.
- To generate reports and visualizations of income, expenses, and savings trends.
- To ensure data security and privacy for all user financial information.
- To enhance user engagement through features like reminders for bill payments and savings tips.
- To support multi-currency transactions for users who travel or manage finances in different currencies.
Project Modules
User Management Module
- User Registration/Login: Allow users to create accounts and log in securely, often with options for social media or email authentication.
- Profile Management: Enable users to manage their profiles, including personal information, financial goals, and preferences.
- Multi-User Support: Allow multiple users to manage their finances under a single account (e.g., family or household accounts).
Dashboard Module
- Overview of Finances: Provide a summary of the user’s financial status, including total income, expenses, savings, and investments.
- Visualizations: Use charts and graphs to display spending patterns, income sources, and budget utilization.
- Quick Actions: Allow users to quickly add expenses, income, or view recent transactions from the dashboard.
Income Management Module
- Income Entry: Allow users to add and categorize different sources of income (e.g., salary, freelance work, investments).
- Recurring Income: Enable users to set up recurring income entries for regular payments (e.g., monthly salary).
Expense Management Module
- Expense Entry: Allow users to add and categorize expenses, including details such as amount, category, date, and notes.
- Recurring Expenses: Enable users to set up recurring expenses (e.g., rent, subscriptions) for automatic tracking.
- Expense Categories: Provide predefined categories (e.g., food, transportation, entertainment) and allow users to create custom categories.
Budgeting Module
- Budget Creation: Allow users to set monthly or yearly budgets for different categories.
- Budget Tracking: Monitor spending against the budget and provide alerts when users approach or exceed their budget limits.
- Budget Reports: Generate reports to show budget performance over time.
Reporting and Analytics Module
- Spending Reports: Generate detailed reports on spending habits, categorized by type, date, or other criteria.
- Income Reports: Provide insights into income sources and trends over time.
- Custom Reports: Allow users to create custom reports based on specific parameters (e.g., date range, category).
Goal Setting Module
- Financial Goals: Allow users to set financial goals (e.g., saving for a vacation, paying off debt) and track progress.
- Savings Targets: Enable users to set specific savings targets and monitor their achievement.
Investment Tracking Module
- Investment Portfolio Management: Allow users to track their investments, including stocks, bonds, mutual funds, and real estate.
- Performance Tracking: Monitor the performance of investments over time, including gains and losses.
- Asset Allocation: Provide insights into asset allocation and diversification.
Notifications and Alerts Module
- Spending Alerts: Notify users when they are close to exceeding their budget or when a recurring expense is due.
- Reminders: Set reminders for bill payments, income entries, or budget reviews.
Data Backup and Sync Module
- Cloud Backup: Allow users to back up their data to the cloud for security and recovery.
- Multi-Device Sync: Enable users to access their financial data across multiple devices (e.g., mobile, tablet, web).
Security and Privacy Module
- Data Encryption: Ensure that sensitive financial data is encrypted and stored securely.
- Access Control: Implement user authentication and authorization to protect user data.
Feedback and Support Module
- User Feedback Collection: Allow users to provide feedback on the app and suggest improvements.
- Help Center: Provide FAQs, tutorials, and support documentation to assist users.
Project Tables Queries
-- Create Users Table
CREATE TABLE Users (
UserId INT PRIMARY KEY IDENTITY(1,1),
Username NVARCHAR(50) NOT NULL UNIQUE,
PasswordHash NVARCHAR(256) NOT NULL,
Email NVARCHAR(100) NOT NULL UNIQUE,
FirstName NVARCHAR(50) NOT NULL,
LastName NVARCHAR(50) NOT NULL,
RoleId INT NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (RoleId) REFERENCES Roles(RoleId)
);
-- Create Roles Table
CREATE TABLE Roles (
RoleId INT PRIMARY KEY IDENTITY(1,1),
RoleName NVARCHAR(50) NOT NULL UNIQUE,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE()
);
-- Create Income Table
CREATE TABLE Income (
IncomeId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
Amount DECIMAL(18, 2) NOT NULL,
Source NVARCHAR(100) NOT NULL,
DateReceived DATETIME NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);
-- Create Expense Table
CREATE TABLE Expenses (
ExpenseId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
Amount DECIMAL(18, 2) NOT NULL,
Category NVARCHAR(100) NOT NULL,
DateIncurred DATETIME NOT NULL,
Description NVARCHAR(MAX),
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);
-- Create Budget Table
CREATE TABLE Budgets (
BudgetId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
Category NVARCHAR(100) NOT NULL,
Amount DECIMAL(18, 2) NOT NULL,
StartDate DATETIME NOT NULL,
EndDate DATETIME NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);
-- Create Reports Table
CREATE TABLE Reports (
ReportId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
ReportDate DATETIME NOT NULL,
ReportContent NVARCHAR(MAX),
CreatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);
-- Create Goals Table
CREATE TABLE Goals (
GoalId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
GoalName NVARCHAR(100) NOT NULL,
TargetAmount DECIMAL(18, 2) NOT NULL,
CurrentAmount DECIMAL(18, 2) NOT NULL DEFAULT 0,
TargetDate DATETIME NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);
-- Create Investments Table
CREATE TABLE Investments (
InvestmentId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
InvestmentName NVARCHAR(100) NOT NULL,
Amount DECIMAL(18, 2) NOT NULL,
InvestmentDate DATETIME NOT NULL,
CurrentValue DECIMAL(18, 2) NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);
-- Create Notifications Table
CREATE TABLE Notifications (
NotificationId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
Message NVARCHAR(255) NOT NULL,
IsRead BIT NOT NULL DEFAULT 0,
CreatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);
-- Create Backup Table
CREATE TABLE Backups (
BackupId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
BackupDate DATETIME DEFAULT GETDATE(),
BackupFile NVARCHAR(255) NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);
-- Create Feedback Table
CREATE TABLE Feedback (
FeedbackId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
FeedbackContent NVARCHAR(MAX) NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);
Explanation of Tables
Users: Stores user information, including their role.
Roles: Defines different roles (e.g., Admin, User) in the system.
Income: Records income details for users, including source and amount.
Expenses: Manages user expenses, categorized by type and amount.
Budgets: Allows users to set and track budgets for different categories.
Reports: Enables users to generate financial reports based on their data.
Goals: Tracks financial goals set by users, including target and current amounts.
Investments: Manages user investments, including their current value and amount invested.
Notifications: Stores notifications for users regarding financial updates and reminders.
Backups: Keeps records of user data backups for recovery purposes.
Feedback: Collects user feedback on the Personal Finance Manager system.
To create the corresponding models and migrations for Laravel 11 based on the provided SQL schema, you can follow these steps.
Below, I will provide the migration files and model classes for each of the tables you defined.
Step 1: Create Migrations
You can create migrations using the Artisan command. For example, to create a migration for the Users table, you would run:
php artisan make:migration create_users_table
Step 2: Define Migrations
Now, you can define the migrations in the generated files located in the database/migrations directory. Below are the migration definitions based on your SQL schema.
Migration for Users Table
// database/migrations/2025_02_01_000001_create_users_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id('User Id');
$table->string('Username', 50)->unique();
$table->string('PasswordHash', 256);
$table->string('Email', 100)->unique();
$table->string('FirstName', 50);
$table->string('LastName', 50);
$table->foreignId('RoleId')->constrained('roles');
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('users');
}
}
Migration for Roles Table
// database/migrations/2025_02_01_000001_create_roles_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateRolesTable extends Migration
{
public function up()
{
Schema::create('roles', function (Blueprint $table) {
$table->id('RoleId');
$table->string('RoleName', 50)->unique();
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('roles');
}
}
Migration for Income Table
// database/migrations/2025_02_01_000003_create_income_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateIncomeTable extends Migration
{
public function up()
{
Schema::create('income', function (Blueprint $table) {
$table->id('IncomeId');
$table->foreignId('User Id')->constrained('users');
$table->decimal('Amount', 18, 2);
$table->string('Source', 100);
$table->dateTime('DateReceived');
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('income');
}
}
Migration for Expenses Table
// database/migrations/2025_02_01_000004_create_expenses_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExpensesTable extends Migration
{
public function up()
{
Schema::create('expenses', function (Blueprint $table) {
$table->id('ExpenseId');
$table->foreignId('User Id')->constrained('users');
$table->decimal('Amount', 18, 2);
$table->string('Category', 100);
$table->dateTime('DateIncurred');
$table->text('Description')->nullable();
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('expenses');
}
}
Migration for Budgets Table
// database/migrations/2025_02_01_000005_create_budgets_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBudgetsTable extends Migration
{
public function up()
{
Schema::create('budgets', function (Blueprint $table) {
$table->id('BudgetId');
$table->foreignId('User Id')->constrained('users');
$table->string('Category', 100);
$table->decimal('Amount', 18, 2);
$table->dateTime('StartDate');
$table->dateTime('EndDate');
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('budgets');
}
}
Migration for Reports Table
// database/migrations/2025_02_01_000006_create_reports_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateReportsTable extends Migration
{
public function up()
{
Schema::create('reports', function (Blueprint $table) {
$table->id('ReportId');
$table->foreignId('User Id')->constrained('users');
$table->dateTime('ReportDate');
$table->text('ReportContent');
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('reports');
}
}
Migration for Goals Table
// database/migrations/2025_02_01_000007_create_goals_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateGoalsTable extends Migration
{
public function up()
{
Schema::create('goals', function (Blueprint $table) {
$table->id('GoalId');
$table->foreignId('User Id')->constrained('users');
$table->string('GoalName', 100);
$table->decimal('TargetAmount', 18, 2);
$table->decimal('CurrentAmount', 18, 2)->default(0);
$table->dateTime('TargetDate');
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('goals');
}
}
Migration for Investments Table
// database/migrations/2025_02_01_000008_create_investments_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateInvestmentsTable extends Migration
{
public function up()
{
Schema::create('investments', function (Blueprint $table) {
$table->id('InvestmentId');
$table->foreignId('User Id')->constrained('users');
$table->string('InvestmentName', 100);
$table->decimal('Amount', 18, 2);
$table->dateTime('InvestmentDate');
$table->decimal('CurrentValue', 18, 2);
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('investments');
}
}
Migration for Notifications Table
// database/migrations/2025_02_01_000009_create_notifications_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNotificationsTable extends Migration
{
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->id('NotificationId');
$table->foreignId('User Id')->constrained('users');
$table->string('Message', 255);
$table->boolean('IsRead')->default(0);
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('notifications');
}
}
Migration for Backup Table
// database/migrations/2025_02_01_000010_create_backups_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBackupsTable extends Migration
{
public function up()
{
Schema::create('backups', function (Blueprint $table) {
$table->id('BackupId');
$table->foreignId('User Id')->constrained('users');
$table->dateTime('BackupDate')->default(now());
$table->string('BackupFile', 255);
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('backups');
}
}
Migration for Feedback Table
// database/migrations/2025_02_01_000011_create_feedback_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFeedbackTable extends Migration
{
public function up()
{
Schema::create('feedback', function (Blueprint $table) {
$table->id('FeedbackId');
$table->foreignId('User Id')->constrained('users');
$table->text('FeedbackContent');
$table->timestamps(0);
});
}
public function down()
{
Schema::dropIfExists('feedback');
}
}
Step 3: Create Models
You can create models using the Artisan command. For example, to create a model for the User table, you would run:
php artisan make:model User
Step 4: Define Eloquent Models
Here are the basic model definitions for each table:
User Model
// app/Models/User.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use HasFactory;
protected $table = 'users';
protected $fillable = [
'Username',
'PasswordHash',
'Email',
'FirstName',
'LastName',
'RoleId',
];
public function roles()
{
return $this->belongsTo(Role::class, 'RoleId');
}
public function incomes()
{
return $this->hasMany(Income::class);
}
public function expenses()
{
return $this->hasMany(Expense::class);
}
public function budgets()
{
return $this->hasMany(Budget::class);
}
public function reports()
{
return $this->hasMany(Report::class);
}
public function goals()
{
return $this->hasMany(Goal::class);
}
public function investments()
{
return $this->hasMany(Investment::class);
}
public function notifications()
{
return $this->hasMany(Notification::class);
}
public function backups()
{
return $this->hasMany(Backup::class);
}
public function feedbacks()
{
return $this->hasMany(Feedback::class);
}
}
Role Model
// app/Models/Role.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Role extends Model
{
use HasFactory;
protected $table = 'roles';
protected $fillable = [
'RoleName',
];
public function users()
{
return $this->hasMany(User::class, 'RoleId');
}
}
Income Model
// app/Models/Income.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Income extends Model
{
use HasFactory;
protected $table = 'income';
protected $fillable = [
'User Id',
'Amount',
'Source',
'DateReceived',
];
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
}
Expense Model
// app/Models/Expense.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Expense extends Model
{
use HasFactory;
protected $table = 'expenses';
protected $fillable = [
'User Id',
'Amount',
'Category',
'DateIncurred',
'Description',
];
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
}
Budget Model
// app/Models/Budget.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Budget extends Model
{
use HasFactory;
protected $table = 'budgets';
protected $fillable = [
'User Id',
'Category',
'Amount',
'StartDate',
'EndDate',
];
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
}
Report Model
// app/Models/Report.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Report extends Model
{
use HasFactory;
protected $table = 'reports';
protected $fillable = [
'User Id',
'ReportDate',
'ReportContent',
];
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
}
Goal Model
// app/Models/Goal.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Goal extends Model
{
use HasFactory;
protected $table = 'goals';
protected $fillable = [
'User Id',
'GoalName',
'TargetAmount',
'CurrentAmount',
'TargetDate',
];
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
}
Investment Model
// app/Models/Investment.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Investment extends Model
{
use HasFactory;
protected $table = 'investments';
protected $fillable = [
'User Id',
'InvestmentName',
'Amount',
'InvestmentDate',
'CurrentValue',
];
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
}
Notification Model
// app/Models/Notification.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Notification extends Model
{
use HasFactory;
protected $table = 'notifications';
protected $fillable = [
'User Id',
'Message',
'IsRead',
];
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
}
Backup Model
// app/Models/Backup.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Backup extends Model
{
use HasFactory;
protected $table = 'backups';
protected $fillable = [
'User Id',
'BackupDate',
'BackupFile',
];
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
}
Feedback Model
// app/Models/Feedback.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Feedback extends Model
{
use HasFactory;
protected $table = 'feedback';
protected $fillable = [
'User Id',
'FeedbackContent',
];
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
Step 5: Implement CRUD Operations
Below are the basic implementations for each controller. Each controller will have methods for the standard CRUD operations: index, create, store, show, edit, update, and destroy.
UserController
// app/Http/Controllers/UserController.php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
class UserController extends Controller
{
public function index()
{
$users = User::all();
return view('users.index', compact('users'));
}
public function create()
{
return view('users.create');
}
public function store(Request $request)
{
$request->validate([
'Username' => 'required|unique:users|max:50',
'PasswordHash' => 'required',
'Email' => 'required|email|unique:users|max:100',
'FirstName' => 'required|max:50',
'LastName' => 'required|max:50',
'RoleId' => 'required|exists:roles,RoleId',
]);
User::create($request->all());
return redirect()->route('users.index')->with('success', 'User created successfully.');
}
public function show(User $user)
{
return view('users.show', compact('user'));
}
public function edit(User $user)
{
return view('users.edit', compact('user'));
}
public function update(Request $request, User $user)
{
$request->validate([
'Username' => 'required|max:50|unique:users,Username,' . $user->id,
'PasswordHash' => 'required',
'Email' => 'required|email|max:100|unique:users,Email,' . $user->id,
'FirstName' => 'required|max:50',
'LastName' => 'required|max:50',
'RoleId' => 'required|exists:roles,RoleId',
]);
$user->update($request->all());
return redirect()->route('users.index')->with('success', 'User updated successfully.');
}
public function destroy(User $user)
{
$user->delete();
return redirect()->route('users.index')->with('success', 'User deleted successfully.');
}
}
RoleController
// app/Http/Controllers/RoleController.php
namespace App\Http\Controllers;
use App\Models\Role;
use Illuminate\Http\Request;
class RoleController extends Controller
{
public function index()
{
$roles = Role::all();
return view('roles.index', compact('roles'));
}
public function create()
{
return view('roles.create');
}
public function store(Request $request)
{
$request->validate([
'RoleName' => 'required|unique:roles|max:50',
]);
Role::create($request->all());
return redirect()->route('roles.index')->with('success', 'Role created successfully.');
}
public function show(Role $role)
{
return view('roles.show', compact('role'));
}
public function edit(Role $role)
{
return view('roles.edit', compact('role'));
}
public function update(Request $request, Role $role)
{
$request->validate([
'RoleName' => 'required|max:50|unique:roles,RoleName,' . $role->id,
]);
$role->update($request->all());
return redirect()->route('roles.index')->with('success', 'Role updated successfully.');
}
public function destroy(Role $role)
{
$role->delete();
return redirect()->route('roles.index')->with('success', 'Role deleted successfully.');
}
}
IncomeController
// app/Http/Controllers/IncomeController.php
namespace App\Http\Controllers;
use App\Models\Income;
use App\Models\User;
use Illuminate\Http\Request;
class IncomeController extends Controller
{
public function index()
{
$incomes = Income::all();
return view('incomes.index', compact('incomes'));
}
public function create()
{
$users = User::all();
return view('incomes.create', compact('users'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'Amount' => 'required|numeric',
'Source' => 'required|max:100',
'DateReceived' => 'required|date',
]);
Income::create($request->all());
return redirect()->route('incomes.index')->with('success', 'Income created successfully.');
}
public function show(Income $income)
{
return view('incomes.show', compact('income'));
}
public function edit(Income $income)
{
$users = User::all();
return view('incomes.edit', compact('income', 'users'));
}
public function update(Request $request, Income $income)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'Amount ' => 'required|numeric',
'Source' => 'required|max:100',
'DateReceived' => 'required|date',
]);
$income->update($request->all());
return redirect()->route('incomes.index')->with('success', 'Income updated successfully.');
}
public function destroy(Income $income)
{
$income->delete();
return redirect()->route('incomes.index')->with('success', 'Income deleted successfully.');
}
}
ExpenseController
// app/Http/Controllers/ExpenseController.php
namespace App\Http\Controllers;
use App\Models\Expense;
use App\Models\User;
use Illuminate\Http\Request;
class ExpenseController extends Controller
{
public function index()
{
$expenses = Expense::all();
return view('expenses.index', compact('expenses'));
}
public function create()
{
$users = User::all();
return view('expenses.create', compact('users'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'Amount' => 'required|numeric',
'Category' => 'required|max:100',
'DateIncurred' => 'required|date',
'Description' => 'nullable|max:255',
]);
Expense::create($request->all());
return redirect()->route('expenses.index')->with('success', 'Expense created successfully.');
}
public function show(Expense $expense)
{
return view('expenses.show', compact('expense'));
}
public function edit(Expense $expense)
{
$users = User::all();
return view('expenses.edit', compact('expense', 'users'));
}
public function update(Request $request, Expense $expense)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'Amount' => 'required|numeric',
'Category' => 'required|max:100',
'DateIncurred' => 'required|date',
'Description' => 'nullable|max:255',
]);
$expense->update($request->all());
return redirect()->route('expenses.index')->with('success', 'Expense updated successfully.');
}
public function destroy(Expense $expense)
{
$expense->delete();
return redirect()->route('expenses.index')->with('success', 'Expense deleted successfully.');
}
}
BudgetController
// app/Http/Controllers/BudgetController.php
namespace App\Http\Controllers;
use App\Models\Budget;
use App\Models\User;
use Illuminate\Http\Request;
class BudgetController extends Controller
{
public function index()
{
$budgets = Budget::all();
return view('budgets.index', compact('budgets'));
}
public function create()
{
$users = User::all();
return view('budgets.create', compact('users'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'Category' => 'required|max:100',
'Amount' => 'required|numeric',
'StartDate' => 'required|date',
'EndDate' => 'required|date|after_or_equal:StartDate',
]);
Budget::create($request->all());
return redirect()->route('budgets.index')->with('success', 'Budget created successfully.');
}
public function show(Budget $budget)
{
return view('budgets.show', compact('budget'));
}
public function edit(Budget $budget)
{
$users = User::all();
return view('budgets.edit', compact('budget', 'users'));
}
public function update(Request $request, Budget $budget)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'Category' => 'required|max:100',
'Amount' => 'required|numeric',
'StartDate' => 'required|date',
'EndDate' => 'required|date|after_or_equal:StartDate',
]);
$budget->update($request->all());
return redirect()->route('budgets.index')->with('success', 'Budget updated successfully.');
}
public function destroy(Budget $budget)
{
$budget->delete();
return redirect()->route('budgets.index')->with('success', 'Budget deleted successfully.');
}
}
ReportController
// app/Http/Controllers/ReportController.php
namespace App\Http\Controllers;
use App\Models\Report;
use App\Models\User;
use Illuminate\Http\Request;
class ReportController extends Controller
{
public function index()
{
$reports = Report::all();
return view('reports.index', compact('reports'));
}
public function create()
{
$users = User::all();
return view('reports.create', compact('users'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'ReportDate' => 'required|date',
'ReportContent' => 'required',
]);
Report::create($request->all());
return redirect()->route('reports.index')->with('success', 'Report created successfully.');
}
public function show(Report $report)
{
return view('reports.show', compact('report'));
}
public function edit(Report $report)
{
$users = User::all();
return view('reports.edit', compact('report', 'users'));
}
public function update(Request $request, Report $report)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'ReportDate' => 'required|date',
'ReportContent' => 'required',
]);
$report->update($request->all());
return redirect()->route('reports.index')->with('success', 'Report updated successfully.');
}
public function destroy(Report $report)
{
$report->delete();
return redirect()->route('reports.index')->with('success', 'Report deleted successfully.');
}
}
GoalController
// app/Http/Controllers/GoalController.php
namespace App\Http\Controllers;
use App\Models\Goal;
use App\Models\User;
use Illuminate\Http\Request;
class GoalController extends Controller
{
public function index()
{
$goals = Goal::all();
return view('goals.index', compact('goals'));
}
public function create()
{
$users = User::all();
return view('goals.create', compact('users'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'GoalName' => 'required|max:100',
'TargetAmount' => 'required|numeric',
'CurrentAmount' => 'nullable|numeric',
'TargetDate' => 'required|date',
]);
Goal::create($request->all());
return redirect()->route('goals.index')->with('success', 'Goal created successfully.');
}
public function show(Goal $goal)
{
return view('goals.show', compact('goal'));
}
public function edit(Goal $goal)
{
$users = User::all();
return view('goals.edit', compact('goal', 'users'));
}
public function update(Request $request, Goal $goal)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'GoalName' => 'required|max:100',
'TargetAmount' => 'required|numeric',
'CurrentAmount' => 'nullable|numeric',
'TargetDate' => 'required|date',
]);
$goal->update($request->all());
return redirect()->route('goals.index')->with('success', 'Goal updated successfully.');
}
public function destroy(Goal $goal)
{
$goal->delete();
return redirect()->route('goals.index')->with('success', 'Goal deleted successfully.');
}
}
InvestmentController
// app/Http/Controllers/InvestmentController.php
namespace App\Http\Controllers;
use App\Models\Investment;
use App\Models\User;
use Illuminate\Http\Request;
class InvestmentController extends Controller
{
public function index()
{
$investments = Investment::all();
return view('investments.index', compact('investments'));
}
public function create()
{
$users = User::all();
return view('investments.create', compact('users'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'InvestmentName' => 'required|max:100',
'Amount' => 'required|numeric',
'InvestmentDate' => 'required|date',
'CurrentValue' => 'required|numeric',
]);
Investment::create($request->all());
return redirect()->route('investments.index')->with('success', 'Investment created successfully.');
}
public function show(Investment $investment)
{
return view('investments.show', compact('investment'));
}
public function edit(Investment $investment)
{
$users = User::all();
return view('investments .edit', compact('investment', 'users'));
}
public function update(Request $request, Investment $investment)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'InvestmentName' => 'required|max:100',
'Amount' => 'required|numeric',
'InvestmentDate' => 'required|date',
'CurrentValue' => 'required|numeric',
]);
$investment->update($request->all());
return redirect()->route('investments.index')->with('success', 'Investment updated successfully.');
}
public function destroy(Investment $investment)
{
$investment->delete();
return redirect()->route('investments.index')->with('success', 'Investment deleted successfully.');
}
}
NotificationController
// app/Http/Controllers/NotificationController.php
namespace App\Http\Controllers;
use App\Models\Notification;
use App\Models\User;
use Illuminate\Http\Request;
class NotificationController extends Controller
{
public function index()
{
$notifications = Notification::all();
return view('notifications.index', compact('notifications'));
}
public function create()
{
$users = User::all();
return view('notifications.create', compact('users'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'Message' => 'required|max:255',
'IsRead' => 'boolean',
]);
Notification::create($request->all());
return redirect()->route('notifications.index')->with('success', 'Notification created successfully.');
}
public function show(Notification $notification)
{
return view('notifications.show', compact('notification'));
}
public function edit(Notification $notification)
{
$users = User::all();
return view('notifications.edit', compact('notification', 'users'));
}
public function update(Request $request, Notification $notification)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'Message' => 'required|max:255',
'IsRead' => 'boolean',
]);
$notification->update($request->all());
return redirect()->route('notifications.index')->with('success', 'Notification updated successfully.');
}
public function destroy(Notification $notification)
{
$notification->delete();
return redirect()->route('notifications.index')->with('success', 'Notification deleted successfully.');
}
}
BackupController
// app/Http/Controllers/BackupController.php
namespace App\Http\Controllers;
use App\Models\Backup;
use App\Models\User;
use Illuminate\Http\Request;
class BackupController extends Controller
{
public function index()
{
$backups = Backup::all();
return view('backups.index', compact('backups'));
}
public function create()
{
$users = User::all();
return view('backups.create', compact('users'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'BackupFile' => 'required|max:255',
]);
Backup::create($request->all());
return redirect()->route('backups.index')->with('success', 'Backup created successfully.');
}
public function show(Backup $backup)
{
return view('backups.show', compact('backup'));
}
public function edit(Backup $backup)
{
$users = User::all();
return view('backups.edit', compact('backup', 'users'));
}
public function update(Request $request, Backup $backup)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'BackupFile' => 'required|max:255',
]);
$backup->update($request->all());
return redirect()->route('backups.index')->with('success', 'Backup updated successfully.');
}
public function destroy(Backup $backup)
{
$backup->delete();
return redirect()->route('backups.index')->with('success', 'Backup deleted successfully.');
}
}
FeedbackController
// app/Http/Controllers/FeedbackController.php
namespace App\Http\Controllers;
use App\Models\Feedback;
use App\Models\User;
use Illuminate\Http\Request;
class FeedbackController extends Controller
{
public function index()
{
$feedbacks = Feedback::all();
return view('feedbacks.index', compact('feedbacks'));
}
public function create()
{
$users = User::all();
return view('feedbacks.create', compact('users'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'FeedbackContent' => 'required',
]);
Feedback::create($request->all());
return redirect()->route('feedbacks.index')->with('success', 'Feedback created successfully.');
}
public function show(Feedback $feedback)
{
return view('feedbacks.show', compact('feedback'));
}
public function edit(Feedback $feedback)
{
$users = User::all();
return view('feedbacks.edit', compact('feedback', 'users'));
}
public function update(Request $request, Feedback $feedback)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'FeedbackContent' => 'required',
]);
$feedback->update($request->all());
return redirect()->route('feedbacks.index')->with('success', 'Feedback updated successfully.');
}
public function destroy(Feedback $feedback)
{
$feedback->delete();
return redirect()->route('feedbacks.index')->with('success', 'Feedback deleted successfully.');
}
}
Step 3: Define Routes
To make the controllers functional, you need to define routes in your `web.php` file. Below is an example of how to set up the routes for each controller.
// routes/web.php
use App\Http\Controllers\UserController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\IncomeController;
use App\Http\Controllers\ExpenseController;
use App\Http\Controllers\BudgetController;
use App\Http\Controllers\ReportController;
use App\Http\Controllers\GoalController;
use App\Http\Controllers\InvestmentController;
use App\Http\Controllers\NotificationController;
use App\Http\Controllers\BackupController;
use App\Http\Controllers\FeedbackController;
Route::resource('users', UserController::class);
Route::resource('roles', RoleController::class);
Route::resource('incomes', IncomeController::class);
Route::resource('expenses', ExpenseController::class);
Route::resource('budgets', BudgetController::class);
Route::resource('reports', ReportController::class);
Route::resource('goals', GoalController::class);
Route::resource('investments', InvestmentController::class);
Route::resource('notifications', NotificationController::class);
Route::resource('backups', BackupController::class);
Route::resource('feedbacks', FeedbackController::class);
Step 6: Create Views
You will also need to create views for each of the CRUD operations. Below is a basic structure for the views. You can create a folder for each model under resources/views and create the necessary Blade files.
resources/views/
├── users/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
├── roles/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
├── incomes/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
├── expenses/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
├── budgets/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
├── reports/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
├── goals/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
├── investments/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
├── notifications/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
├── backups/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
├── feedbacks/
│ ├── index.blade.php
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
Step 7: Implement Basic View Logic
Each view file will contain the necessary HTML and Blade syntax to display forms and lists. Here's a simple example for the index view of the User model.
Example: User Index View
<!-- resources/views/users/index.blade.php -->
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Users</h1>
<a href="{{ route('users.create') }}" class="btn btn-primary">Create User</a>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Email</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->Username }}</td>
<td>{{ $user->Email }}</td>
<td>
<a href="{{ route('users.show', $user->id) }}" class="btn btn-info">View</a>
<a href="{{ route('users.edit', $user->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('users.destroy', $user->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
This structure provides a comprehensive setup for CRUD operations across all models in your Laravel application.
You can replicate the view structure for other models, adjusting the fields and logic as necessary.
Below are example view files for each controller, designed using Bootstrap 5.
Each view includes basic CRUD functionality, such as displaying a list of records, creating new records, editing existing records, and showing details of a specific record.
User Views
resources/views/users/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Users</h1>
<a href="{{ route('users.create') }}" class="btn btn-primary mb-3">Create User</a>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Email</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->Username }}</td>
<td>{{ $user->Email }}</td>
<td>
<a href="{{ route('users.show', $user->id) }}" class="btn btn-info">View</a>
<a href="{{ route('users.edit', $user->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('users.destroy', $user->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/users/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create User</h1>
<form action="{{ route('users.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="Username" class="form-label">Username</label>
<input type="text" class="form-control" id="Username" name="Username" required>
</div>
<div class="mb-3">
<label for="PasswordHash" class="form-label">Password</label>
<input type="password" class="form-control" id="PasswordHash" name="PasswordHash" required>
</div>
<div class="mb-3">
<label for="Email" class="form-label">Email</label>
<input type="email" class="form-control" id="Email" name="Email" required>
</div>
<div class="mb-3">
<label for="FirstName" class="form-label">First Name</label>
<input type="text" class="form-control" id="FirstName" name="FirstName" required>
</div>
<div class="mb-3">
<label for="LastName" class="form-label">Last Name</label>
<input type="text" class="form-control" id="LastName" name="LastName" required>
</div>
<div class="mb-3">
<label for="RoleId" class="form-label">Role</label>
<select class="form-select" id="RoleId" name="RoleId" required>
@foreach ($roles as $role)
<option value="{{ $role->RoleId }}">{{ $role->RoleName }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Create User</button>
</form>
</div>
@endsection
resources/views/users/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit User</h1>
<form action="{{ route('users.update', $user->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="Username" class="form-label">Username</label>
<input type="text" class="form-control" id="Username" name="Username" value="{{ $user->Username }}" required>
</div>
<div class="mb-3">
<label for="PasswordHash" class="form-label">Password</label>
<input type="password" class="form-control" id="PasswordHash" name="PasswordHash" required>
</div>
<div class="mb-3">
<label for="Email" class="form-label">Email</label>
<input type="email" class="form-control" id="Email" name="Email" value="{{ $user->Email }}" required>
</div>
<div class="mb-3">
<label for="FirstName" class="form-label">First Name</label>
<input type="text" class="form-control" id="FirstName" name="FirstName" value="{{ $user->FirstName }}" required>
</div>
<div class="mb-3">
<label for="LastName" class="form-label">Last Name</label>
<input type="text" class="form-control" id="LastName" name="LastName" value="{{ $user->LastName }}" required>
</div>
<div class="mb-3">
<label for="RoleId" class="form-label">Role</label>
<select class="form-select" id="RoleId" name="RoleId" required>
@foreach ($roles as $role)
<option value="{{ $role->RoleId }}" {{ $role->RoleId == $user->RoleId ? 'selected' : '' }}>{{ $role->RoleName }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Update User</button>
</form>
</div>
@endsection
resources/views/users/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container"> <h1>User Details</h1> <div class="mb-3"> <strong>Username:</strong> {{ $user->Username }} </div> <div class="mb-3"> <strong>Email:</strong> {{ $user->Email }} </div> <div class="mb-3"> <strong>First Name:</strong> {{ $user->FirstName }} </div> <div class="mb-3"> <strong>Last Name:</strong> {{ $user->LastName }} </div> <div class="mb-3"> <strong>Role:</strong> {{ $user->role->RoleName }} </div> <a href="{{ route('users.edit', $user->id) }}" class="btn btn-warning">Edit</a> <form action="{{ route('users.destroy', $user->id) }}" method="POST" style="display:inline;"> @csrf @method('DELETE') <button type="submit" class="btn btn-danger">Delete</button> </form> <a href="{{ route('users.index') }}" class="btn btn-secondary">Back to Users</a> </div>
@endsection
Role Views
resources/views/roles/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Roles</h1>
<a href="{{ route('roles.create') }}" class="btn btn-primary mb-3">Create Role</a>
<table class="table">
<thead>
<tr>
<th>Role Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($roles as $role)
<tr>
<td>{{ $role->RoleName }}</td>
<td>
<a href="{{ route('roles.show', $role->id) }}" class="btn btn-info">View</a>
<a href="{{ route('roles.edit', $role->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('roles.destroy', $role->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/roles/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Role</h1>
<form action="{{ route('roles.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="RoleName" class="form-label">Role Name</label>
<input type="text" class="form-control" id="RoleName" name="RoleName" required>
</div>
<button type="submit" class="btn btn-primary">Create Role</button>
</form>
</div>
@endsection
resources/views/roles/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Role</h1>
<form action="{{ route('roles.update', $role->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="RoleName" class="form-label">Role Name</label>
<input type="text" class="form-control" id="RoleName" name="RoleName" value="{{ $role->RoleName }}" required>
</div>
<button type="submit" class="btn btn-primary">Update Role</button>
</form>
</div>
@endsection
resources/views/roles/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Role Details</h1>
<div class="mb-3">
<strong>Role Name:</strong> {{ $role->RoleName }}
</div>
<a href="{{ route('roles.edit', $role->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('roles.destroy', $role->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('roles.index') }}" class="btn btn -secondary">Back to Roles</a>
</div>
@endsection
Income Views
resources/views/incomes/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Incomes</h1>
<a href="{{ route('incomes.create') }}" class="btn btn-primary mb-3">Create Income</a>
<table class="table">
<thead>
<tr>
<th>Source</th>
<th>Amount</th>
<th>Date Received</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($incomes as $income)
<tr>
<td>{{ $income->Source }}</td>
<td>{{ $income->Amount }}</td>
<td>{{ $income->DateReceived }}</td>
<td>
<a href="{{ route('incomes.show', $income->id) }}" class="btn btn-info">View</a>
<a href="{{ route('incomes.edit', $income->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('incomes.destroy', $income->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/incomes/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Income</h1>
<form action="{{ route('incomes.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="Amount" class="form-label">Amount</label>
<input type="number" class="form-control" id="Amount" name="Amount" required>
</div>
<div class="mb-3">
<label for="Source" class="form-label">Source</label>
<input type="text" class="form-control" id="Source" name="Source" required>
</div>
<div class="mb-3">
<label for="DateReceived" class="form-label">Date Received</label>
<input type="date" class="form-control" id="DateReceived" name="DateReceived" required>
</div>
<button type="submit" class="btn btn-primary">Create Income</button>
</form>
</div>
@endsection
resources/views/incomes/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Income</h1>
<form action="{{ route('incomes.update', $income->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $user->id == $income->User Id ? 'selected' : '' }}>{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="Amount" class="form-label">Amount</label>
<input type="number" class="form-control" id="Amount" name="Amount" value="{{ $income->Amount }}" required>
</div>
<div class="mb-3">
<label for="Source" class="form-label">Source</label>
<input type="text" class="form-control" id="Source" name="Source" value="{{ $income->Source }}" required>
</div>
<div class="mb-3">
<label for="DateReceived" class="form-label">Date Received</label>
<input type="date" class="form-control" id="DateReceived" name="DateReceived" value="{{ $income->DateReceived }}" required>
</div>
<button type="submit" class=" btn btn-primary">Update Income</button>
</form>
</div>
@endsection
resources/views/incomes/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Income Details</h1>
<div class="mb-3">
<strong>User:</strong> {{ $income->user->Username }}
</div>
<div class="mb-3">
<strong>Source:</strong> {{ $income->Source }}
</div>
<div class="mb-3">
<strong>Amount:</strong> {{ $income->Amount }}
</div>
<div class="mb-3">
<strong>Date Received:</strong> {{ $income->DateReceived }}
</div>
<a href="{{ route('incomes.edit', $income->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('incomes.destroy', $income->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('incomes.index') }}" class="btn btn-secondary">Back to Incomes</a>
</div>
@endsection
Expense Views
resources/views/expenses/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Expenses</h1>
<a href="{{ route('expenses.create') }}" class="btn btn-primary mb-3">Create Expense</a>
<table class="table">
<thead>
<tr>
<th>Category</th>
<th>Amount</th>
<th>Date Incurred</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($expenses as $expense)
<tr>
<td>{{ $expense->Category }}</td>
<td>{{ $expense->Amount }}</td>
<td>{{ $expense->DateIncurred }}</td>
<td>
<a href="{{ route('expenses.show', $expense->id) }}" class="btn btn-info">View</a>
<a href="{{ route('expenses.edit', $expense->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('expenses.destroy', $expense->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/expenses/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Expense</h1>
<form action="{{ route('expenses.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="Amount" class="form-label">Amount</label>
<input type="number" class="form-control" id="Amount" name="Amount" required>
</div>
<div class="mb-3">
<label for="Category" class="form-label">Category</label>
<input type="text" class="form-control" id="Category" name="Category" required>
</div>
<div class="mb-3">
<label for="DateIncurred" class="form-label">Date Incurred</label>
<input type="date" class="form-control" id="DateIncurred" name="DateIncurred" required>
</div>
<div class="mb-3">
<label for="Description" class="form-label">Description</label>
<textarea class="form-control" id="Description" name="Description"></textarea>
</div>
<button type="submit" class="btn btn-primary">Create Expense</button>
</form>
</div>
@endsection
resources/views/expenses/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Expense</h1>
<form action="{{ route('expenses.update', $expense->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $user->id == $expense->User Id ? 'selected' : '' }}>{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="Amount" class="form-label">Amount</label>
<input type="number" class="form-control" id="Amount" name="Amount" value="{{ $expense->Amount }}" required>
</div>
<div class="mb-3">
<label for="Category" class="form-label">Category</label>
<input type="text" class="form-control" id="Category" name="Category" value="{{ $expense->Category }}" required>
</div>
<div class="mb-3">
<label for="DateIncurred" class="form-label">Date Incurred</label>
<input type="date" class="form-control" id="DateIncurred" name="DateIncurred" value="{{ $expense->DateIncurred }}" required>
</div>
<div class="mb-3">
<label for="Description" class="form-label">Description</label>
<textarea class="form-control" id="Description" name="Description">{{ $expense->Description }}</textarea>
</div>
<button type="submit" class="btn btn-primary">Update Expense</button>
</form>
</div>
@endsection
resources/views/expenses/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Expense Details</h1>
<div class="mb-3">
<strong>User:</strong> {{ $expense->user->Username }}
</div>
<div class="mb-3">
<strong>Category:</strong> {{ $expense->Category }}
</div>
<div class="mb-3">
<strong>Amount:</strong> {{ $expense->Amount }}
</div>
<div class="mb-3">
<strong>Date Incurred:</strong> {{ $expense->DateIncurred }}
</div>
<div class="mb-3">
<strong>Description:</strong> {{ $expense->Description }}
</div>
<a href="{{ route('expenses.edit', $expense->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('expenses.destroy', $expense->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('expenses.index') }}" class="btn btn-secondary">Back to Expenses</a>
</div>
@endsection
Budget Views
resources/views/budgets/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Budgets</h1>
<a href="{{ route('budgets.create') }}" class="btn btn-primary mb-3">Create Budget</a>
<table class="table">
<thead>
<tr>
<th>Category</th>
<th>Amount</th>
<th>Start Date</th>
<th>End Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($budgets as $budget)
<tr>
<td>{{ $budget->Category }}</td>
<td>{{ $budget->Amount }}</td>
<td>{{ $budget->StartDate }}</td>
<td>{{ $budget->EndDate }}</td>
<td>
<a href="{{ route('budgets.show', $budget->id) }}" class="btn btn-info">View</a>
<a href="{{ route('budgets.edit', $budget->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('budgets.destroy', $budget->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/budgets/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Budget</h1>
<form action="{{ route('budgets.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="Category" class="form-label">Category</label>
<input type="text" class="form-control" id="Category" name="Category" required>
</div>
<div class="mb-3">
<label for="Amount" class="form-label">Amount</label>
<input type="number" class="form-control" id="Amount" name="Amount" required>
</div>
<div class="mb-3">
<label for="StartDate" class="form-label">Start Date</label>
<input type="date" class="form-control" id="StartDate" name="StartDate" required>
</div>
<div class="mb-3">
<label for="EndDate" class="form-label">End Date</label>
<input type="date" class="form-control" id="EndDate" name="EndDate" required>
</div>
<button type="submit" class="btn btn-primary">Create Budget</button>
</form>
</div>
@endsection
resources/views/budgets/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Budget</h1>
<form action="{{ route('budgets.update', $budget->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $user->id == $budget->User Id ? 'selected' : '' }}>{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="Category" class="form-label">Category</label>
<input type="text" class="form-control" id="Category" name="Category" value="{{ $budget->Category }}" required>
</div>
<div class="mb-3">
<label for="Amount" class="form-label">Amount</label>
<input type="number" class="form-control" id="Amount" name="Amount" value="{{ $budget->Amount }}" required>
</div>
<div class="mb-3">
<label for="StartDate" class="form-label">Start Date</label>
<input type="date" class="form-control" id="StartDate" name="StartDate" value="{{ $budget->StartDate }}" required>
</div>
<div class="mb-3">
<label for="EndDate" class="form-label">End Date</label>
<input type="date" class="form-control" id="EndDate" name="EndDate" value="{{ $budget->EndDate }}" required>
</div>
<button type="submit" class="btn btn-primary">Update Budget</button>
</form>
</div>
@endsection
resources/views/budgets/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Budget Details</h1>
<div class="mb-3">
<strong>User:</strong> {{ $budget->user->Username }}
</div>
<div class="mb-3">
<strong>Category:</strong> {{ $budget->Category }}
</div>
<div class="mb-3">
<strong>Amount:</strong> {{ $budget->Amount }}
</div>
<div class="mb-3">
<strong>Start Date:</strong> {{ $budget->StartDate }}
</div>
<div class="mb-3">
<strong>End Date:</strong> {{ $budget-> EndDate }}
</div>
<a href="{{ route('budgets.edit', $budget->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('budgets.destroy', $budget->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('budgets.index') }}" class="btn btn-secondary">Back to Budgets</a>
</div>
@endsection
Report Views
resources/views/reports/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Reports</h1>
<a href="{{ route('reports.create') }}" class="btn btn-primary mb-3">Create Report</a>
<table class="table">
<thead>
<tr>
<th>Report Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($reports as $report)
<tr>
<td>{{ $report->ReportDate }}</td>
<td>
<a href="{{ route('reports.show', $report->id) }}" class="btn btn-info">View</a>
<a href="{{ route('reports.edit', $report->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('reports.destroy', $report->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/reports/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Report</h1>
<form action="{{ route('reports.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="ReportDate" class="form-label">Report Date</label>
<input type="date" class="form-control" id="ReportDate" name="ReportDate" required>
</div>
<div class="mb-3">
<label for="ReportContent" class="form-label">Report Content</label>
<textarea class="form-control" id="ReportContent" name="ReportContent" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Create Report</button>
</form>
</div>
@endsection
resources/views/reports/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Report</h1>
<form action="{{ route('reports.update', $report->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $user->id == $report->User Id ? 'selected' : '' }}>{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="ReportDate" class="form-label">Report Date</label>
<input type="date" class="form-control" id="ReportDate" name="ReportDate" value="{{ $report->ReportDate }}" required>
</div>
<div class="mb-3">
<label for="ReportContent" class="form-label">Report Content</label>
<textarea class="form-control" id="ReportContent" name="ReportContent" required>{{ $report->ReportContent }}</textarea>
</div>
<button type="submit" class="btn btn-primary">Update Report</button>
</form>
</div>
@endsection
resources/views/reports/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Report Details</h1>
<div class="mb-3">
<strong>User:</strong> {{ $report->user->Username }}
</div>
<div class="mb-3">
<strong>Report Date:</strong> {{ $report->ReportDate }}
</div>
<div class="mb-3">
<strong>Report Content:</strong> {{ $report->ReportContent }}
</div>
<a href="{{ route('reports.edit', $report->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('reports.destroy', $report->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('reports.index') }}" class="btn btn-secondary">Back to Reports</a>
</div>
@endsection
Goal Views
resources/views/goals/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Goals</h1>
<a href="{{ route('goals.create') }}" class="btn btn-primary mb-3">Create Goal</a>
<table class="table">
<thead>
<tr>
<th>Goal Name</th>
<th>Target Amount</th>
<th>Current Amount</th>
<th>Target Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($goals as $goal)
<tr>
<td>{{ $goal->GoalName }}</td>
<td>{{ $goal->TargetAmount }}</td>
<td>{{ $goal->CurrentAmount }}</td>
<td>{{ $goal->TargetDate }}</td>
<td>
<a href="{{ route('goals.show', $goal->id) }}" class="btn btn-info">View</a>
<a href="{{ route('goals.edit', $goal->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('goals.destroy', $goal->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/goals/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Goal</h1>
<form action="{{ route('goals.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="GoalName" class="form-label">Goal Name</label>
<input type="text" class="form-control" id="GoalName" name="GoalName" required>
</div>
<div class="mb-3">
<label for="TargetAmount" class="form-label">Target Amount</label>
<input type="number" class="form-control" id="TargetAmount" name="TargetAmount" required>
</div>
<div class="mb-3">
<label for="CurrentAmount" class="form-label">Current Amount</label>
<input type="number" class="form-control" id="CurrentAmount" name="CurrentAmount">
</div>
<div class="mb-3">
<label for="TargetDate" class="form-label">Target Date</label>
<input type="date" class="form-control" id="TargetDate" name="TargetDate" required>
</div>
<button type="submit" class="btn btn-primary">Create Goal</button>
</form>
</div>
@endsection
resources/views/goals/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Goal</h1>
<form action="{{ route('goals.update', $goal->id) }}" method="POST">
@csrf
@method('PUT <div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $user->id == $goal->User Id ? 'selected' : '' }}>{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="GoalName" class="form-label">Goal Name</label>
<input type="text" class="form-control" id="GoalName" name="GoalName" value="{{ $goal->GoalName }}" required>
</div>
<div class="mb-3">
<label for="TargetAmount" class="form-label">Target Amount</label>
<input type="number" class="form-control" id="TargetAmount" name="TargetAmount" value="{{ $goal->TargetAmount }}" required>
</div>
<div class="mb-3">
<label for="CurrentAmount" class="form-label">Current Amount</label>
<input type="number" class="form-control" id="CurrentAmount" name="CurrentAmount" value="{{ $goal->CurrentAmount }}">
</div>
<div class="mb-3">
<label for="TargetDate" class="form-label">Target Date</label>
<input type="date" class="form-control" id="TargetDate" name="TargetDate" value="{{ $goal->TargetDate }}" required>
</div>
<button type="submit" class="btn btn-primary">Update Goal</button>
</form>
</div>
@endsection
resources/views/goals/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Goal Details</h1>
<div class="mb-3">
<strong>User:</strong> {{ $goal->user->Username }}
</div>
<div class="mb-3">
<strong>Goal Name:</strong> {{ $goal->GoalName }}
</div>
<div class="mb-3">
<strong>Target Amount:</strong> {{ $goal->TargetAmount }}
</div>
<div class="mb-3">
<strong>Current Amount:</strong> {{ $goal->CurrentAmount }}
</div>
<div class="mb-3">
<strong>Target Date:</strong> {{ $goal->TargetDate }}
</div>
<a href="{{ route('goals.edit', $goal->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('goals.destroy', $goal->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('goals.index') }}" class="btn btn-secondary">Back to Goals</a>
</div>
@endsection
Investment Views
resources/views/investments/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Investments</h1>
<a href="{{ route('investments.create') }}" class="btn btn-primary mb-3">Create Investment</a>
<table class="table">
<thead>
<tr>
<th>Investment Name</th>
<th>Amount</th>
<th>Investment Date</th>
<th>Current Value</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($investments as $investment)
<tr>
<td>{{ $investment->InvestmentName }}</td>
<td>{{ $investment->Amount }}</td>
<td>{{ $investment->InvestmentDate }}</td>
<td>{{ $investment->CurrentValue }}</td>
<td>
<a href="{{ route('investments.show', $investment->id) }}" class="btn btn-info">View</a>
<a href="{{ route('investments.edit', $investment->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('investments.destroy', $investment->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/investments/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Investment</h1>
<form action="{{ route('investments.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="InvestmentName" class="form-label">Investment Name</label>
<input type="text" class="form-control" id="InvestmentName" name="InvestmentName" required>
</div>
<div class="mb-3">
<label for="Amount" class="form-label">Amount</label>
<input type="number" class="form-control" id="Amount" name="Amount" required>
</div>
<div class="mb-3">
<label for="InvestmentDate" class="form-label">Investment Date</label>
<input type="date" class="form-control" id="InvestmentDate" name="InvestmentDate" required>
</div>
<div class="mb-3">
<label for="CurrentValue" class="form-label">Current Value</label>
<input type="number" class="form-control" id="CurrentValue" name="CurrentValue" required>
</div>
<button type="submit" class="btn btn-primary">Create Investment</button>
</form>
</div>
@endsection
resources/views/investments/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Investment</h1>
<form action="{{ route('investments.update', $investment->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $user->id == $investment->User Id ? 'selected' : '' }}>{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="InvestmentName" class="form-label">Investment Name</label>
<input type="text" class="form-control" id="InvestmentName" name="InvestmentName" value="{{ $investment->InvestmentName }}" required>
</div>
<div class="mb-3">
<label for="Amount" class="form-label">Amount</label>
<input type="number" class="form-control" id="Amount" name="Amount" value="{{ $investment->Amount }}" required>
</div>
<div class="mb-3">
<label for="InvestmentDate" class="form-label">Investment Date</label>
<input type="date" class="form-control" id="InvestmentDate" name="InvestmentDate" value="{{ $investment->InvestmentDate }}" required>
</div>
<div class="mb-3">
<label for="CurrentValue" class="form-label">Current Value</label>
<input type="number" class="form-control" id="CurrentValue" name="CurrentValue" value="{{ $investment->CurrentValue }}" required>
</div>
<button type="submit" class="btn btn-primary">Update Investment</button>
</form>
</div>
@endsection
resources/views/investments/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Investment Details</h1>
<div class="mb-3">
<strong>User:</strong> {{ $investment->user->Username }}
</div>
<div class="mb-3">
<strong>Investment Name:</strong> {{ $investment->InvestmentName }}
</div>
<div class="mb-3">
<strong>Amount:</strong> {{ $investment->Amount }}
</div>
<div class="mb-3">
<strong>Investment Date:</strong> {{ $investment->InvestmentDate }}
</div>
<div class="mb-3">
<strong>Current Value:</strong> {{ $investment->CurrentValue }}
</div>
<a href="{{ route('investments.edit', $investment->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('investments.destroy', $investment->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('investments.index') }}" class="btn btn-secondary">Back to Investments</a>
</div>
@endsection
Notification Views
resources/views/notifications/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Notifications</h1>
<a href="{{ route('notifications.create') }}" class="btn btn-primary mb-3">Create Notification</a>
<table class="table">
<thead>
<tr>
<th>Message</th>
<th>Is Read</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($notifications as $notification)
<tr>
<td>{{ $notification->Message }}</td>
<td>{{ $notification->IsRead ? 'Yes' : 'No' }}</td>
<td>
<a href="{{ route('notifications.show', $notification->id) }}" class="btn btn-info">View</a>
<a href="{{ route('notifications.edit', $notification->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('notifications.destroy', $notification->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/notifications/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Notification</h1>
<form action="{{ route('notifications.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="Message" class="form-label">Message</label>
<textarea class="form-control" id="Message" name="Message" required></textarea>
</div>
<div class="mb-3">
<label for="IsRead" class="form-label">Is Read</label>
<select class="form-select" id="IsRead" name="IsRead" required>
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Create Notification</button>
</form>
</div>
@endsection
resources/views/notifications/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Notification</h1>
<form action="{{ route('notifications.update', $notification->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $user->id == $notification->User Id ? 'selected' : '' }}>{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="Message" class="form-label">Message</label>
<textarea class="form-control" id="Message" name="Message" required>{{ $notification->Message }}</textarea>
</div>
<div class="mb-3">
<label for="IsRead" class="form-label">Is Read</label>
<select class="form-select" id="IsRead" name="IsRead" required>
<option value="1" {{ $notification->IsRead ? 'selected ' : '' }}>Yes</option>
<option value="0" {{ !$notification->IsRead ? 'selected' : '' }}>No</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Update Notification</button>
</form>
</div>
@endsection
resources/views/notifications/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Notification Details</h1>
<div class="mb-3">
<strong>User:</strong> {{ $notification->user->Username }}
</div>
<div class="mb-3">
<strong>Message:</strong> {{ $notification->Message }}
</div>
<div class="mb-3">
<strong>Is Read:</strong> {{ $notification->IsRead ? 'Yes' : 'No' }}
</div>
<a href="{{ route('notifications.edit', $notification->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('notifications.destroy', $notification->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('notifications.index') }}" class="btn btn-secondary">Back to Notifications</a>
</div>
@endsection
Backup Views
resources/views/backups/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Backups</h1>
<a href="{{ route('backups.create') }}" class="btn btn-primary mb-3">Create Backup</a>
<table class="table">
<thead>
<tr>
<th>Backup File</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($backups as $backup)
<tr>
<td>{{ $backup->BackupFile }}</td>
<td>
<a href="{{ route('backups.show', $backup->id) }}" class="btn btn-info">View</a>
<a href="{{ route('backups.edit', $backup->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('backups.destroy', $backup->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/backups/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Backup</h1>
<form action="{{ route('backups.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="BackupFile" class="form-label">Backup File</label>
<input type="text" class="form-control" id="BackupFile" name="BackupFile" required>
</div>
<button type="submit" class="btn btn-primary">Create Backup</button>
</form>
</div>
@endsection
resources/views/backups/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Backup</h1>
<form action="{{ route('backups.update', $backup->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $user->id == $backup->User Id ? 'selected' : '' }}>{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="BackupFile" class="form-label">Backup File</label>
<input type="text" class="form-control" id="BackupFile" name="BackupFile" value="{{ $backup->BackupFile }}" required>
</div>
<button type="submit" class="btn btn-primary">Update Backup</button>
</form>
</div>
@endsection
resources/views/backups/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Backup Details</h1>
<div class="mb-3">
<strong>User:</strong> {{ $backup->user->Username }}
</div>
<div class="mb-3">
<strong>Backup File:</strong> {{ $backup->BackupFile }}
</div>
<a href="{{ route('backups.edit', $backup->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('backups.destroy', $backup->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('backups.index') }}" class="btn btn-secondary">Back to Backups</a>
</div>
@endsection
Feedback Views
resources/views/feedbacks/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Feedbacks</h1>
<a href="{{ route('feedbacks.create') }}" class="btn btn-primary mb-3">Create Feedback</a>
<table class="table">
<thead>
<tr>
<th>User</th>
<th>Feedback Content</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($feedbacks as $feedback)
<tr>
<td>{{ $feedback->user->Username }}</td>
<td>{{ $feedback->FeedbackContent }}</td>
<td>
<a href="{{ route('feedbacks.show', $feedback->id) }}" class="btn btn-info">View</a>
<a href="{{ route('feedbacks.edit', $feedback->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('feedbacks.destroy', $feedback->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
resources/views/feedbacks/create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Feedback</h1>
<form action="{{ route('feedbacks.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="FeedbackContent" class="form-label">Feedback Content</label>
<textarea class="form-control" id="FeedbackContent" name="FeedbackContent" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Create Feedback</button>
</form>
</div>
@endsection
resources/views/feedbacks/edit.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Feedback</h1>
<form action="{{ route('feedbacks.update', $feedback->id) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select class="form-select" id="User Id" name="User Id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}" {{ $user->id == $feedback->User Id ? 'selected' : '' }}>{{ $user->Username }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="FeedbackContent" class="form-label">Feedback Content</label>
<textarea class="form-control" id="FeedbackContent" name="FeedbackContent" required>{{ $feedback->FeedbackContent }}</textarea>
</div>
<button type="submit" class="btn btn-primary">Update Feedback</button>
</form>
</div>
@endsection
resources/views/feedbacks/show.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Feedback Details</h1>
<div class="mb-3">
<strong>User:</strong> {{ $feedback->user->Username }}
</div>
<div class="mb-3">
<strong>Feedback Content:</strong> {{ $feedback->FeedbackContent }}
</div>
<a href="{{ route('feedbacks.edit', $feedback->id) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('feedbacks.destroy', $feedback->id) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('feedbacks.index') }}" class="btn btn-secondary">Back to Feedbacks</a>
</div>
@endsection
Creating a layout file in Laravel allows you to define a common structure for your views, which can help maintain consistency across your application.
Below is an example of a layout file using Bootstrap 5. This layout file will include a navigation bar, a container for the main content, and links to Bootstrap's CSS and JavaScript.
Step 1: Create the Layout File
Create a new file named app.blade.php in the resources/views/layouts directory.
resources/views/layouts/app.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title', 'My Application')</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="{{ asset('css/app.css') }}"> <!-- Optional custom CSS -->
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="{{ url('/') }}">My Application</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="{{ route('users.index') }}">Users</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('roles.index') }}">Roles</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('incomes.index') }}">Incomes</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('expenses.index') }}">Expenses</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('budgets.index') }}">Budgets</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('reports.index') }}">Reports</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('goals.index') }}">Goals</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('investments.index') }}">Investments</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('notifications.index') }}">Notifications</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('backups.index') }}">Backups</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('feedbacks.index') }}">Feedbacks</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-4">
@if(session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
@endif
@if(session('error'))
<div class="alert alert-danger">
{{ session('error') }}
</div>
@endif
@yield('content')
</div>
<footer class="bg-light text-center text-lg-start mt-4">
<div class="text-center p-3">
© 2023 My Application
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Explanation of the Layout File
HTML Structure: The layout file starts with the standard HTML structure, including the <!DOCTYPE html> declaration and the <html> tag.
Head Section:
The <head> section includes meta tags for character set and viewport settings.
The title of the page can be set using @yield('title', 'My Application'), allowing individual views to specify their own titles.
Bootstrap CSS is included via a CDN link.
Navigation Bar:
A responsive navigation bar is created using Bootstrap classes.
Links to various sections of the application (Users, Roles, Incomes, etc.) are provided, using Laravel's route helper functions to generate URLs.
Flash Messages:
The layout includes a section to display success and error messages using Bootstrap alert classes. These messages are typically set in the controller and can be displayed to the user.
Content Section:
The @yield('content') directive is where the content of individual views will be injected.
Footer:
A simple footer is included at the bottom of the page.
JavaScript:
Bootstrap's JavaScript bundle is included at the end of the body to ensure that the page loads quickly.
Step 2: Using the Layout in Views
To use this layout in your views, you can extend it at the top of each view file. For example:
@extends('layouts.app')
@section('title', 'User List')
@section('content')
<!-- Your content here -->
@endsection
This way, all your views will have a consistent layout, and you can easily manage the navigation and footer in one place.
How To Build Different Dashboards For Different Roles In Laravel
To create a dashboard page in Laravel for displaying consolidated project data, you can follow these general steps:
Step 1: Set Up Routes
Define a route in your web.php file that points to the dashboard controller.
Step 2: Create a Controller
Generate a controller that will handle the logic for fetching and consolidating project data from your models.
Step 3: Fetch Data
In the controller, retrieve the necessary data from your database, possibly using Eloquent models to aggregate information.
Step 4: Create a View
Design a Blade view that will display the consolidated data in a user-friendly format, such as charts or tables.
Step 5: Integrate Frontend Libraries
Optionally, use libraries like Chart.js or Vue.js to enhance the visual representation of your data.
Step 6: Link to the Dashboard
Ensure that your navigation includes a link to the dashboard page for easy access.
Detailed Example of Setting Up the Dashboard
Step 1: Set Up Routes
In your routes/web.php, add a route for the dashboard:
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
Step 2: Create a Controller
Generate a controller using Artisan command:
php artisan make:controller DashboardController
In the DashboardController, fetch the consolidated project data:
namespace App\Http\Controllers;
use App\Models\Project; // Assuming you have a Project model
use Illuminate\Http\Request;
class DashboardController extends Controller
{
public function index()
{
$projects = Project::all(); // Fetch all projects
$totalProjects = $projects->count();
$completedProjects = $projects->where('status', 'completed')->count();
$ongoingProjects = $projects->where('status', 'ongoing')->count();
return view('dashboard.index', compact('totalProjects', 'completedProjects', 'ongoingProjects'));
}
}
Step 3: Create a View
Create a new Blade view file at resources/views/dashboard/index.blade.php:
@extends('layouts.app')
@section('title', 'Dashboard')
@section('content')
<div class="container">
<h1 class="mb-4">Dashboard</h1>
<div class="row">
<div class="col-md-4">
<div class="card text-white bg-success mb-3">
<div class="card-header">Total Projects</div>
<div class="card-body">
<h5 class="card-title">{{ $totalProjects }}</h5>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card text-white bg-info mb-3">
<div class="card-header">Completed Projects</div>
<div class="card-body">
<h5 class="card-title">{{ $completedProjects }}</h5>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card text-white bg-warning mb-3">
<div class="card-header">Ongoing Projects</div>
<div class="card-body">
<h5 class="card-title">{{ $ongoingProjects }}</h5>
</div>
</div>
</div>
</div>
</div>
@endsection
Step 4: Integrate Frontend Libraries
If you want to visualize the data further, you can integrate Chart.js. First, include the Chart.js library in your layout file:
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
Then, you can create a chart in your dashboard view:
<canvas id="projectChart" width="400" height="200"></canvas>
<script>
const ctx = document.getElementById('projectChart').getContext('2d');
const projectChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Total Projects', 'Completed Projects', 'Ongoing Projects'],
datasets: [{
label: 'Projects',
data: [{{ $totalProjects }}, {{ $completedProjects }}, {{ $ongoingProjects }}],
backgroundColor: [
'rgba(75, 192, 192, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)'
],
borderColor: [
'rgba(75, 192, 192, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
Step 5: Link to the Dashboard
Ensure that the dashboard link is included in your navigation bar in the app.blade.php layout:
<li class="nav-item">
<a class="nav-link" href="{{ route('dashboard') }}">Dashboard</a>
</li>
Additional Features
To further enhance the dashboard, consider adding features such as filtering options, date ranges, or project categories. This can help users gain more insights into their projects.
Step 6: Implement Filtering
You can implement filtering by adding a form at the top of your dashboard view. For example:
<form method="GET" action="{{ route('dashboard') }}" class="mb-4">
<div class="form-row">
<div class="col">
<input type="text" name="search" class="form-control" placeholder="Search projects...">
</div>
<div class="col">
<select name="status" class="form-control">
<option value="">All Statuses</option>
<option value="completed">Completed</option>
<option value="ongoing">Ongoing</option>
</select>
</div>
<div class="col">
<button type="submit" class="btn btn-primary">Filter</button>
</div>
</div>
</form>
Step 7: Update Controller Logic
Modify the index method in your DashboardController to handle the filtering logic:
public function index(Request $request)
{
$query = Project::query();
if ($request->filled('search')) {
$query->where('name', 'like', '%' . $request->search . '%');
}
if ($request->filled('status')) {
$query->where('status', $request->status);
}
$projects = $query->get();
$totalProjects = $projects->count();
$completedProjects = $projects->where('status', 'completed')->count();
$ongoingProjects = $projects->where('status', 'ongoing')->count();
return view('dashboard.index', compact('totalProjects', 'completedProjects', 'ongoingProjects'));
}
Step 8: Add Pagination
If you have a large number of projects, consider adding pagination to your dashboard. You can modify the query to paginate results:
$projects = $query->paginate(10);
Then, update your view to display the pagination links:
{{ $projects->links() }}
Step 9: Style the Dashboard
To improve the visual appeal of your dashboard, you can customize the CSS styles. You can create a custom CSS file and include it in your layout:
<link rel="stylesheet" href="{{ asset('css/custom.css') }}">
In your custom.css, you can add styles to enhance the layout and design of your dashboard components.