Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 5 additions & 6 deletions app/Exports/CitiesExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace App\Exports;

use App\Models\City;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class CitiesExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize, WithStyles
class CitiesExport implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithStyles
{
protected $cities;

Expand All @@ -20,8 +19,8 @@ public function __construct($cities)
}

/**
* @return \Illuminate\Support\Collection
*/
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return $this->cities;
Expand Down Expand Up @@ -55,7 +54,7 @@ public function styles(Worksheet $sheet)
{
return [
// Style the first row as bold text.
1 => ['font' => ['bold' => true]],
1 => ['font' => ['bold' => true]],
];
}
}
11 changes: 5 additions & 6 deletions app/Exports/CustomersExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace App\Exports;

use App\Models\Customer;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class CustomersExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize, WithStyles
class CustomersExport implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithStyles
{
protected $customers;

Expand All @@ -20,8 +19,8 @@ public function __construct($customers)
}

/**
* @return \Illuminate\Support\Collection
*/
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return $this->customers;
Expand Down Expand Up @@ -67,7 +66,7 @@ public function styles(Worksheet $sheet)
{
return [
// Style the first row as bold text.
1 => ['font' => ['bold' => true]],
1 => ['font' => ['bold' => true]],
];
}
}
46 changes: 23 additions & 23 deletions app/Exports/ProductTemplateExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

namespace App\Exports;

use App\Models\Category;
use App\Models\Unit;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
use App\Models\Category;
use App\Models\Unit;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class ProductTemplateExport implements FromCollection, WithHeadings, WithTitle, WithStyles, WithEvents
class ProductTemplateExport implements FromCollection, WithEvents, WithHeadings, WithStyles, WithTitle
{
public function collection()
{
Expand All @@ -31,8 +31,8 @@ public function collection()
'3000.00', // Limit Price
'50', // Quantity
'5', // Alert Quantity
'https://example.com/image.jpg' // Image URL
]
'https://example.com/image.jpg', // Image URL
],
]);
}

Expand All @@ -50,7 +50,7 @@ public function headings(): array
'Limit Price',
'Quantity*',
'Alert Quantity',
'Image URL'
'Image URL',
];
}

Expand All @@ -65,25 +65,25 @@ public function styles(Worksheet $sheet)
1 => ['font' => ['bold' => true]],
];
}

public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
AfterSheet::class => function (AfterSheet $event) {
$sheet = $event->sheet;

// 1. Category Dropdown (Column B)
$categories = Category::pluck('name')->toArray();
if(!empty($categories)) {
if (! empty($categories)) {
$catValidation = $sheet->getCell('B2')->getDataValidation();
$catValidation->setType(DataValidation::TYPE_LIST);
$catValidation->setErrorStyle(DataValidation::STYLE_INFORMATION);
$catValidation->setAllowBlank(false);
$catValidation->setShowInputMessage(true);
$catValidation->setShowErrorMessage(true);
$catValidation->setShowDropDown(true);
$catValidation->setFormula1('"' . implode(',', $categories) . '"');
$catValidation->setFormula1('"'.implode(',', $categories).'"');

// Apply to 100 rows
for ($i = 2; $i <= 100; $i++) {
$sheet->getCell("B$i")->setDataValidation(clone $catValidation);
Expand All @@ -92,30 +92,30 @@ public function registerEvents(): array

// 2. Sub Category Dropdown (Column C)
$subCategories = \App\Models\SubCategory::pluck('name')->toArray();
if(!empty($subCategories)) {
if (! empty($subCategories)) {
$subCatValidation = $sheet->getCell('C2')->getDataValidation();
$subCatValidation->setType(DataValidation::TYPE_LIST);
$subCatValidation->setErrorStyle(DataValidation::STYLE_INFORMATION);
$subCatValidation->setAllowBlank(true);
$subCatValidation->setShowDropDown(true);
$subCatValidation->setFormula1('"' . implode(',', $subCategories) . '"');
for ($i = 2; $i <= 100; $i++) {
$subCatValidation->setFormula1('"'.implode(',', $subCategories).'"');

for ($i = 2; $i <= 100; $i++) {
$sheet->getCell("C$i")->setDataValidation(clone $subCatValidation);
}
}

// 3. Unit Dropdown (Column E)
$units = Unit::pluck('name')->toArray();
if(!empty($units)) {
if (! empty($units)) {
$unitValidation = $sheet->getCell('E2')->getDataValidation();
$unitValidation->setType(DataValidation::TYPE_LIST);
$unitValidation->setErrorStyle(DataValidation::STYLE_INFORMATION);
$unitValidation->setAllowBlank(false);
$unitValidation->setShowDropDown(true);
$unitValidation->setFormula1('"' . implode(',', $units) . '"');
for ($i = 2; $i <= 100; $i++) {
$unitValidation->setFormula1('"'.implode(',', $units).'"');

for ($i = 2; $i <= 100; $i++) {
$sheet->getCell("E$i")->setDataValidation(clone $unitValidation);
}
}
Expand Down
20 changes: 10 additions & 10 deletions app/Exports/ProductsExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use App\Models\Product;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;

class ProductsExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize
class ProductsExport implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping
{
protected $request;

Expand All @@ -18,8 +18,8 @@ public function __construct($request)
}

/**
* @return \Illuminate\Support\Collection
*/
* @return \Illuminate\Support\Collection
*/
public function collection()
{
$query = \App\Models\ProductVariant::query()->with(['product.category', 'product.subCategory', 'unit']);
Expand All @@ -32,17 +32,17 @@ public function collection()

if (isset($this->request['search']) && $this->request['search']) {
$search = $this->request['search'];
$query->where(function($q) use ($search) {
$q->whereHas('product', function($pq) use ($search) {
$query->where(function ($q) use ($search) {
$q->whereHas('product', function ($pq) use ($search) {
$pq->where('name', 'like', "%{$search}%")
->orWhere('barcode_data', 'like', "%{$search}%");
->orWhere('barcode_data', 'like', "%{$search}%");
})
->orWhere('sku', 'like', "%{$search}%");
->orWhere('sku', 'like', "%{$search}%");
});
}

if (isset($this->request['category_id']) && $this->request['category_id']) {
$query->whereHas('product', function($q) {
$query->whereHas('product', function ($q) {
$q->where('category_id', $this->request['category_id']);
});
}
Expand All @@ -64,7 +64,7 @@ public function headings(): array
'Limit Price',
'Quantity',
'Alert Quantity',
'Product Created At'
'Product Created At',
];
}

Expand Down
12 changes: 6 additions & 6 deletions app/Exports/ResellerPaymentTemplateExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace App\Exports;

use App\Models\Reseller;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use App\Models\Reseller;

class ResellerPaymentTemplateExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize
class ResellerPaymentTemplateExport implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping
{
/**
* @return \Illuminate\Support\Collection
*/
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return Reseller::select('id', 'name', 'due_amount')->orderBy('name')->get();
Expand All @@ -27,7 +27,7 @@ public function headings(): array
'Payment Amount',
'Payment Method (cash/bank/other)',
'Reference',
'Date (YYYY-MM-DD)'
'Date (YYYY-MM-DD)',
];
}

Expand Down
11 changes: 5 additions & 6 deletions app/Exports/ResellersExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace App\Exports;

use App\Models\Reseller;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class ResellersExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize, WithStyles
class ResellersExport implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithStyles
{
protected $resellers;

Expand All @@ -20,8 +19,8 @@ public function __construct($resellers)
}

/**
* @return \Illuminate\Support\Collection
*/
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return $this->resellers;
Expand Down Expand Up @@ -69,7 +68,7 @@ public function styles(Worksheet $sheet)
{
return [
// Style the first row as bold text.
1 => ['font' => ['bold' => true]],
1 => ['font' => ['bold' => true]],
];
}
}
11 changes: 5 additions & 6 deletions app/Exports/SuppliersExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace App\Exports;

use App\Models\Supplier;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class SuppliersExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize, WithStyles
class SuppliersExport implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithStyles
{
protected $suppliers;

Expand All @@ -20,8 +19,8 @@ public function __construct($suppliers)
}

/**
* @return \Illuminate\Support\Collection
*/
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return $this->suppliers;
Expand Down Expand Up @@ -67,7 +66,7 @@ public function styles(Worksheet $sheet)
{
return [
// Style the first row as bold text.
1 => ['font' => ['bold' => true]],
1 => ['font' => ['bold' => true]],
];
}
}
5 changes: 3 additions & 2 deletions app/Http/Controllers/Admin/PermissionManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class PermissionManagementController extends Controller
public function index()
{
$permissions = Permission::paginate(10);

return view('admin.permissions.index', compact('permissions'));
}

Expand Down Expand Up @@ -39,7 +40,7 @@ public function edit(Permission $permission)
public function update(Request $request, Permission $permission)
{
$request->validate([
'name' => ['required', 'string', 'max:255', 'unique:permissions,name,' . $permission->id],
'name' => ['required', 'string', 'max:255', 'unique:permissions,name,'.$permission->id],
]);

$permission->update(['name' => $request->name]);
Expand All @@ -54,7 +55,7 @@ public function destroy(Permission $permission)
$criticalPermissions = [
'view users', 'create users', 'edit users', 'delete users',
'view roles', 'create roles', 'edit roles', 'delete roles',
'view permissions', 'assign permissions'
'view permissions', 'assign permissions',
];

if (in_array($permission->name, $criticalPermissions)) {
Expand Down
Loading