title: laravel query with a model function
body: <p>I have this function in my model:</p>
  
  <pre><code> public function isFull(){
          $maxMembers=$this-&gt;course-&gt;type-&gt;max_members;
          $countActualMembers=LessonLicenseMember::where('lesson_id',$this-&gt;id)-&gt;count();
          if( $countActualMembers &lt; $maxMembers) {
              return false;
          }
          else{
              return true;
          }
      }
  </code></pre>
  
  <p>Is it possible to use it in a laravel query like this?</p>
  
  <pre><code> public function getOpenLessonsInCourses($licenseMemberId)
      {
          $lessons =Lesson::select ('lessons.id as idLesson','courses.id as id','course_type.description as description'
              ,'lessons.number as number','lessons.date_time as date_time')
              -&gt;status('aperto')
              -&gt;concluded(false)
              -&gt;join('courses','lessons.course_id','courses.id')
              -&gt;join('course_type','courses.course_type_id','course_type.id')
              -&gt;get();
          return $lessons;
      }
  </code></pre>
  
  <p>The purpose is to have the lessons that aren't full, but I don't have a field in my table. 
  I know there are scopes but I think they work only with fields in the table...</p>