1

私は Laravel 4 を使用しており、ユーザーがログインしている場合に情報を渡そうとしています。ユーザーがログインしていない場合は、他の何かをプレーンテキストで表示したい

BookController

public function showIndex() { 

    $user_information = UsersInformation::find(Auth::user()->id);

    return View::make('book.index', array('pageTitle' => 'Book your appointment',  'user_information' => $user_information));
}

$user_information 変数のすぐ上に isset() を追加しようとしましたが、このエラーメッセージが表示されました

Cannot use isset() on the result of a function call 
   (you can use "null !== func()" instead)

Index.blade.php

        @if (isset($user_information->first_name))
           <p> You already have the 1 step complete let's move on to the second step!</p>
        @else
           <p>first step. let's create a login name and let's get to know you better</p>
        @endif

アカウントにアクセスする場合は名前を入力する必要があるため、ここに名の isset を追加しました。

次のようにissetを追加しようとしました:

             if (isset(UsersInformation::find(Auth::user()->id))) {
                $user_information = UsersInformation::find(Auth::user()->id);
             }

もちろん、推奨される構文を使用してみましたが、「オブジェクト以外のプロパティを取得しようとしています」というエラーが再び発生しました

4

1 に答える 1