Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Main #27

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
search
  • Loading branch information
Adiconquerors committed Sep 24, 2024
commit 1319e952c34297b97e2832beb50e3b0fdf3198a8
55 changes: 55 additions & 0 deletions app/Http/Livewire/SearchReports.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
namespace App\Http\Livewire;

use App\Models\Report;
use Livewire\Component;

class SearchReports extends Component
{
public $searchTest = '';
public $searchItem = '';
public $reports = []; // Public property to hold filtered reports

public function mount() // Fetch all reports when the component is mounted
{
$this->reports = Report::all(); // Load all records initially
}

public function updatedSearchTest() // Triggered when the searchTest changes
{
$this->searchFeedMessage(); // Call the search method when input changes
}

public function searchFeedMessage()
{
if ($this->searchTest !== '') {
// Filter reports based on search input
$this->reports = Report::where('test', 'like', '%' . $this->searchTest . '%')->get();
} else {
// Reset reports to show all records when the search input is empty
$this->reports = Report::all();
}
}

public function updatedSearchItem() // Triggered when the searchTest changes
{
$this->searchItemReports(); // Call the search method when input changes
}

public function searchItemReports()
{
if ($this->searchItem !== '') {
// Filter reports based on search input
$this->reports = Report::where('item_name', 'like', '%' . $this->searchItem . '%')->get();
} else {
// Reset reports to show all records when the search input is empty
$this->reports = Report::all();
}
}

public function render()
{
// Pass the current reports to the view
return view('livewire.search-reports', ['reports' => $this->reports]);
}
}
75 changes: 75 additions & 0 deletions resources/views/livewire/search-reports.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<div>
<input wire:model.debounce.300ms="searchTest" class="outline-none bg-[#F0F2F5] rounded-md pl-16 py-1 w-[26vw] mr-2" placeholder="Search Test Name" type="text" id="search">
<input wire:model.debounce.300ms="searchItem" class="outline-none bg-[#F0F2F5] rounded-md pl-16 py-1 w-[26vw] mr-2" placeholder="Search Item Name" type="text" id="search">

<div class="tabs-content">
<div x-show="activeTab === 'details'" class="tab-content" id="details">
<div class="m-2">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Item Name</th>
<th scope="col">Item Code</th>
<th scope="col">Generic Item Name</th>
<th scope="col">Item Category</th>
<th scope="col">Department</th>
<th scope="col">Machine</th>
<th scope="col">Test Code</th>
<th scope="col">Test Name</th>
<th scope="col">Supplier Name</th>
<th scope="col">Address</th>
<th scope="col">Manufacture</th>
<th scope="col">HSN Code</th>
<th scope="col">Unit of Purchase</th>
<th scope="col">Pack Size</th>
<th scope="col">Test</th>
<th scope="col">Unit Price</th>
<th scope="col">CGST</th>
<th scope="col">SGST</th>
<th scope="col">Price (GST)</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
@foreach($reports as $report)
<tr>
<td>{{ $report->item_name }}</td>
<td>{{ $report->item_code }}</td>
<td>{{ $report->generic_item_name }}</td>
<td>{{ $report->item_category }}</td>
<td>{{ $report->department }}</td>
<td>{{ $report->machine }}</td>
<td>{{ $report->test_code }}</td>
<td>{{ $report->test_name }}</td>
<td>{{ $report->supplier_name }}</td>
<td>{{ $report->address }}</td>
<td>{{ $report->manufacture }}</td>
<td>{{ $report->hsn_code }}</td>
<td>{{ $report->unit_of_purchase }}</td>
<td>{{ $report->pack_size }}</td>
<td>{{ $report->test }}</td>
<td>{{ $report->unit_price }}</td>
<td>{{ $report->cgst }}</td>
<td>{{ $report->sgst }}</td>
<td>{{ $report->price_gst }}</td>
<td>
<!-- Action buttons can be added here -->
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>

<div x-show="activeTab === 'company'" class="tab-content" id="company">
<p>Company</p>
</div>

<div x-show="activeTab === 'team'" class="tab-content" id="team">
<p>Team</p>
</div>
</div>
</div>