fully working now
This commit is contained in:
@ -42,6 +42,6 @@ class AuthenticatedSessionController extends Controller
|
|||||||
|
|
||||||
$request->session()->regenerateToken();
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
return redirect('/');
|
return redirect()->route('login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
74
crm-panel/app/Http/Controllers/CompanyController.php
Normal file
74
crm-panel/app/Http/Controllers/CompanyController.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Company;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class CompanyController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$companies = Company::paginate(10);
|
||||||
|
return view('companies.index', compact('companies'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('companies.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required',
|
||||||
|
'email' => 'nullable|email',
|
||||||
|
'logo' => 'nullable|image|dimensions:min_width=100,min_height=100',
|
||||||
|
'website' => 'nullable|url',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($request->hasFile('logo')) {
|
||||||
|
$path = $request->file('logo')->store('public/logos');
|
||||||
|
$request->merge(['logo' => $path]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Company::create($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('companies.index')->with('success', 'Company created successfully.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Company $company)
|
||||||
|
{
|
||||||
|
return view('companies.show', compact('company'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Company $company)
|
||||||
|
{
|
||||||
|
return view('companies.edit', compact('company'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, Company $company)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required',
|
||||||
|
'email' => 'nullable|email',
|
||||||
|
'logo' => 'nullable|image|dimensions:min_width=100,min_height=100',
|
||||||
|
'website' => 'nullable|url',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($request->hasFile('logo')) {
|
||||||
|
$path = $request->file('logo')->store('public/logos');
|
||||||
|
$company->logo = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$company->update($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('companies.index')->with('success', 'Company updated successfully.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Company $company)
|
||||||
|
{
|
||||||
|
$company->delete();
|
||||||
|
return redirect()->route('companies.index')->with('success', 'Company deleted successfully.');
|
||||||
|
}
|
||||||
|
}
|
69
crm-panel/app/Http/Controllers/EmployeeController.php
Normal file
69
crm-panel/app/Http/Controllers/EmployeeController.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Employee;
|
||||||
|
use App\Models\Company;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class EmployeeController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$employees = Employee::paginate(10);
|
||||||
|
return view('employees.index', compact('employees'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$companies = Company::all(); // You need to fetch companies for the dropdown
|
||||||
|
return view('employees.create', compact('companies'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'first_name' => 'required',
|
||||||
|
'last_name' => 'required',
|
||||||
|
'company_id' => 'required|exists:companies,id',
|
||||||
|
'email' => 'nullable|email',
|
||||||
|
'phone' => 'nullable|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Employee::create($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('employees.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Employee $employee)
|
||||||
|
{
|
||||||
|
return view('employees.show', compact('employee'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Employee $employee)
|
||||||
|
{
|
||||||
|
$companies = Company::all();
|
||||||
|
return view('employees.edit', compact('employee', 'companies'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, Employee $employee)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'first_name' => 'required',
|
||||||
|
'last_name' => 'required',
|
||||||
|
'company_id' => 'required|exists:companies,id',
|
||||||
|
'email' => 'nullable|email',
|
||||||
|
'phone' => 'nullable|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$employee->update($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('employees.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Employee $employee)
|
||||||
|
{
|
||||||
|
$employee->delete();
|
||||||
|
return redirect()->route('employees.index');
|
||||||
|
}
|
||||||
|
}
|
@ -2,9 +2,18 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Company extends Model
|
class Company extends Model
|
||||||
{
|
{
|
||||||
//
|
use HasFactory;
|
||||||
|
|
||||||
|
// Define fillable fields for mass assignment
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'logo',
|
||||||
|
'website',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,19 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Employee extends Model
|
class Employee extends Model
|
||||||
{
|
{
|
||||||
//
|
use HasFactory;
|
||||||
|
|
||||||
|
// Add these fields to allow mass assignment
|
||||||
|
protected $fillable = [
|
||||||
|
'first_name',
|
||||||
|
'last_name',
|
||||||
|
'company_id',
|
||||||
|
'email',
|
||||||
|
'phone',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
19
crm-panel/database/seeders/AdminUserSeeder.php
Normal file
19
crm-panel/database/seeders/AdminUserSeeder.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class AdminUserSeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
User::firstOrCreate([
|
||||||
|
'email' => 'admin@admin.com'
|
||||||
|
], [
|
||||||
|
'name' => 'Admin',
|
||||||
|
'password' => Hash::make('password')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
31
crm-panel/database/seeders/CompanySeeder.php
Normal file
31
crm-panel/database/seeders/CompanySeeder.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Company;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class CompanySeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
Company::create([
|
||||||
|
'name' => 'TechCorp',
|
||||||
|
'email' => 'techcorp@example.com',
|
||||||
|
'logo' => 'techcorp_logo.png', // Add a default logo or adjust the logic accordingly
|
||||||
|
'website' => 'https://techcorp.com',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Company::create([
|
||||||
|
'name' => 'Web Solutions',
|
||||||
|
'email' => 'websolutions@example.com',
|
||||||
|
'logo' => 'websolutions_logo.png',
|
||||||
|
'website' => 'https://websolutions.com',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,6 @@
|
|||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class DatabaseSeeder extends Seeder
|
class DatabaseSeeder extends Seeder
|
||||||
@ -13,11 +12,11 @@ class DatabaseSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
// User::factory(10)->create();
|
// Call admin seeder
|
||||||
|
$this->call(AdminUserSeeder::class);
|
||||||
User::factory()->create([
|
$this->call([
|
||||||
'name' => 'Test User',
|
CompanySeeder::class,
|
||||||
'email' => 'test@example.com',
|
EmployeeSeeder::class
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
crm-panel/database/seeders/EmployeeSeeder.php
Normal file
37
crm-panel/database/seeders/EmployeeSeeder.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Employee;
|
||||||
|
use App\Models\Company;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class EmployeeSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$company1 = Company::where('name', 'TechCorp')->first();
|
||||||
|
$company2 = Company::where('name', 'Web Solutions')->first();
|
||||||
|
|
||||||
|
Employee::create([
|
||||||
|
'first_name' => 'John',
|
||||||
|
'last_name' => 'Doe',
|
||||||
|
'company_id' => $company1->id,
|
||||||
|
'email' => 'john.doe@techcorp.com',
|
||||||
|
'phone' => '123-456-7890',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Employee::create([
|
||||||
|
'first_name' => 'Jane',
|
||||||
|
'last_name' => 'Smith',
|
||||||
|
'company_id' => $company2->id,
|
||||||
|
'email' => 'jane.smith@websolutions.com',
|
||||||
|
'phone' => '987-654-3210',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
27
crm-panel/resources/views/companies/create.blade.php
Normal file
27
crm-panel/resources/views/companies/create.blade.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<h1>Add Company</h1>
|
||||||
|
<form action="{{ route('companies.store') }}" method="POST" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="name">Name</label>
|
||||||
|
<input type="text" name="name" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="email">Email</label>
|
||||||
|
<input type="email" name="email" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="logo">Logo (min: 100x100)</label>
|
||||||
|
<input type="file" name="logo" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="website">Website</label>
|
||||||
|
<input type="url" name="website" class="form-control">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-success">Save</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endsection
|
31
crm-panel/resources/views/companies/edit.blade.php
Normal file
31
crm-panel/resources/views/companies/edit.blade.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<h1>Edit Company</h1>
|
||||||
|
<form action="{{ route('companies.update', $company) }}" method="POST" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="name">Name</label>
|
||||||
|
<input type="text" name="name" class="form-control" value="{{ $company->name }}" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="email">Email</label>
|
||||||
|
<input type="email" name="email" class="form-control" value="{{ $company->email }}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="logo">Logo (min: 100x100)</label>
|
||||||
|
<input type="file" name="logo" class="form-control">
|
||||||
|
@if($company->logo)
|
||||||
|
<img src="{{ Storage::url($company->logo) }}" alt="Logo" width="100" class="mt-2">
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="website">Website</label>
|
||||||
|
<input type="url" name="website" class="form-control" value="{{ $company->website }}">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-success">Update</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endsection
|
50
crm-panel/resources/views/companies/index.blade.php
Normal file
50
crm-panel/resources/views/companies/index.blade.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<h1>Companies</h1>
|
||||||
|
<a href="{{ route('companies.create') }}" class="btn btn-primary mb-3">Add Company</a>
|
||||||
|
|
||||||
|
@if (session('success'))
|
||||||
|
<div class="alert alert-success">{{ session('success') }}</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Logo</th>
|
||||||
|
<th>Website</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($companies as $company)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $company->name }}</td>
|
||||||
|
<td>{{ $company->email }}</td>
|
||||||
|
<td>
|
||||||
|
@if($company->logo)
|
||||||
|
<img src="{{ Storage::url($company->logo) }}" alt="Logo" width="100">
|
||||||
|
@else
|
||||||
|
N/A
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td>{{ $company->website }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ route('companies.show', $company) }}" class="btn btn-info btn-sm">View</a>
|
||||||
|
<a href="{{ route('companies.edit', $company) }}" class="btn btn-warning btn-sm">Edit</a>
|
||||||
|
<form action="{{ route('companies.destroy', $company) }}" method="POST" style="display:inline;">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')">Delete</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{ $companies->links() }}
|
||||||
|
</div>
|
||||||
|
@endsection
|
21
crm-panel/resources/views/companies/show.blade.php
Normal file
21
crm-panel/resources/views/companies/show.blade.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<h1>Company Details</h1>
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item"><strong>Name:</strong> {{ $company->name }}</li>
|
||||||
|
<li class="list-group-item"><strong>Email:</strong> {{ $company->email }}</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Logo:</strong>
|
||||||
|
@if($company->logo)
|
||||||
|
<img src="{{ Storage::url($company->logo) }}" alt="Logo" width="100">
|
||||||
|
@else
|
||||||
|
N/A
|
||||||
|
@endif
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item"><strong>Website:</strong> {{ $company->website }}</li>
|
||||||
|
</ul>
|
||||||
|
<a href="{{ route('companies.index') }}" class="btn btn-secondary mt-3">Back to List</a>
|
||||||
|
</div>
|
||||||
|
@endsection
|
@ -1,12 +1,11 @@
|
|||||||
<!DOCTYPE html>
|
@extends('layouts.app')
|
||||||
<html lang="en">
|
|
||||||
<head>
|
@section('content')
|
||||||
<meta charset="UTF-8">
|
<div class="container mt-5">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Dashboard</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Dashboard</h1>
|
<h1>Dashboard</h1>
|
||||||
<a href="{{ url('/') }}">Back to Home</a>
|
<div class="d-flex gap-3 mt-3">
|
||||||
</body>
|
<a href="{{ route('companies.index') }}" class="btn btn-primary">Manage Companies</a>
|
||||||
</html>
|
<a href="{{ route('employees.index') }}" class="btn btn-secondary">Manage Employees</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
37
crm-panel/resources/views/employees/create.blade.php
Normal file
37
crm-panel/resources/views/employees/create.blade.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<h1>Add New Employee</h1>
|
||||||
|
|
||||||
|
<form action="{{ route('employees.store') }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="first_name" class="form-label">First Name</label>
|
||||||
|
<input type="text" class="form-control" id="first_name" name="first_name" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="last_name" class="form-label">Last Name</label>
|
||||||
|
<input type="text" class="form-control" id="last_name" name="last_name" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="company_id" class="form-label">Company</label>
|
||||||
|
<select class="form-select" id="company_id" name="company_id" required>
|
||||||
|
<option value="">Select Company</option>
|
||||||
|
@foreach($companies as $company)
|
||||||
|
<option value="{{ $company->id }}">{{ $company->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="phone" class="form-label">Phone</label>
|
||||||
|
<input type="text" class="form-control" id="phone" name="phone">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Save Employee</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endsection
|
37
crm-panel/resources/views/employees/edit.blade.php
Normal file
37
crm-panel/resources/views/employees/edit.blade.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<h1>Edit Employee</h1>
|
||||||
|
|
||||||
|
<form action="{{ route('employees.update', $employee) }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="first_name" class="form-label">First Name</label>
|
||||||
|
<input type="text" class="form-control" id="first_name" name="first_name" value="{{ old('first_name', $employee->first_name) }}" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="last_name" class="form-label">Last Name</label>
|
||||||
|
<input type="text" class="form-control" id="last_name" name="last_name" value="{{ old('last_name', $employee->last_name) }}" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="company_id" class="form-label">Company</label>
|
||||||
|
<select class="form-select" id="company_id" name="company_id" required>
|
||||||
|
@foreach($companies as $company)
|
||||||
|
<option value="{{ $company->id }}" {{ $employee->company_id == $company->id ? 'selected' : '' }}>{{ $company->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="{{ old('email', $employee->email) }}">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="phone" class="form-label">Phone</label>
|
||||||
|
<input type="text" class="form-control" id="phone" name="phone" value="{{ old('phone', $employee->phone) }}">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Update Employee</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endsection
|
42
crm-panel/resources/views/employees/index.blade.php
Normal file
42
crm-panel/resources/views/employees/index.blade.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<h1>Employees</h1>
|
||||||
|
<a href="{{ route('employees.create') }}" class="btn btn-primary mb-3">Add Employee</a>
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>First Name</th>
|
||||||
|
<th>Last Name</th>
|
||||||
|
<th>Company</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Phone</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($employees as $employee)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $employee->first_name }}</td>
|
||||||
|
<td>{{ $employee->last_name }}</td>
|
||||||
|
<td>{{ $employee->company->name ?? 'N/A' }}</td>
|
||||||
|
<td>{{ $employee->email }}</td>
|
||||||
|
<td>{{ $employee->phone }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ route('employees.show', $employee) }}" class="btn btn-info btn-sm">View</a>
|
||||||
|
<a href="{{ route('employees.edit', $employee) }}" class="btn btn-warning btn-sm">Edit</a>
|
||||||
|
<form action="{{ route('employees.destroy', $employee) }}" method="POST" style="display:inline;">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')">Delete</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{ $employees->links() }}
|
||||||
|
</div>
|
||||||
|
@endsection
|
15
crm-panel/resources/views/employees/show.blade.php
Normal file
15
crm-panel/resources/views/employees/show.blade.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<h1>Employee Details</h1>
|
||||||
|
<ul>
|
||||||
|
<li>First Name: {{ $employee->first_name }}</li>
|
||||||
|
<li>Last Name: {{ $employee->last_name }}</li>
|
||||||
|
<li>Company: {{ $employee->company->name ?? 'N/A' }}</li>
|
||||||
|
<li>Email: {{ $employee->email }}</li>
|
||||||
|
<li>Phone: {{ $employee->phone }}</li>
|
||||||
|
</ul>
|
||||||
|
<a href="{{ route('employees.index') }}" class="btn btn-primary">Back to List</a>
|
||||||
|
</div>
|
||||||
|
@endsection
|
@ -20,57 +20,46 @@
|
|||||||
<div id="app">
|
<div id="app">
|
||||||
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
|
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand" href="{{ url('/') }}">
|
<a class="navbar-brand" href="{{ url('/dashboard') }}">
|
||||||
{{ config('app.name', 'Laravel') }}
|
Admin Panel
|
||||||
</a>
|
</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<!-- Left Side Of Navbar -->
|
|
||||||
<ul class="navbar-nav me-auto">
|
<ul class="navbar-nav me-auto">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="{{ route('dashboard') }}">Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="{{ route('companies.index') }}">Companies</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="{{ route('employees.index') }}">Employees</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- Right Side Of Navbar -->
|
|
||||||
<ul class="navbar-nav ms-auto">
|
<ul class="navbar-nav ms-auto">
|
||||||
<!-- Authentication Links -->
|
|
||||||
@guest
|
@guest
|
||||||
@if (Route::has('login'))
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
|
<a class="nav-link" href="{{ route('login') }}">Login</a>
|
||||||
</li>
|
</li>
|
||||||
@endif
|
|
||||||
|
|
||||||
@if (Route::has('register'))
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
|
|
||||||
</li>
|
|
||||||
@endif
|
|
||||||
@else
|
@else
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item">
|
||||||
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
|
<form action="{{ route('logout') }}" method="POST">
|
||||||
{{ Auth::user()->name }}
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
|
|
||||||
<a class="dropdown-item" href="{{ route('logout') }}"
|
|
||||||
onclick="event.preventDefault();
|
|
||||||
document.getElementById('logout-form').submit();">
|
|
||||||
{{ __('Logout') }}
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
|
|
||||||
@csrf
|
@csrf
|
||||||
|
<button type="submit" class="btn btn-danger">
|
||||||
|
Logout
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
</li>
|
</li>
|
||||||
@endguest
|
@endguest
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
<main class="py-4">
|
<main class="py-4">
|
||||||
@yield('content')
|
@yield('content')
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use App\Http\Controllers\CompanyController;
|
||||||
use App\Http\Controllers\ProfileController;
|
use App\Http\Controllers\EmployeeController;
|
||||||
|
use App\Http\Controllers\Auth\AuthenticatedSessionController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
@ -12,13 +13,10 @@ Route::get('/dashboard', function () {
|
|||||||
})->middleware(['auth', 'verified'])->name('dashboard');
|
})->middleware(['auth', 'verified'])->name('dashboard');
|
||||||
|
|
||||||
Route::middleware('auth')->group(function () {
|
Route::middleware('auth')->group(function () {
|
||||||
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
|
Route::resource('companies', CompanyController::class);
|
||||||
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
|
Route::resource('employees', EmployeeController::class);
|
||||||
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])->name('logout');
|
||||||
|
|
||||||
require __DIR__.'/auth.php';
|
require __DIR__.'/auth.php';
|
||||||
|
|
||||||
Auth::routes();
|
|
||||||
|
|
||||||
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
|
|
||||||
|
Reference in New Issue
Block a user