第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Laravel 通知 - 嘗試從控制器傳遞數(shù)據(jù)

Laravel 通知 - 嘗試從控制器傳遞數(shù)據(jù)

PHP
海綿寶寶撒 2023-04-15 16:34:37
在HomeController.php我發(fā)送這樣的通知$user->notify(new OutdatedAELocation($conSite));然后在OutdatedAELocation.php我嘗試使用此數(shù)據(jù)將通知存儲(chǔ)到數(shù)據(jù)庫(kù)中。<?phpnamespace App\Notifications;use Illuminate\Bus\Queueable;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Notifications\Messages\MailMessage;use Illuminate\Notifications\Notification;class OutdatedAELocation extends Notification implements ShouldQueue{    use Queueable;    /**     * Create a new notification instance.     *     * @return void     */    public function __construct($conSite)    {        $this->CSid = $conSite->id;        $this->outdatedAes = $conSite->outdatedAes;        $this->link = $conSite->link;    }    /**     * Get the notification's delivery channels.     *     * @param  mixed  $notifiable     * @return array     */    public function via($notifiable)    {        return ['database'];    }    /**     * Get the array representation of the notification.     *     * @param  mixed  $notifiable     * @return array     */    public function toArray($notifiable)    {           // dd($this);        return [            'conSite_id' => $this->CSid,            'outdatedAes' => $this->outdatedAes,            'link' => $this->link,        ];    }}由于某種原因,數(shù)據(jù)不會(huì)傳給toArray方法。當(dāng)我dd($this)在 __construct() 方法末尾調(diào)用時(shí),它就在那里:App\Notifications\OutdatedAELocation {#1329 ▼  +id: null  +locale: null  +connection: null  +queue: null  +chainConnection: null  +chainQueue: null  +delay: null  +middleware: []  +chained: []  +"CSid": 1  +"outdatedAes": "info, "  +"link": "https://app.com/query?location=1"}但是,當(dāng)我dd($this)在方法的第一行調(diào)用時(shí)toArray(),是這樣的:App\Notifications\OutdatedAELocation {#1780 ▼  +id: "ac659b25-7ff2-4500-adc8-72e6508d50c6"  +locale: null  +connection: null  +queue: null  +chainConnection: null  +chainQueue: null  +delay: null  +middleware: []  +chained: []}請(qǐng)問(wèn),如何傳遞數(shù)據(jù)?
查看完整描述

1 回答

?
吃雞游戲

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊

首先你必須定義類中的成員:


<?php


class OutdatedAELocation extends Notification implements ShouldQueue

{

    use Queueable;


    // HERE you define the members

    var $CSid;

    var $outdatedAes;

    var $link;


    // ...

}

之后dd($conSite);在構(gòu)造函數(shù)的開(kāi)頭嘗試查看是否將完整對(duì)象傳遞給類。


查看完整回答
反對(duì) 回復(fù) 2023-04-15
  • 1 回答
  • 0 關(guān)注
  • 108 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)