jeudi 30 avril 2020

how to make two If condition in laravel

Two conditions I want to apply for a button that will show the application when applied and if the user has a login then the button will show and ask to login.

Blade

            @if (Auth::check())
            @if ($tuitionJob->checkApply())

            <form action="" method="POST">
              @csrf
                <input type="hidden" value="" name="tuitionid">
                <button type="submit" class="btn btn-primary login-apply-btn my-2 text-light pull-right">
                  Apply <i class="fa fa-send"></i>
                </button>
              </form>
                @else
              <a href="/login" class="btn btn-primary login-apply-btn my-2 text-light pull-right">
                <i class="fa fa-send"></i>
                Login For Apply
              </a>
            @else
              <a href="tuition/job" class="btn btn-primary login-apply-btn my-2 text-light pull-right">
                <i class="fa fa-send"></i>
                 Applied
              </a>

            @endif
            @endif

Model

public function checkApply(){
  return \DB::table('tuition_applies')->where('users_id', auth()->user()->id)
  ->where('tuition_post_id', $this->id)->exists();
}

Aucun commentaire:

Enregistrer un commentaire