$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
}
/**
'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());
}
'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());
}
/**
* 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.
'no_items' => 'No items available',
'back_to_top' => 'Back to top',
'toggle_details' => 'Toggle Details',
+ 'toggle_thumbnails' => 'Toggle Thumbnails',
/**
* Header
<div class="container small" ng-non-bindable>
<h1>{{ trans('entities.books_create') }}</h1>
- <form action="{{ baseUrl("/books") }}" method="POST">
+ <form action="{{ baseUrl("/books") }}" method="POST" enctype="multipart/form-data">
@include('books/form')
</form>
</div>
<div class="container small" ng-non-bindable>
<h1>{{ trans('entities.books_edit') }}</h1>
- <form action="{{ $book->getUrl() }}" method="POST">
+ <form action="{{ $book->getUrl() }}" method="POST" enctype="multipart/form-data">
<input type="hidden" name="_method" value="PUT">
@include('books/form', ['model' => $book])
</form>
@include('form/textarea', ['name' => 'description'])
</div>
+<div class="form-group">
+ <label for="image">Choose image</label>
+ <input type="file" name="image">
+</div>
<div class="form-group">
<a href="{{ isset($book) ? $book->getUrl() : baseUrl('/books') }}" class="button muted">{{ trans('common.cancel') }}</a>
<button type="submit" class="button pos">{{ trans('entities.books_save') }}</button>
--- /dev/null
+<div class="galleryContainer" data-entity-type="book" data-entity-id="{{$book->id}}">
+<div class="col-sm-3 galleryItem">
+ <h3>
+ <a class="text-book entity-list-item-link" href="{{$book->getUrl()}}"><i class="zmdi zmdi-book"></i><span class="entity-list-item-name">{{$book->name}}</span>
+ <br>
+ <img @if($book->image === NULL) src="{{baseUrl('/default.jpg')}}" @else src="{{$book->image}}" @endif alt="{{$book->name}}">
+ </a>
+ </h3>
+ @if(isset($book->searchSnippet))
+ <p class="text-muted">{!! $book->searchSnippet !!}</p>
+ @else
+ <p class="text-muted">{{ $book->getExcerpt() }}</p>
+ @endif
+ </div>
+</div>
\ No newline at end of file
<div class="faded-small toolbar">
<div class="container">
<div class="row">
- <div class="col-xs-1"></div>
<div class="col-xs-11 faded">
- <div class="action-buttons">
+ <div class="action-buttons text-left">
@if($currentUser->can('book-create-all'))
<a href="{{ baseUrl("/books/create") }}" class="text-pos text-button"><i class="zmdi zmdi-plus"></i>{{ trans('entities.books_create') }}</a>
@endif
+ <a data-action="expand-thumbnail" class="text-primary text-button"><i class="zmdi zmdi-wrap-text"></i>{{ trans('common.toggle_thumbnails') }}</a>
</div>
</div>
</div>
<div class="container" ng-non-bindable>
<div class="row">
- <div class="col-sm-7">
+ <div class="col-sm-9">
<h1>{{ trans('entities.books') }}</h1>
+ {!! $books->render() !!}
@if(count($books) > 0)
+ @if($display=='grid')
+ @foreach($books as $book)
+ @include('books/grid-item', ['book' => $book])
+ @endforeach
+ @else
@foreach($books as $book)
- @include('books/list-item', ['book' => $book])
- <hr>
- @endforeach
- {!! $books->render() !!}
+ @include('books/list-item', ['book' => $book])
+ @endforeach
+ @endif
@else
<p class="text-muted">{{ trans('entities.books_empty') }}</p>
@if(userCan('books-create-all'))
@endif
@endif
</div>
- <div class="col-sm-4 col-sm-offset-1">
+ <div class="col-sm-3">
<div id="recents">
@if($recents)
<div class="margin-top"> </div>
@endif
</div>
</div>
+ {!! $books->render() !!}
</div>
</div>
@endforeach
</select>
</div>
+ <!--Select display type -->
+ <div class="form-group">
+ <label for="display">Type of view</label>
+ <select name="display" id="display">
+ <option @if($user->display === 'grid') selected @endif value="grid">Grid</option>
+ <option @if($user->display === 'list') selected @endif value="list">List</option>
+ </select>
+ </div>
+ <!---->
</div>
</div>
<div class="form-group">