我对laravel很新.我有一个基本问题,在laravel中添加常量的最佳方法是什么.我知道我们用来添加常量的.env方法.我还制作了一个常量文件,用于我的项目.例如:
define('OPTION_ATTACHMENT', 13);
define('OPTION_EMAIL', 14);
define('OPTION_MONETERY', 15);
define('OPTION_RATINGS', 16);
define('OPTION_TEXTAREA', 17);
Run Code Online (Sandbox Code Playgroud)
等等.它可以达到100或更多记录.那么编写常量的最佳方法应该是什么..env方法.或者添加constant.php文件?
谢谢
我是magento的新手.基本上,我想将多个产品分配给多个类别.我已经关注这篇文章了,我已经完成了以下代码,它运行正常:
$collection = Mage::getModel('catalog/product')->getCollection();//my coustom collection
$categorys_ids = array(1,2,3,4,5);//Array of ids etc
if ($categorys_ids != NULL && $collection->getData()!= NULL)
{
foreach ($collection as $product)
{
$categories_pd = $product->getCategoryIds();
$product->setCategoryIds(array_merge($product->getCategoryIds(),array($categorys_ids)));
$product->save();
}
}
Run Code Online (Sandbox Code Playgroud)
现在,主要问题是,当我为产品分配设置类别ID时,需要花费大量时间.我有200个产品,这需要两分钟左右,这是很多时间.
我想知道是否有一种方法可以为产品阵列分配类别,而不是将产品分配到类别或可以优化的东西,花费更少的时间.
我有一个内置于laravel 5.8的应用程序,它处于生产模式。由于该网站已上线,我不想向我们的用户显示任何错误。但是如果发生了一些错误,那么我想要日志号或任何指示在特定时间抛出什么错误的参考。
所以我想知道是否有任何方法可以向我们的用户显示“糟糕,出现问题 ref#123456”。这样他们就可以向我们发送屏幕截图或参考编号,我们可以通过检查我们的日志文件来跟踪实际发生的情况。
提前致谢。快乐编码。
我一直在使用Laravel 5.4的雄辩,我遇到了一个问题.
我有一个名为posts的数据库表,其中有一个名为的列template_ids.它以如下json_encoded格式存储值:
["1","25","48"]
Run Code Online (Sandbox Code Playgroud)
现在,我想根据ID数组对我的查询应用过滤器:
$id_access = array:3 [
0 => "1"
1 => "3"
2 => "48"
]
Run Code Online (Sandbox Code Playgroud)
我想要做的是搜索$id_access数据库列中是否存在任何值,template_ids.
我试过了:
Post::where('accessable_to',1)->whereIn('template_ids', $template_access_array)->paginate(3);
Run Code Online (Sandbox Code Playgroud)
另外,我试过:
Post::where('accessable_to',1)->whereRaw("JSON_CONTAINS(template_ids, ".$template_access.")")->paginate(3);
Run Code Online (Sandbox Code Playgroud)
已经看过这个,但它不适合我.