2017-04-22 3 views
0

FatalThrowableError未定義の方法はstdClassにMyController コール::通知()コール::通知()

laravel通知()未定義の方法です。

namespace App\Http\Controllers; 
use Illuminate\Http\Request; 
use DB; 
use Mail; 
use Apps\User; 
use App\Notifications\InvoicePaid; 

class BlogController extends Controller 
{ 
    public function EmailNotify(){ 
    $user = DB::table('users')->where('id',2)->first(); 
    $urlData = DB::table('url')->where('id',2)->first(); 

    $user->notify(new InvoicePaid($urlData)); 

} 
} 

アプリ/通知/ InvoicePaid.php

namespace App\Notifications; 

use Illuminate\Bus\Queueable; 
use Illuminate\Notifications\Notification; 
use Illuminate\Contracts\Queue\ShouldQueue; 
use Illuminate\Notifications\Messages\MailMessage; 

class InvoicePaid extends Notification 
{ 
use Queueable; 
protected $toto; 

public function __construct($toturial) 
{ 
    $this->toto=$toturial; 
} 

public function via($notifiable) 
{ 
    return ['mail']; 
} 
public function toMail($notifiable) 
{ 
    return (new MailMessage) 
       ->line('The introduction to the notification.') 
       ->action('Notification Action', url('/')) 
       ->line('Thank you for using our application!'); 
    } 

} 
+0

これはどの言語のタグを追加しますか – FCin

答えて

1

あなたが追加する必要がnotifyメソッドを使用するには..私を助け....

コントローラファイルを、それを解決する方法クラスへのNotifiableの特性。

class User extends Authenticatable { 
    use \Illuminate\Notifications\Notifiable; 

    //... 
} 

あなたがNotificationファサードを使用することができますNotifiable形質を使用しない場合。

Notification::send($users, new InvoicePaid($invoice)); 

詳細はhereです。ララキャストにもビデオがあります。 Watch it here

関連する問題