nWidart / laravel-modules如何在我的视图中使用配置关键模块

时间:2019-02-10 09:37:49

标签: laravel

我使用nWidart / laravel-modules包,我需要在视图中使用myModulesName Config键。 我的配置路径:Modules\Tickets\Config\config.php 而我的config.php是:

<?php

return [
    'name' => 'Tickets',

    'status' => [
        '1' => 'باز',
        '2' => 'درحال بررسی',
        '3' => 'بسته شده'
    ],
    'color' => [
        '1' => 'label-danger',
        '2' => 'label-warning',
        '3' => 'label-success',
    ],
];

现在,在我看来,如何使用配置键?

谢谢

2 个答案:

答案 0 :(得分:0)

将此config.php文件添加到名称为public class Item { private String itemName; private int itemNumber; private int itemQuantity; private double itemPrice; public Item() { itemName = " "; itemNumber = 0; itemQuantity = 0; itemPrice = 0.0; } public Item(String name, int itemNum, int itemQty, double itemP) { this.itemName = name; this.itemNumber = itemNum; this.itemQuantity = itemQty; this.itemPrice = itemP; } public void setItemName(String name) { this.itemName = name; } public void setItemNumber(int itemNum) { this.itemNumber = itemNum; } public void setItemQuantity(int itemQty) { this.itemQuantity = itemQty; } public void setItemPrice(double itemP) { this.itemPrice = itemP; } public String getName() { return this.itemName; } public int getItemNumber() { return this.itemNumber; } public int getItemQuantity() { return this.itemQuantity; } public double getItemPrice() { return this.itemPrice; } public void displayData() { for (int i = 0; i < 1; i++) { System.out.println("Name: " + this.itemName + "\t\tItem number: " + this.itemNumber + "\t\tPrice: $" + this.itemPrice + "\t\tQuantity: " + this.itemQuantity); } } public boolean is_the_same(Item itemNum) { boolean same = (itemName.equals(itemNum.itemName) && itemNumber == itemNum.itemNumber); return same; } } //end of constructor import java.util.Scanner; public class test { public static void main(String[] args) { Item ItemArray[] = new Item[6]; Scanner input = new Scanner(System.in); String[] itemName = {"Eggs", "Chicken", "Coca-Cola", "Apple", "Water", "Chocolate"}; int[] itemNumber = {1, 5, 11, 15, 12, 20}; Double[] itemPrice = {0.2, 5.8, 1.4, 0.6, 1.0, 0.7}; int[] itemQuantity = {60, 20, 12, 35, 80, 58}; for (int x = 0; x < ItemArray.length; x++) { ItemArray[x] = new Item(itemName[x], itemNumber[x], itemQuantity[x], itemPrice[x]); } for (int i = 0; i < 1; i++) { System.out.println("Choose one of the options[] below: \n[1] Buy item. \n[2] Add an item to store. \n[3] List all items and their prices. \n[4] Search for an item."); System.out.print("Enter Option: "); int Option = input.nextInt(); if (Option < 1 || Option > 4) { System.out.println("\nInvalid Option. Please enter option again."); System.out.println("Choose one of the options[] below: \n[1] Buy item. \n[2] Add an item to store. \n[3] List all items and their prices. \n[4] Search for an item."); System.out.print("Enter Option: "); Option = input.nextInt(); } if (Option == 2) { System.out.print("\n--------------OPTION 2--------------"); System.out.print("\nHow many items to add to store: "); int Store = input.nextInt(); for (int c = 0; c < Store; c++) { System.out.print("Name: "); ItemArray[c].setItemName(input.next()); System.out.print("Number: "); ItemArray[c].setItemNumber(Integer.parseInt(input.next())); System.out.print("Price: $"); ItemArray[c].setItemPrice(Double.parseDouble(input.next())); System.out.print("Quantity: "); ItemArray[c].setItemQuantity(Integer.parseInt(input.next())); } input.close(); System.out.print("\n\n"); for (int c = 0; c < ItemArray.length; c++) { ItemArray[c].displayData(); } System.exit(0); } } } } 的config文件夹中,并获得如下值:

tickets.php

在运行此命令{{ config('tickets.name') }}

之前

要使用另一个文件夹Follow this中的软件包

答案 1 :(得分:0)

return [
  'name' => 'Blog',
  'fa_name' => 'وبلاگ',
  'icon' => 'comment',
  'color1' => 'EF6F6C',
  'color2' => 'EF6F6C',
  'route' => 'blog',
  'disable' => false,

  'subs' => [
    ['name' => 'مطالب وبلاگ', 'route' => 'blog/list'],
    ['name' => 'دسته بندی ها', 'route' => 'category/list']
  ]
];