Exemple #1
0
 /**
  * Check main author book.
  * @param  [type] $authorId [description]
  * @param  [type] $bookId   [description]
  * @return [type]           [description]
  */
 public static function checkAuthorAndMain($authorId, $bookId)
 {
     $check = BookAuthor::where('book_id', $bookId)->where('author_id', $authorId)->where('is_main', 1)->first();
     if (count($check) == 0) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * Page show invitation to let people accept it.
  * @return [type] [description]
  */
 public function invitation()
 {
     $authorId = Auth::user()->id;
     $bookbundles = $this->bookbundle->all();
     $bundlesRes = array();
     foreach ($bookbundles as $key => $value) {
         if (BookAuthor::checkAuthorAndMain($authorId, $value->bundle_id)) {
             array_push($bundlesRes, $value);
         }
     }
     return view('frontend.invitation', compact('bundles_res'));
 }
Exemple #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBookAuthors()
 {
     return $this->hasMany(BookAuthor::className(), ['author_id' => 'id']);
 }