diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 8996ae64a..086929558 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -40,7 +40,7 @@ class BookController extends Controller $recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('book', 4, 0) : false; $popular = $this->entityRepo->getPopular('book', 4, 0); $this->setPageTitle('Books'); - return view('books/index', ['books' => $books, 'recents' => $recents, 'popular' => $popular]); + return view('books/index', ['books' => $books, 'recents' => $recents, 'popular' => $popular, 'display' => $display]); //added displaly to access user display } /** @@ -67,7 +67,14 @@ class BookController extends Controller 'name' => 'required|string|max:255', 'description' => 'string|max:1000' ]); + $image = $request->file('image'); + $input = time().'-'.$image->getClientOriginalName(); + $destinationPath = public_path('uploads/book/'); + $image->move($destinationPath, $input); + $path = baseUrl('/uploads/book/').'/'.$input; $book = $this->entityRepo->createFromInput('book', $request->all()); + $book->image = $path; + $book->save(); Activity::add($book, 'book_create', $book->id); return redirect($book->getUrl()); } @@ -114,9 +121,17 @@ class BookController extends Controller 'name' => 'required|string|max:255', 'description' => 'string|max:1000' ]); - $book = $this->entityRepo->updateFromInput('book', $book, $request->all()); - Activity::add($book, 'book_update', $book->id); - return redirect($book->getUrl()); + + $input = $request->file('image')->getClientOriginalName(); + echo $input; + $destinationPath = public_path('uploads/book/'); + $request->file('image')->move($destinationPath, $input); + $path = baseUrl('/uploads/book/').'/'.$input; + $book = $this->entityRepo->updateFromInput('book', $book, $request->all()); + $book->image = $path; + $book->save(); + Activity::add($book, 'book_update', $book->id); + return redirect($book->getUrl()); } /** diff --git a/app/User.php b/app/User.php index 8033557e4..3d77cd8ee 100644 --- a/app/User.php +++ b/app/User.php @@ -22,7 +22,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon * The attributes that are mass assignable. * @var array */ - protected $fillable = ['name', 'email', 'image_id']; + protected $fillable = ['name', 'email', 'image_id', 'display']; //to write in user database /** * The attributes excluded from the model's JSON form. diff --git a/resources/lang/en/common.php b/resources/lang/en/common.php index e1d74c95e..dae6d0509 100644 --- a/resources/lang/en/common.php +++ b/resources/lang/en/common.php @@ -44,6 +44,7 @@ return [ 'no_items' => 'No items available', 'back_to_top' => 'Back to top', 'toggle_details' => 'Toggle Details', + 'toggle_thumbnails' => 'Toggle Thumbnails', /** * Header diff --git a/resources/views/books/create.blade.php b/resources/views/books/create.blade.php index 2c629e699..36c94af62 100644 --- a/resources/views/books/create.blade.php +++ b/resources/views/books/create.blade.php @@ -4,7 +4,7 @@
{!! $book->searchSnippet !!}
+ @else +{{ $book->getExcerpt() }}
+ @endif +