Showing
13 changed files
with
132 additions
and
3 deletions
| ... | @@ -29,6 +29,16 @@ class Book extends Model | ... | @@ -29,6 +29,16 @@ class Book extends Model |
| 29 | return $this->hasMany('Oxbow\Chapter'); | 29 | return $this->hasMany('Oxbow\Chapter'); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | + public function createdBy() | ||
| 33 | + { | ||
| 34 | + return $this->belongsTo('Oxbow\User', 'created_by'); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public function updatedBy() | ||
| 38 | + { | ||
| 39 | + return $this->belongsTo('Oxbow\User', 'updated_by'); | ||
| 40 | + } | ||
| 41 | + | ||
| 32 | public function children() | 42 | public function children() |
| 33 | { | 43 | { |
| 34 | $pages = $this->pages()->where('chapter_id', '=', 0)->get(); | 44 | $pages = $this->pages()->where('chapter_id', '=', 0)->get(); | ... | ... |
| ... | @@ -17,6 +17,16 @@ class Chapter extends Model | ... | @@ -17,6 +17,16 @@ class Chapter extends Model |
| 17 | return $this->hasMany('Oxbow\Page')->orderBy('priority', 'ASC'); | 17 | return $this->hasMany('Oxbow\Page')->orderBy('priority', 'ASC'); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | + public function createdBy() | ||
| 21 | + { | ||
| 22 | + return $this->belongsTo('Oxbow\User', 'created_by'); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public function updatedBy() | ||
| 26 | + { | ||
| 27 | + return $this->belongsTo('Oxbow\User', 'updated_by'); | ||
| 28 | + } | ||
| 29 | + | ||
| 20 | public function getUrl() | 30 | public function getUrl() |
| 21 | { | 31 | { |
| 22 | return '/books/' . $this->book->slug . '/chapter/' . $this->slug; | 32 | return '/books/' . $this->book->slug . '/chapter/' . $this->slug; | ... | ... |
| ... | @@ -4,6 +4,7 @@ namespace Oxbow\Http\Controllers; | ... | @@ -4,6 +4,7 @@ namespace Oxbow\Http\Controllers; |
| 4 | 4 | ||
| 5 | use Illuminate\Http\Request; | 5 | use Illuminate\Http\Request; |
| 6 | 6 | ||
| 7 | +use Illuminate\Support\Facades\Auth; | ||
| 7 | use Illuminate\Support\Str; | 8 | use Illuminate\Support\Str; |
| 8 | use Oxbow\Http\Requests; | 9 | use Oxbow\Http\Requests; |
| 9 | use Oxbow\Repos\BookRepo; | 10 | use Oxbow\Repos\BookRepo; |
| ... | @@ -65,6 +66,8 @@ class BookController extends Controller | ... | @@ -65,6 +66,8 @@ class BookController extends Controller |
| 65 | $slug .= '1'; | 66 | $slug .= '1'; |
| 66 | } | 67 | } |
| 67 | $book->slug = $slug; | 68 | $book->slug = $slug; |
| 69 | + $book->created_by = Auth::user()->id; | ||
| 70 | + $book->updated_by = Auth::user()->id; | ||
| 68 | $book->save(); | 71 | $book->save(); |
| 69 | return redirect('/books'); | 72 | return redirect('/books'); |
| 70 | } | 73 | } |
| ... | @@ -113,6 +116,7 @@ class BookController extends Controller | ... | @@ -113,6 +116,7 @@ class BookController extends Controller |
| 113 | $slug += '1'; | 116 | $slug += '1'; |
| 114 | } | 117 | } |
| 115 | $book->slug = $slug; | 118 | $book->slug = $slug; |
| 119 | + $book->updated_by = Auth::user()->id; | ||
| 116 | $book->save(); | 120 | $book->save(); |
| 117 | return redirect($book->getUrl()); | 121 | return redirect($book->getUrl()); |
| 118 | } | 122 | } | ... | ... |
| ... | @@ -4,6 +4,7 @@ namespace Oxbow\Http\Controllers; | ... | @@ -4,6 +4,7 @@ namespace Oxbow\Http\Controllers; |
| 4 | 4 | ||
| 5 | use Illuminate\Http\Request; | 5 | use Illuminate\Http\Request; |
| 6 | 6 | ||
| 7 | +use Illuminate\Support\Facades\Auth; | ||
| 7 | use Oxbow\Http\Requests; | 8 | use Oxbow\Http\Requests; |
| 8 | use Oxbow\Http\Controllers\Controller; | 9 | use Oxbow\Http\Controllers\Controller; |
| 9 | use Oxbow\Repos\BookRepo; | 10 | use Oxbow\Repos\BookRepo; |
| ... | @@ -56,6 +57,8 @@ class ChapterController extends Controller | ... | @@ -56,6 +57,8 @@ class ChapterController extends Controller |
| 56 | $chapter = $this->chapterRepo->newFromInput($request->all()); | 57 | $chapter = $this->chapterRepo->newFromInput($request->all()); |
| 57 | $chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id); | 58 | $chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id); |
| 58 | $chapter->priority = $this->bookRepo->getNewPriority($book); | 59 | $chapter->priority = $this->bookRepo->getNewPriority($book); |
| 60 | + $chapter->created_by = Auth::user()->id; | ||
| 61 | + $chapter->updated_by = Auth::user()->id; | ||
| 59 | $book->chapters()->save($chapter); | 62 | $book->chapters()->save($chapter); |
| 60 | return redirect($book->getUrl()); | 63 | return redirect($book->getUrl()); |
| 61 | } | 64 | } |
| ... | @@ -102,6 +105,7 @@ class ChapterController extends Controller | ... | @@ -102,6 +105,7 @@ class ChapterController extends Controller |
| 102 | $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id); | 105 | $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id); |
| 103 | $chapter->fill($request->all()); | 106 | $chapter->fill($request->all()); |
| 104 | $chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id, $chapter->id); | 107 | $chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id, $chapter->id); |
| 108 | + $chapter->updated_by = Auth::user()->id; | ||
| 105 | $chapter->save(); | 109 | $chapter->save(); |
| 106 | return redirect($chapter->getUrl()); | 110 | return redirect($chapter->getUrl()); |
| 107 | } | 111 | } | ... | ... |
| ... | @@ -5,6 +5,7 @@ namespace Oxbow\Http\Controllers; | ... | @@ -5,6 +5,7 @@ namespace Oxbow\Http\Controllers; |
| 5 | use Illuminate\Filesystem\Filesystem as File; | 5 | use Illuminate\Filesystem\Filesystem as File; |
| 6 | use Illuminate\Http\Request; | 6 | use Illuminate\Http\Request; |
| 7 | 7 | ||
| 8 | +use Illuminate\Support\Facades\Auth; | ||
| 8 | use Intervention\Image\Facades\Image as ImageTool; | 9 | use Intervention\Image\Facades\Image as ImageTool; |
| 9 | use Illuminate\Support\Facades\DB; | 10 | use Illuminate\Support\Facades\DB; |
| 10 | use Oxbow\Http\Requests; | 11 | use Oxbow\Http\Requests; |
| ... | @@ -126,6 +127,8 @@ class ImageController extends Controller | ... | @@ -126,6 +127,8 @@ class ImageController extends Controller |
| 126 | // Create and save image object | 127 | // Create and save image object |
| 127 | $this->image->name = $name; | 128 | $this->image->name = $name; |
| 128 | $this->image->url = $imagePath . $name; | 129 | $this->image->url = $imagePath . $name; |
| 130 | + $this->image->created_by = Auth::user()->id; | ||
| 131 | + $this->image->updated_by = Auth::user()->id; | ||
| 129 | $this->image->save(); | 132 | $this->image->save(); |
| 130 | return response()->json($this->image); | 133 | return response()->json($this->image); |
| 131 | } | 134 | } | ... | ... |
| ... | @@ -4,6 +4,7 @@ namespace Oxbow\Http\Controllers; | ... | @@ -4,6 +4,7 @@ namespace Oxbow\Http\Controllers; |
| 4 | 4 | ||
| 5 | use Illuminate\Http\Request; | 5 | use Illuminate\Http\Request; |
| 6 | 6 | ||
| 7 | +use Illuminate\Support\Facades\Auth; | ||
| 7 | use Illuminate\Support\Str; | 8 | use Illuminate\Support\Str; |
| 8 | use Oxbow\Http\Requests; | 9 | use Oxbow\Http\Requests; |
| 9 | use Oxbow\Repos\BookRepo; | 10 | use Oxbow\Repos\BookRepo; |
| ... | @@ -82,6 +83,8 @@ class PageController extends Controller | ... | @@ -82,6 +83,8 @@ class PageController extends Controller |
| 82 | 83 | ||
| 83 | $page->book_id = $book->id; | 84 | $page->book_id = $book->id; |
| 84 | $page->text = strip_tags($page->html); | 85 | $page->text = strip_tags($page->html); |
| 86 | + $page->created_by = Auth::user()->id; | ||
| 87 | + $page->updated_by = Auth::user()->id; | ||
| 85 | $page->save(); | 88 | $page->save(); |
| 86 | return redirect($page->getUrl()); | 89 | return redirect($page->getUrl()); |
| 87 | } | 90 | } |
| ... | @@ -130,6 +133,7 @@ class PageController extends Controller | ... | @@ -130,6 +133,7 @@ class PageController extends Controller |
| 130 | $page->fill($request->all()); | 133 | $page->fill($request->all()); |
| 131 | $page->slug = $this->pageRepo->findSuitableSlug($page->name, $book->id, $page->id); | 134 | $page->slug = $this->pageRepo->findSuitableSlug($page->name, $book->id, $page->id); |
| 132 | $page->text = strip_tags($page->html); | 135 | $page->text = strip_tags($page->html); |
| 136 | + $page->updated_by = Auth::user()->id; | ||
| 133 | $page->save(); | 137 | $page->save(); |
| 134 | return redirect($page->getUrl()); | 138 | return redirect($page->getUrl()); |
| 135 | } | 139 | } | ... | ... |
| ... | @@ -10,4 +10,14 @@ class Image extends Model | ... | @@ -10,4 +10,14 @@ class Image extends Model |
| 10 | { | 10 | { |
| 11 | return storage_path() . $this->url; | 11 | return storage_path() . $this->url; |
| 12 | } | 12 | } |
| 13 | + | ||
| 14 | + public function createdBy() | ||
| 15 | + { | ||
| 16 | + return $this->belongsTo('Oxbow\User', 'created_by'); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public function updatedBy() | ||
| 20 | + { | ||
| 21 | + return $this->belongsTo('Oxbow\User', 'updated_by'); | ||
| 22 | + } | ||
| 13 | } | 23 | } | ... | ... |
| ... | @@ -32,9 +32,14 @@ class Page extends Model | ... | @@ -32,9 +32,14 @@ class Page extends Model |
| 32 | return $this->chapter()->count() > 0; | 32 | return $this->chapter()->count() > 0; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | - public function parent() | 35 | + public function createdBy() |
| 36 | { | 36 | { |
| 37 | - return $this->belongsTo('Oxbow\Page', 'page_id'); | 37 | + return $this->belongsTo('Oxbow\User', 'created_by'); |
| 38 | + } | ||
| 39 | + | ||
| 40 | + public function updatedBy() | ||
| 41 | + { | ||
| 42 | + return $this->belongsTo('Oxbow\User', 'updated_by'); | ||
| 38 | } | 43 | } |
| 39 | 44 | ||
| 40 | public function getUrl() | 45 | public function getUrl() | ... | ... |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use Illuminate\Database\Schema\Blueprint; | ||
| 4 | +use Illuminate\Database\Migrations\Migration; | ||
| 5 | + | ||
| 6 | +class AddUsersToEntities extends Migration | ||
| 7 | +{ | ||
| 8 | + /** | ||
| 9 | + * Run the migrations. | ||
| 10 | + * | ||
| 11 | + * @return void | ||
| 12 | + */ | ||
| 13 | + public function up() | ||
| 14 | + { | ||
| 15 | + Schema::table('pages', function (Blueprint $table) { | ||
| 16 | + $table->integer('created_by'); | ||
| 17 | + $table->integer('updated_by'); | ||
| 18 | + }); | ||
| 19 | + Schema::table('chapters', function (Blueprint $table) { | ||
| 20 | + $table->integer('created_by'); | ||
| 21 | + $table->integer('updated_by'); | ||
| 22 | + }); | ||
| 23 | + Schema::table('images', function (Blueprint $table) { | ||
| 24 | + $table->integer('created_by'); | ||
| 25 | + $table->integer('updated_by'); | ||
| 26 | + }); | ||
| 27 | + Schema::table('books', function (Blueprint $table) { | ||
| 28 | + $table->integer('created_by'); | ||
| 29 | + $table->integer('updated_by'); | ||
| 30 | + }); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * Reverse the migrations. | ||
| 35 | + * | ||
| 36 | + * @return void | ||
| 37 | + */ | ||
| 38 | + public function down() | ||
| 39 | + { | ||
| 40 | + Schema::table('pages', function (Blueprint $table) { | ||
| 41 | + $table->dropColumn('created_by'); | ||
| 42 | + $table->dropColumn('updated_by'); | ||
| 43 | + }); | ||
| 44 | + Schema::table('chapters', function (Blueprint $table) { | ||
| 45 | + $table->dropColumn('created_by'); | ||
| 46 | + $table->dropColumn('updated_by'); | ||
| 47 | + }); | ||
| 48 | + Schema::table('images', function (Blueprint $table) { | ||
| 49 | + $table->dropColumn('created_by'); | ||
| 50 | + $table->dropColumn('updated_by'); | ||
| 51 | + }); | ||
| 52 | + Schema::table('books', function (Blueprint $table) { | ||
| 53 | + $table->dropColumn('created_by'); | ||
| 54 | + $table->dropColumn('updated_by'); | ||
| 55 | + }); | ||
| 56 | + } | ||
| 57 | +} |
| ... | @@ -169,6 +169,9 @@ p.neg, p .neg, span.neg, .text-neg { | ... | @@ -169,6 +169,9 @@ p.neg, p .neg, span.neg, .text-neg { |
| 169 | 169 | ||
| 170 | p.muted, p .muted, span.muted, .text-muted { | 170 | p.muted, p .muted, span.muted, .text-muted { |
| 171 | color: lighten($text-dark, 26%); | 171 | color: lighten($text-dark, 26%); |
| 172 | + &.small, .small { | ||
| 173 | + color: lighten($text-dark, 42%); | ||
| 174 | + } | ||
| 172 | } | 175 | } |
| 173 | 176 | ||
| 174 | p.primary, p .primary, span.primary, .text-primary { | 177 | p.primary, p .primary, span.primary, .text-primary { | ... | ... |
| ... | @@ -37,7 +37,7 @@ | ... | @@ -37,7 +37,7 @@ |
| 37 | {{$childElement->getExcerpt()}} | 37 | {{$childElement->getExcerpt()}} |
| 38 | </p> | 38 | </p> |
| 39 | 39 | ||
| 40 | - @if(is_a($childElement, 'Oxbow\Chapter')) | 40 | + @if(is_a($childElement, 'Oxbow\Chapter') && count($childElement->pages) > 0) |
| 41 | <div class="inset-list"> | 41 | <div class="inset-list"> |
| 42 | @foreach($childElement->pages as $page) | 42 | @foreach($childElement->pages as $page) |
| 43 | <h4><a href="{{$page->getUrl()}}"><i class="zmdi zmdi-file-text"></i> {{$page->name}}</a></h4> | 43 | <h4><a href="{{$page->getUrl()}}"><i class="zmdi zmdi-file-text"></i> {{$page->name}}</a></h4> |
| ... | @@ -49,6 +49,12 @@ | ... | @@ -49,6 +49,12 @@ |
| 49 | @endforeach | 49 | @endforeach |
| 50 | </div> | 50 | </div> |
| 51 | 51 | ||
| 52 | + <p class="text-muted small"> | ||
| 53 | + Created {{$book->created_at->diffForHumans()}} @if($book->createdBy) by {{$book->createdBy->name}} @endif | ||
| 54 | + <br> | ||
| 55 | + Last Updated {{$book->updated_at->diffForHumans()}} @if($book->createdBy) by {{$book->updatedBy->name}} @endif | ||
| 56 | + </p> | ||
| 57 | + | ||
| 52 | </div> | 58 | </div> |
| 53 | 59 | ||
| 54 | 60 | ... | ... |
| ... | @@ -42,6 +42,12 @@ | ... | @@ -42,6 +42,12 @@ |
| 42 | @else | 42 | @else |
| 43 | <p class="text-muted">No pages are in this chapter</p> | 43 | <p class="text-muted">No pages are in this chapter</p> |
| 44 | @endif | 44 | @endif |
| 45 | + | ||
| 46 | + <p class="text-muted small"> | ||
| 47 | + Created {{$chapter->created_at->diffForHumans()}} @if($chapter->createdBy) by {{$chapter->createdBy->name}} @endif | ||
| 48 | + <br> | ||
| 49 | + Last Updated {{$chapter->updated_at->diffForHumans()}} @if($chapter->createdBy) by {{$chapter->updatedBy->name}} @endif | ||
| 50 | + </p> | ||
| 45 | </div> | 51 | </div> |
| 46 | 52 | ||
| 47 | 53 | ... | ... |
| ... | @@ -41,6 +41,13 @@ | ... | @@ -41,6 +41,13 @@ |
| 41 | </div> | 41 | </div> |
| 42 | @endif | 42 | @endif |
| 43 | {!! $page->html !!} | 43 | {!! $page->html !!} |
| 44 | + | ||
| 45 | + <hr> | ||
| 46 | + <p class="text-muted small"> | ||
| 47 | + Created {{$page->created_at->diffForHumans()}} @if($page->createdBy) by {{$page->createdBy->name}} @endif | ||
| 48 | + <br> | ||
| 49 | + Last Updated {{$page->updated_at->diffForHumans()}} @if($page->createdBy) by {{$page->updatedBy->name}} @endif | ||
| 50 | + </p> | ||
| 44 | </div> | 51 | </div> |
| 45 | 52 | ||
| 46 | 53 | ... | ... |
-
Please register or sign in to post a comment