CHANGE purchase_module:ss

This commit is contained in:
sriramv 2024-04-23 11:15:46 +05:30
parent a6d5ae227f
commit be80321e44
14 changed files with 170 additions and 77 deletions

View File

@ -32,6 +32,8 @@ class Purchase extends BaseController
$purchase = $PurchaseOrderModel->getPurchaseOrdersWithProducts($this->session->get('logged_user_branch_id')); $purchase = $PurchaseOrderModel->getPurchaseOrdersWithProducts($this->session->get('logged_user_branch_id'));
// echo "<pre>"; // echo "<pre>";
// print_r($product);die; // print_r($product);die;
// echo json_encode($purchase);die;
$data['purchase']=$purchase; $data['purchase']=$purchase;
// echo "<pre>"; // echo "<pre>";
@ -184,7 +186,8 @@ class Purchase extends BaseController
$child_data = [ $child_data = [
'purchase_order_id' => $purchase_order_id, 'purchase_order_id' => $purchase_order_id,
'product_id' => $product_id, 'product_id' => $product_id,
'qty' => $qty, // 'qty' => $qty,
// 'received_qty' => $qty,
// 'discount' => $discount, // 'discount' => $discount,
// 'discount_type' => $discount_type, // 'discount_type' => $discount_type,
'net_price'=>$rate, 'net_price'=>$rate,
@ -193,6 +196,14 @@ class Purchase extends BaseController
'is_selected'=>$selected_item, 'is_selected'=>$selected_item,
'isactive'=>1, 'isactive'=>1,
]; ];
if($status == 'Received') {
$child_data['received_qty'] = $qty;
}
else{
$child_data['qty'] = $qty;
}
// print_r($child_data);die; // print_r($child_data);die;
if (!empty($purchase_order_child_id[$key])) { if (!empty($purchase_order_child_id[$key])) {

View File

@ -25,25 +25,53 @@ class Reorderlevel extends BaseController
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
$productModel = new ProductModel(); $productModel = new ProductModel();
$reorder = $productModel->select('products.*, vendor.vendor_name as prefered_vendor_name') $reorder = $productModel->select('products.*, vendor.vendor_name as prefered_vendor_name, COUNT(vendor.vendor_name) as product_count')
->join('vendor', 'vendor.vendor_id = products.prefered_vendor') ->join('vendor', 'vendor.vendor_id = products.prefered_vendor')
->where('products.qty_stock <= purchase_order_level') ->where('products.qty_stock <= purchase_order_level')
->groupBy('products.prefered_vendor')
->findAll(); ->findAll();
// echo json_encode($reorder);die;
$data['reorder']=$reorder; $data['reorder']=$reorder;
return view('reorder_level_list',$data); return view('reorder_level_list',$data);
} }
public function rise_order($product_id) // public function rise_order($product_id)
// {
// if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
// $data['page_name']="Rise Order";
// $ProductModel = new ProductModel();
// $products=$ProductModel->where('product_id', $product_id)->get()->getRowArray();
// $data['products']=$products;
// // echo "<pre>";
// // print_r($products);die;
// $vendorid= $products['prefered_vendor'];
// $VendorModel = new VendorModel();
// $vendor=$VendorModel->where('vendor_id',$vendorid)->findAll();
// $data['vendor']=$vendor;
// $PurchaseOrderModel = new PurchaseOrderModel();
// $purchase=$PurchaseOrderModel->where('vendor_id',$vendorid)->first();
// $data['purchase']=$purchase;
// return view('reorder_level_form',$data);
// }
public function rise_order($prefered_vendor)
{ {
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
$data['page_name']="Rise Order"; $data['page_name']="Rise Order";
$ProductModel = new ProductModel(); $ProductModel = new ProductModel();
$products=$ProductModel->where('product_id', $product_id)->get()->getRowArray(); $products=$ProductModel->where('prefered_vendor', $prefered_vendor)->where('qty_stock <= purchase_order_level')->findAll();
// echo json_encode($products);die;
$data['products']=$products; $data['products']=$products;
// echo "<pre>"; // echo "<pre>";
// print_r($products);die; // print_r($products);die;
$vendorid= $products['prefered_vendor']; $vendorid= $prefered_vendor;
$product_data = $ProductModel->where('prefered_vendor', $vendorid)->findAll();
// echo json_encode($product_data);die;
$data['product_data'] = $product_data;
$VendorModel = new VendorModel(); $VendorModel = new VendorModel();
$vendor=$VendorModel->where('vendor_id',$vendorid)->findAll(); $vendor=$VendorModel->where('vendor_id',$vendorid)->findAll();
$data['vendor']=$vendor; $data['vendor']=$vendor;

View File

@ -91,7 +91,7 @@ class ReturnOrder extends BaseController
$PurchaseOrderChildModel = new PurchaseOrderChildModel(); $PurchaseOrderChildModel = new PurchaseOrderChildModel();
$purchase_product=$PurchaseOrderChildModel->where('purchase_order_id', $purchase_order_id)->findAll(); $purchase_product=$PurchaseOrderChildModel->where('purchase_order_id', $purchase_order_id)->where('received_qty >', 0)->where('is_selected', 1)->findAll();
$data['purchase_product'] = $purchase_product; $data['purchase_product'] = $purchase_product;
@ -132,6 +132,7 @@ class ReturnOrder extends BaseController
$ReturnModel = new ReturnModel(); $ReturnModel = new ReturnModel();
$ReturnOrderChildModel = new ReturnOrderChildModel(); $ReturnOrderChildModel = new ReturnOrderChildModel();
$PurchaseOrderChildModel = new PurchaseOrderChildModel();
$return = $ReturnModel->where('return_order_id', $return_order_id)->first(); $return = $ReturnModel->where('return_order_id', $return_order_id)->first();
@ -143,6 +144,14 @@ class ReturnOrder extends BaseController
$quantity =$this->request->getPost('quantity'); $quantity =$this->request->getPost('quantity');
$item_details =$this->request->getPost('item_details'); $item_details =$this->request->getPost('item_details');
foreach ($item_details as $index => $item_detail) { foreach ($item_details as $index => $item_detail) {
// reduce qty in purchaase child
$purchase_id = $this->request->getPost('purchase_order_id');
$purchase_order_data = $PurchaseOrderChildModel->where('purchase_order_id', $purchase_id)->where('product_id', $item_detail)->first();
$received_qty = $purchase_order_data['received_qty'] - $quantity[$index];
$PurchaseOrderChildModel->update($purchase_order_data['purchase_order_child_id'], [ 'received_qty' => $received_qty ]);
$product = $ProductModel->where('product_id',$item_detail)->first(); $product = $ProductModel->where('product_id',$item_detail)->first();
$changed_quantity = $product['qty_stock'] - $quantity[$index]; $changed_quantity = $product['qty_stock'] - $quantity[$index];
$product_id = $item_detail; $product_id = $item_detail;
@ -157,7 +166,7 @@ class ReturnOrder extends BaseController
$return_order_id = $this->request->getPost('return_order_id'); $return_order_id = $this->request->getPost('return_order_id');
// echo $this->request->getPost('return_order_id');die;
if (!empty($return_order_id)) { if (!empty($return_order_id)) {
$this->returnModel->update($return_order_id, $data); $this->returnModel->update($return_order_id, $data);

View File

@ -5,7 +5,7 @@ class PurchaseOrderChildModel extends Model
{ {
protected $table = 'purchase_order_child'; protected $table = 'purchase_order_child';
protected $primaryKey = 'purchase_order_child_id'; protected $primaryKey = 'purchase_order_child_id';
protected $allowedFields = ['purchase_order_child_id','is_selected','purchase_order_id','product_id','qty','total','tax','net_price','amount','discount_type','selling_price','discount','isactive']; protected $allowedFields = ['purchase_order_child_id','is_selected','purchase_order_id','product_id','qty', 'received_qty','total','tax','net_price','amount','discount_type','selling_price','discount','isactive'];
} }

View File

@ -21,6 +21,10 @@ class PurchaseOrderModel extends Model
// Add condition to fetch only active sales orders // Add condition to fetch only active sales orders
$this->where('purchase_order_child.isactive', 1); $this->where('purchase_order_child.isactive', 1);
$this ->where('purchase_order.branch_id',$logged_user_branch_id); $this ->where('purchase_order.branch_id',$logged_user_branch_id);
$subquery = "(SELECT COUNT(*) FROM purchase_order_child WHERE purchase_order_child.purchase_order_id = purchase_order.purchase_order_id AND purchase_order_child.is_selected = 1) AS selected_product_count";
$this->select($subquery, false);
$this->orderBy('purchase_order.purchase_order_id','DESC'); $this->orderBy('purchase_order.purchase_order_id','DESC');
// Get the results // Get the results
return $this->findAll(); return $this->findAll();

View File

@ -145,7 +145,7 @@
<a href="<?php echo base_url('return_order') ?>"> Purchase Return</a> <a href="<?php echo base_url('return_order') ?>"> Purchase Return</a>
</li> </li>
<li> <li>
<a href="<?php echo base_url('reorder_level_index') ?>">Reorder List</a> <a href="<?php echo base_url('reorder_level_index') ?>">Low Stock Items</a>
</li> </li>
<li> <li>
<a href="<?php echo base_url('vendor_index') ?>">Vendor</a> <a href="<?php echo base_url('vendor_index') ?>">Vendor</a>

View File

@ -169,7 +169,7 @@
</select> </select>
</td> </td>
<td style="width:5%;"> <td style="width:5%;">
<input type="number" class="form-control item-quantity" name="quantity[]" min="0" value="<?= isset($purchasechild['qty']) ? $purchasechild['qty'] : '' ?>"> <input type="number" class="form-control item-quantity" name="quantity[]" min="0" value="<?= isset($purchasechild['received_qty']) && $purchasechild['received_qty'] != null ? $purchasechild['received_qty'] : $purchasechild['qty'] ?>">
</td> </td>
<td style="width:2%;"> <td style="width:2%;">
<input type="hidden" name="selected_items[]" value="<?= ($purchasechild['is_selected'] == 1) ? 'checked' : 'unchecked' ?>"> <!-- Hidden input for unchecked checkboxes --> <input type="hidden" name="selected_items[]" value="<?= ($purchasechild['is_selected'] == 1) ? 'checked' : 'unchecked' ?>"> <!-- Hidden input for unchecked checkboxes -->

View File

@ -55,7 +55,7 @@
<th>Contact Person Details</th> <th>Contact Person Details</th>
<!-- <th>Contact Person Mobile</th> --> <!-- <th>Contact Person Mobile</th> -->
<th>Items</th> <th>Items</th>
<th>Received Items</th>
<th>Status</th> <th>Status</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
@ -71,6 +71,7 @@
<td><?= $value['contact_person_name']; ?><br> <td><?= $value['contact_person_name']; ?><br>
<?= $value['contact_person_mobile']; ?> <?= $value['contact_person_mobile']; ?>
<td><?= $value['product_count']; ?></td> <td><?= $value['product_count']; ?></td>
<td><?= $value['selected_product_count']; ?></td>
<td class="<?php <td class="<?php
if ($value['status'] == 'Cancel') { if ($value['status'] == 'Cancel') {
echo 'cancelled-status'; echo 'cancelled-status';

View File

@ -111,35 +111,34 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php if (isset($products) && !empty($products)) : ?> <?php if (isset($products) && !empty($products)) :
foreach ($products as $product) { ?>
<tr> <tr>
<td style="width:10%;"> <td style="width:10%;">
<select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;"> <select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option> <option value="">Select a Product</option>
<option value="<?= $products["product_id"] ?>" <?= isset($products['product_id']) ? 'selected' : '' ?>> <option value="<?= $product["product_id"] ?>" <?= isset($product['product_id']) ? 'selected' : '' ?>>
<?= $products["product_name"]; ?> <?= $product["product_name"]; ?>
</option> </option>
</select> </select>
</td> </td>
<td style="width:5%;"> <td style="width:5%;">
<input type="number" class="form-control item-quantity" name="quantity[]" min="0" value="<?= isset($products['reorder_level']) ? $products['reorder_level'] : '' ?>"> <input type="number" class="form-control item-quantity" name="quantity[]" min="1" value="<?= isset($product['reorder_level']) ? $product['reorder_level'] : '' ?>">
</td> </td>
<td style="width:5%;"> <td style="width:5%;">
<center><i class="fa fa-trash remove-item"></i></center> <center><i class="fa fa-trash"></i></center>
</td> </td>
</tr> </tr>
<?php endif; ?> <?php } endif; ?>
<!-- You can add more rows as needed using JavaScript --> <!-- You can add more rows as needed using JavaScript -->
</tbody> </tbody>
</table> </table>
<?php if (empty($purchase["status"])): ?>
<div class="form-group text-right m-b-0"> <div class="form-group text-right m-b-0">
<!-- Show the "Add More Item" button only if invoice_type is not 1 --> <!-- Show the "Add More Item" button only if invoice_type is not 1 -->
<a class="btn" id="addItem"> <a class="btn" id="addItem">
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Product</h4> <h4><i class="fa fa-plus" aria-hidden="true"></i> Add Product</h4>
</a> </a>
</div> </div>
<?php endif; ?>
</div> </div>
</div> </div>
<h4 class="header-title">Terms & Condition :</h4><br> <h4 class="header-title">Terms & Condition :</h4><br>
@ -160,7 +159,39 @@
</div> </div>
</div> </div>
</div> </div>
<input type="hidden" id="pr_data" value="<?= htmlspecialchars(json_encode($product_data)); ?>">
<?php include('layout/footer.php'); ?> <?php include('layout/footer.php'); ?>
<script>
// Event listener for "Add More Item" button
$('#addItem').click(function() {
const productarray = JSON.parse($('#pr_data').val())
console.log($('#pr_data').val());
var newRow = '<tr>' +
'<td><select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Product</option>';
for (var i = 0; i < productarray.length; i++) {
var product = productarray[i];
newRow += '<option value="' + product.product_id + '" >' + product.product_name +
'</option>';
}
newRow += '</select></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="1" max="" value="1" name="quantity[]"/></td>' +
'<td><center><i class="fa fa-trash remove-item"></i></center></td>' +
'</tr>';
$('#itemTable tbody').append(newRow);
initializeSelect2();
updateCalculations();
initializeRowCalculations(row);
});
$(document).on('click', '.remove-item', function() {
$(this).closest('tr').remove();
});
</script>

View File

@ -26,11 +26,11 @@
<thead> <thead>
<tr> <tr>
<th>Product Name</th>
<th>Vendor Name</th> <th>Vendor Name</th>
<th>Unit Price</th> <!-- <th>Vendor Name</th>
<th>Qty in Stock</th> <th>Unit Price</th> -->
<th>Re-Order Level</th> <th>Qty</th>
<!-- <th>Re-Order Level</th> -->
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
@ -40,13 +40,15 @@
<?php foreach ($reorder as $value) : ?> <?php foreach ($reorder as $value) : ?>
<tr> <tr>
<td><?= $value['product_name']; ?></td>
<td><?= $value['prefered_vendor_name']; ?></td> <td><?= $value['prefered_vendor_name']; ?></td>
<td><?= $value['product_count']; ?></td>
<!-- <td><?= $value['prefered_vendor_name']; ?></td>
<td><?= number_format($value['unit_price']); ?></td> <td><?= number_format($value['unit_price']); ?></td>
<td><?= $value['qty_stock']; ?></td> <td><?= $value['qty_stock']; ?></td>
<td><?= $value['purchase_order_level']; ?></td> <td><?= $value['purchase_order_level']; ?></td> -->
<td> <td>
<a href="<?= "rise_order/" . $value['product_id']; ?>" class="edit-button"><i class="ri-arrow-up-circle-fill"></i>Rise</a> <!-- <a href="<?= "rise_order/" . $value['product_id']; ?>" class="edit-button"><i class="ri-arrow-up-circle-fill"></i>Rise</a> -->
<a href="<?= "rise_order/" . $value['prefered_vendor']; ?>" class="edit-button"><i class="ri-arrow-up-circle-fill"></i>Rise</a>
</td> </td>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -149,7 +149,7 @@
</select> </select>
</td> </td>
<td style="width:5%;"> <td style="width:5%;">
<input type="number" class="form-control item-quantity" name="quantity[]" min="1" max="<?= isset($purchasechild['qty']) ? $purchasechild['qty'] : '' ?>" value="<?= isset($purchasechild['qty']) ? $purchasechild['qty'] : '' ?>"> <input type="number" class="form-control item-quantity" name="quantity[]" min="1" max="<?= isset($purchasechild['received_qty']) ? $purchasechild['received_qty'] : '' ?>" value="<?= isset($purchasechild['received_qty']) ? $purchasechild['received_qty'] : '' ?>">
</td> </td>
<td style="width:7%;"> <td style="width:7%;">
<input type="checkbox" class="form-control-check-input" name="return_selected_items[]" value="<?= $key; ?>"> <input type="checkbox" class="form-control-check-input" name="return_selected_items[]" value="<?= $key; ?>">

View File

@ -53,7 +53,7 @@
<th>Order Date</th> <th>Order Date</th>
<th>Contact Person Details</th> <th>Contact Person Details</th>
<th>Items</th> <th>Items</th>
<th>Received Items</th>
<th>Status</th> <th>Status</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
@ -69,6 +69,7 @@
<td><?= $value['contact_person_name']; ?><br> <td><?= $value['contact_person_name']; ?><br>
<?= $value['contact_person_mobile']; ?> <?= $value['contact_person_mobile']; ?>
<td><?= $value['product_count']; ?></td> <td><?= $value['product_count']; ?></td>
<td><?= $value['selected_product_count']; ?></td>
<td class="<?php <td class="<?php
if ($value['status'] == 'Cancel') { if ($value['status'] == 'Cancel') {
echo 'cancelled-status'; echo 'cancelled-status';

View File

@ -45,34 +45,35 @@ class ClassLoader
/** @var \Closure(string):void */ /** @var \Closure(string):void */
private static $includeFile; private static $includeFile;
/** @var string|null */ /** @var ?string */
private $vendorDir; private $vendorDir;
// PSR-4 // PSR-4
/** /**
* @var array<string, array<string, int>> * @var array[]
* @psalm-var array<string, array<string, int>>
*/ */
private $prefixLengthsPsr4 = array(); private $prefixLengthsPsr4 = array();
/** /**
* @var array<string, list<string>> * @var array[]
* @psalm-var array<string, array<int, string>>
*/ */
private $prefixDirsPsr4 = array(); private $prefixDirsPsr4 = array();
/** /**
* @var list<string> * @var array[]
* @psalm-var array<string, string>
*/ */
private $fallbackDirsPsr4 = array(); private $fallbackDirsPsr4 = array();
// PSR-0 // PSR-0
/** /**
* List of PSR-0 prefixes * @var array[]
* * @psalm-var array<string, array<string, string[]>>
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
*/ */
private $prefixesPsr0 = array(); private $prefixesPsr0 = array();
/** /**
* @var list<string> * @var array[]
* @psalm-var array<string, string>
*/ */
private $fallbackDirsPsr0 = array(); private $fallbackDirsPsr0 = array();
@ -80,7 +81,8 @@ class ClassLoader
private $useIncludePath = false; private $useIncludePath = false;
/** /**
* @var array<string, string> * @var string[]
* @psalm-var array<string, string>
*/ */
private $classMap = array(); private $classMap = array();
@ -88,20 +90,21 @@ class ClassLoader
private $classMapAuthoritative = false; private $classMapAuthoritative = false;
/** /**
* @var array<string, bool> * @var bool[]
* @psalm-var array<string, bool>
*/ */
private $missingClasses = array(); private $missingClasses = array();
/** @var string|null */ /** @var ?string */
private $apcuPrefix; private $apcuPrefix;
/** /**
* @var array<string, self> * @var self[]
*/ */
private static $registeredLoaders = array(); private static $registeredLoaders = array();
/** /**
* @param string|null $vendorDir * @param ?string $vendorDir
*/ */
public function __construct($vendorDir = null) public function __construct($vendorDir = null)
{ {
@ -110,7 +113,7 @@ class ClassLoader
} }
/** /**
* @return array<string, list<string>> * @return string[]
*/ */
public function getPrefixes() public function getPrefixes()
{ {
@ -122,7 +125,8 @@ class ClassLoader
} }
/** /**
* @return array<string, list<string>> * @return array[]
* @psalm-return array<string, array<int, string>>
*/ */
public function getPrefixesPsr4() public function getPrefixesPsr4()
{ {
@ -130,7 +134,8 @@ class ClassLoader
} }
/** /**
* @return list<string> * @return array[]
* @psalm-return array<string, string>
*/ */
public function getFallbackDirs() public function getFallbackDirs()
{ {
@ -138,7 +143,8 @@ class ClassLoader
} }
/** /**
* @return list<string> * @return array[]
* @psalm-return array<string, string>
*/ */
public function getFallbackDirsPsr4() public function getFallbackDirsPsr4()
{ {
@ -146,7 +152,8 @@ class ClassLoader
} }
/** /**
* @return array<string, string> Array of classname => path * @return string[] Array of classname => path
* @psalm-return array<string, string>
*/ */
public function getClassMap() public function getClassMap()
{ {
@ -154,7 +161,8 @@ class ClassLoader
} }
/** /**
* @param array<string, string> $classMap Class to filename map * @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
* *
* @return void * @return void
*/ */
@ -171,25 +179,24 @@ class ClassLoader
* Registers a set of PSR-0 directories for a given prefix, either * Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix. * appending or prepending to the ones previously set for this prefix.
* *
* @param string $prefix The prefix * @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 root directories * @param string[]|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories * @param bool $prepend Whether to prepend the directories
* *
* @return void * @return void
*/ */
public function add($prefix, $paths, $prepend = false) public function add($prefix, $paths, $prepend = false)
{ {
$paths = (array) $paths;
if (!$prefix) { if (!$prefix) {
if ($prepend) { if ($prepend) {
$this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0 = array_merge(
$paths, (array) $paths,
$this->fallbackDirsPsr0 $this->fallbackDirsPsr0
); );
} else { } else {
$this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0, $this->fallbackDirsPsr0,
$paths (array) $paths
); );
} }
@ -198,19 +205,19 @@ class ClassLoader
$first = $prefix[0]; $first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) { if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = $paths; $this->prefixesPsr0[$first][$prefix] = (array) $paths;
return; return;
} }
if ($prepend) { if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix] = array_merge(
$paths, (array) $paths,
$this->prefixesPsr0[$first][$prefix] $this->prefixesPsr0[$first][$prefix]
); );
} else { } else {
$this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix], $this->prefixesPsr0[$first][$prefix],
$paths (array) $paths
); );
} }
} }
@ -219,9 +226,9 @@ class ClassLoader
* Registers a set of PSR-4 directories for a given namespace, either * Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace. * appending or prepending to the ones previously set for this namespace.
* *
* @param string $prefix The prefix/namespace, with trailing '\\' * @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories * @param string[]|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories * @param bool $prepend Whether to prepend the directories
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* *
@ -229,18 +236,17 @@ class ClassLoader
*/ */
public function addPsr4($prefix, $paths, $prepend = false) public function addPsr4($prefix, $paths, $prepend = false)
{ {
$paths = (array) $paths;
if (!$prefix) { if (!$prefix) {
// Register directories for the root namespace. // Register directories for the root namespace.
if ($prepend) { if ($prepend) {
$this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4 = array_merge(
$paths, (array) $paths,
$this->fallbackDirsPsr4 $this->fallbackDirsPsr4
); );
} else { } else {
$this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4, $this->fallbackDirsPsr4,
$paths (array) $paths
); );
} }
} elseif (!isset($this->prefixDirsPsr4[$prefix])) { } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
@ -250,18 +256,18 @@ class ClassLoader
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
} }
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = $paths; $this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) { } elseif ($prepend) {
// Prepend directories for an already registered namespace. // Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix] = array_merge(
$paths, (array) $paths,
$this->prefixDirsPsr4[$prefix] $this->prefixDirsPsr4[$prefix]
); );
} else { } else {
// Append directories for an already registered namespace. // Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix], $this->prefixDirsPsr4[$prefix],
$paths (array) $paths
); );
} }
} }
@ -270,8 +276,8 @@ class ClassLoader
* Registers a set of PSR-0 directories for a given prefix, * Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix. * replacing any others previously set for this prefix.
* *
* @param string $prefix The prefix * @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 base directories * @param string[]|string $paths The PSR-0 base directories
* *
* @return void * @return void
*/ */
@ -288,8 +294,8 @@ class ClassLoader
* Registers a set of PSR-4 directories for a given namespace, * Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace. * replacing any others previously set for this namespace.
* *
* @param string $prefix The prefix/namespace, with trailing '\\' * @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories * @param string[]|string $paths The PSR-4 base directories
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* *
@ -475,9 +481,9 @@ class ClassLoader
} }
/** /**
* Returns the currently registered loaders keyed by their corresponding vendor directories. * Returns the currently registered loaders indexed by their corresponding vendor directories.
* *
* @return array<string, self> * @return self[]
*/ */
public static function getRegisteredLoaders() public static function getRegisteredLoaders()
{ {

View File

@ -3,7 +3,7 @@
'name' => 'codeigniter4/framework', 'name' => 'codeigniter4/framework',
'pretty_version' => 'dev-main', 'pretty_version' => 'dev-main',
'version' => 'dev-main', 'version' => 'dev-main',
'reference' => '61daab30b3008141deb7b9c58dc792e9799011e7', 'reference' => 'a6d5ae227f80d0f293a23092015a3ef9d9b572e4',
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
@ -22,7 +22,7 @@
'codeigniter4/framework' => array( 'codeigniter4/framework' => array(
'pretty_version' => 'dev-main', 'pretty_version' => 'dev-main',
'version' => 'dev-main', 'version' => 'dev-main',
'reference' => '61daab30b3008141deb7b9c58dc792e9799011e7', 'reference' => 'a6d5ae227f80d0f293a23092015a3ef9d9b572e4',
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),