简体   繁体   English

Laravel。 使用Session时如何在对象中调用特定数组?

[英]Laravel. How to call specific array in object when using Session?

Please take a look first to my picture to see data structure. 请先看一下我的照片以查看数据结构。 I would like to call 'event_name' 我想叫“ event_name”

i have tried : 我努力了 :

$session->event_name;

This not working. 这行不通。 在此处输入图片说明

Your screenshot displays an array, therefore the value would be accessible like so: 屏幕截图显示了一个数组,因此可以像这样访问该值:

$session['event_name'];

But if you are using the Laravel session tools: https://laravel.com/docs/5.8/session#retrieving-data 但是,如果您使用的是Laravel会话工具: https ://laravel.com/docs/5.8/session#retrieving-data

You can do this: 你可以这样做:

$session->get('event_name');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Laravel中保存模型时出错。 “在非对象上调用成员函数getKey()” - Error when I save model in Laravel. 'Call to a member function getKey() on a non-object' Laravel。 使用WHERENOTIN - Laravel. Using WHERENOTIN 在查询中使用 JOIN 时,Laravel. Json 转换为数组的列作为字符串返回 - Laravel. Json column with cast as array are returning as a string when using JOIN in query 未定义的属性:> 在 Laravel 上使用日期类型列时出现 stdClass 错误。 我该如何解决? - Undefined property: > stdClass error when using date type column on Laravel. How can I solve it? 拉拉维尔。 如何获得外键是数组的关系 - Laravel. How to get relationships where foreign key is an array 如何将数组存储到会话中并在Laravel中调用它? - How to store an array into a session and call it in Laravel? Laravel本地化。 这个怎么运作? - Localization with Laravel. How it works? 我需要在laravel中返回更改。 数组{}到[]的对象(尝试与'[object Object]进行比较时出错) - I need change return in laravel. object to array {} to [] (Error trying to diff '[object Object]) 此查询替换为 Laravel。 在laravel中怎么写? - This query replace to Laravel. How to write in laravel? Laravel。 toArray()转换后,无法将StdClass类型的对象用作数组 - Laravel. Cannot use object of type StdClass as array after toArray() convert
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM