Skip to content

Commit

Permalink
Merge pull request #1 from tqt97/Extra-Features
Browse files Browse the repository at this point in the history
Extra features
  • Loading branch information
tqt97 authored Nov 10, 2023
2 parents 381fab6 + 6a53532 commit deed34d
Show file tree
Hide file tree
Showing 70 changed files with 32,422 additions and 75 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,35 @@
9. **[Customer View Page with Infolist](https://github.com/tqt97/laravel-crm-filament/commit/59beb89b72011939b720d8a7ef33d3f7c99a717d)**
10. **[Customer Documents: Upload/Download](https://github.com/tqt97/laravel-crm-filament/commit/c18cef80ab740af812dd5cca90f25ae761db6e72)**
11. **[Custom Fields for Customers](https://github.com/tqt97/laravel-crm-filament/commit/db6e66bf036002f98a166fbfabd046bf48262879)**
12. **[Customers in a Draggable Kanban Board](https://github.com/tqt97/laravel-crm-filament)**
- Creating Custom Page - Our Customer Board ```php artisan make:filament-page ManageCustomerStages```
13. **[Roles/Permissions: Manage Employees](https://github.com/tqt97/laravel-crm-filament)**
- Creating Roles Model and Database structure
- Creating Users Resource
- Adding Employees to Customers
- Adding Employee Changes to Customer History
- Limiting Employee Access
14. **[Employee User Invitations Process](https://github.com/tqt97/laravel-crm-filament)**
- Create Invitation Model and Database tables
- Modify UserResource Create Button Action - to Invite the Employee
- Creating Custom Registration Page
- Creating and Sending the Email
15. **[Customer Tasks and Calendar View](https://github.com/tqt97/laravel-crm-filament)**
- Create Task Model and Database
- Add Create Task button to the Customer list
- Add Task List to the Customer Page
- Add Task Resource with Tabs
- Adding Tabs to the Task Resource
- Add a Calendar Page for Tasks
16. **[Create Customer Quotes with Products](https://github.com/tqt97/laravel-crm-filament)**
- Creating the Product Model
- Creating Product Resource
- Creating the Quote Model
- Creating Quote Resource
- Create Quotes From Customer Table
17. **[Generate Quote PDF](https://github.com/tqt97/laravel-crm-filament)**
- Creating a Simple View Page for Quote
- Installing PDF Package
- Generating PDF
- Displaying PDF in View Page
109 changes: 109 additions & 0 deletions app/Filament/Pages/ManageCustomerStages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

namespace App\Filament\Pages;

use App\Models\Customer;
use Filament\Pages\Page;
use Livewire\Attributes\On;
use App\Models\PipelineStage;
use Illuminate\Support\Collection;
use Filament\Notifications\Notification;


class ManageCustomerStages extends Page
{
protected static ?string $navigationIcon = 'heroicon-s-queue-list';

protected static string $view = 'filament.pages.manage-customer-stages';

// Our Custom heading to be displayed on the page
protected ?string $heading = 'Customer Board';
// Custom Navigation Link name
protected static ?string $navigationLabel = 'Customer Board';

// We will be listening for the `statusChangeEvent` event to update the record status
#[On('statusChangeEvent')]
public function changeRecordStatus($id, $pipeline_stage_id): void
{
// Find the customer and update the pipeline_stage_id
$customer = Customer::find($id);
$customer->pipeline_stage_id = $pipeline_stage_id;
$customer->save();

// Don't forget to write the log
$customer->pipelineStageLogs()->create([
'pipeline_stage_id' => $pipeline_stage_id,
'notes' => null,
'user_id' => auth()->id()
]);

// Inform the user that the status has been updated
$customerName = $customer->first_name . ' ' . $customer->last_name;

Notification::make()
->title($customerName . ' Pipeline Stage Updated')
->success()
->send();
}

// Data that we will pass to our View
protected function getViewData(): array
{
$statuses = $this->statuses();

$records = $this->records();

// We are mapping through the statuses and adding the records to each status
// This will form multiple lists dynamically based on the records
$statuses = $statuses
->map(function ($status) use ($records) {
$status['group'] = $this->getId();
$status['kanbanRecordsId'] = "{$this->getId()}-{$status['id']}";
$status['records'] = $records
->filter(function ($record) use ($status) {
return $this->isRecordInStatus($record, $status);
});

return $status;
});

return [
'records' => $records,
'statuses' => $statuses,
];
}

// Loading the statuses from the database and mapping them
// to have id and title. ID will be checked against Customers
protected function statuses(): Collection
{
return PipelineStage::query()
->orderBy('position')
->get()
->map(function (PipelineStage $stage) {
return [
'id' => $stage->id,
'title' => $stage->name,
];
});
}

// We are loading all the customers and mapping them to have ID, title, and status
protected function records(): Collection
{
return Customer::all()
->map(function (Customer $item) {
return [
'id' => $item->id,
'title' => $item->first_name . ' ' . $item->last_name,
'status' => $item->pipeline_stage_id,
];
});
}

// We are checking if the record is in the status
protected function isRecordInStatus($record, $status): bool
{
return $record['status'] === $status['id'];
}
}
12 changes: 12 additions & 0 deletions app/Filament/Pages/TaskCalendar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Filament\Pages;

use Filament\Pages\Page;

class TaskCalendar extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.task-calendar';
}
Loading

0 comments on commit deed34d

Please sign in to comment.