Пример #1
0
 /**
  * Connect collaborator to book.
  * @param  [array] $data
  * @param  [int] $book_id  [description]
  * @return [bool]           [description]
  */
 public function connectCoAuthor($data, $book_id)
 {
     $coAuthor = User::where('username', $data['username'])->first();
     if ($coAuthor != null) {
         DB::table('book_author')->insert(['author_id' => $coAuthor->id, 'book_id' => $book_id, 'is_main' => 0, 'royalty' => $data['royalty'], 'is_accepted' => 0, 'message' => $data['message']]);
         return true;
     } else {
         return false;
     }
 }