mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Added created_by and updated_by to entities. Fixes #3
This commit is contained in:
parent
fc50a1400d
commit
52033f3a6f
10
app/Book.php
10
app/Book.php
@ -29,6 +29,16 @@ class Book extends Model
|
|||||||
return $this->hasMany('Oxbow\Chapter');
|
return $this->hasMany('Oxbow\Chapter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createdBy()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('Oxbow\User', 'created_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedBy()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('Oxbow\User', 'updated_by');
|
||||||
|
}
|
||||||
|
|
||||||
public function children()
|
public function children()
|
||||||
{
|
{
|
||||||
$pages = $this->pages()->where('chapter_id', '=', 0)->get();
|
$pages = $this->pages()->where('chapter_id', '=', 0)->get();
|
||||||
|
@ -17,6 +17,16 @@ class Chapter extends Model
|
|||||||
return $this->hasMany('Oxbow\Page')->orderBy('priority', 'ASC');
|
return $this->hasMany('Oxbow\Page')->orderBy('priority', 'ASC');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createdBy()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('Oxbow\User', 'created_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedBy()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('Oxbow\User', 'updated_by');
|
||||||
|
}
|
||||||
|
|
||||||
public function getUrl()
|
public function getUrl()
|
||||||
{
|
{
|
||||||
return '/books/' . $this->book->slug . '/chapter/' . $this->slug;
|
return '/books/' . $this->book->slug . '/chapter/' . $this->slug;
|
||||||
|
@ -4,6 +4,7 @@ namespace Oxbow\Http\Controllers;
|
|||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Oxbow\Http\Requests;
|
use Oxbow\Http\Requests;
|
||||||
use Oxbow\Repos\BookRepo;
|
use Oxbow\Repos\BookRepo;
|
||||||
@ -65,6 +66,8 @@ class BookController extends Controller
|
|||||||
$slug .= '1';
|
$slug .= '1';
|
||||||
}
|
}
|
||||||
$book->slug = $slug;
|
$book->slug = $slug;
|
||||||
|
$book->created_by = Auth::user()->id;
|
||||||
|
$book->updated_by = Auth::user()->id;
|
||||||
$book->save();
|
$book->save();
|
||||||
return redirect('/books');
|
return redirect('/books');
|
||||||
}
|
}
|
||||||
@ -113,6 +116,7 @@ class BookController extends Controller
|
|||||||
$slug += '1';
|
$slug += '1';
|
||||||
}
|
}
|
||||||
$book->slug = $slug;
|
$book->slug = $slug;
|
||||||
|
$book->updated_by = Auth::user()->id;
|
||||||
$book->save();
|
$book->save();
|
||||||
return redirect($book->getUrl());
|
return redirect($book->getUrl());
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace Oxbow\Http\Controllers;
|
|||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Oxbow\Http\Requests;
|
use Oxbow\Http\Requests;
|
||||||
use Oxbow\Http\Controllers\Controller;
|
use Oxbow\Http\Controllers\Controller;
|
||||||
use Oxbow\Repos\BookRepo;
|
use Oxbow\Repos\BookRepo;
|
||||||
@ -56,6 +57,8 @@ class ChapterController extends Controller
|
|||||||
$chapter = $this->chapterRepo->newFromInput($request->all());
|
$chapter = $this->chapterRepo->newFromInput($request->all());
|
||||||
$chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id);
|
$chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id);
|
||||||
$chapter->priority = $this->bookRepo->getNewPriority($book);
|
$chapter->priority = $this->bookRepo->getNewPriority($book);
|
||||||
|
$chapter->created_by = Auth::user()->id;
|
||||||
|
$chapter->updated_by = Auth::user()->id;
|
||||||
$book->chapters()->save($chapter);
|
$book->chapters()->save($chapter);
|
||||||
return redirect($book->getUrl());
|
return redirect($book->getUrl());
|
||||||
}
|
}
|
||||||
@ -102,6 +105,7 @@ class ChapterController extends Controller
|
|||||||
$chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
|
$chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
|
||||||
$chapter->fill($request->all());
|
$chapter->fill($request->all());
|
||||||
$chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id, $chapter->id);
|
$chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id, $chapter->id);
|
||||||
|
$chapter->updated_by = Auth::user()->id;
|
||||||
$chapter->save();
|
$chapter->save();
|
||||||
return redirect($chapter->getUrl());
|
return redirect($chapter->getUrl());
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace Oxbow\Http\Controllers;
|
|||||||
use Illuminate\Filesystem\Filesystem as File;
|
use Illuminate\Filesystem\Filesystem as File;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Intervention\Image\Facades\Image as ImageTool;
|
use Intervention\Image\Facades\Image as ImageTool;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Oxbow\Http\Requests;
|
use Oxbow\Http\Requests;
|
||||||
@ -126,6 +127,8 @@ class ImageController extends Controller
|
|||||||
// Create and save image object
|
// Create and save image object
|
||||||
$this->image->name = $name;
|
$this->image->name = $name;
|
||||||
$this->image->url = $imagePath . $name;
|
$this->image->url = $imagePath . $name;
|
||||||
|
$this->image->created_by = Auth::user()->id;
|
||||||
|
$this->image->updated_by = Auth::user()->id;
|
||||||
$this->image->save();
|
$this->image->save();
|
||||||
return response()->json($this->image);
|
return response()->json($this->image);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace Oxbow\Http\Controllers;
|
|||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Oxbow\Http\Requests;
|
use Oxbow\Http\Requests;
|
||||||
use Oxbow\Repos\BookRepo;
|
use Oxbow\Repos\BookRepo;
|
||||||
@ -82,6 +83,8 @@ class PageController extends Controller
|
|||||||
|
|
||||||
$page->book_id = $book->id;
|
$page->book_id = $book->id;
|
||||||
$page->text = strip_tags($page->html);
|
$page->text = strip_tags($page->html);
|
||||||
|
$page->created_by = Auth::user()->id;
|
||||||
|
$page->updated_by = Auth::user()->id;
|
||||||
$page->save();
|
$page->save();
|
||||||
return redirect($page->getUrl());
|
return redirect($page->getUrl());
|
||||||
}
|
}
|
||||||
@ -130,6 +133,7 @@ class PageController extends Controller
|
|||||||
$page->fill($request->all());
|
$page->fill($request->all());
|
||||||
$page->slug = $this->pageRepo->findSuitableSlug($page->name, $book->id, $page->id);
|
$page->slug = $this->pageRepo->findSuitableSlug($page->name, $book->id, $page->id);
|
||||||
$page->text = strip_tags($page->html);
|
$page->text = strip_tags($page->html);
|
||||||
|
$page->updated_by = Auth::user()->id;
|
||||||
$page->save();
|
$page->save();
|
||||||
return redirect($page->getUrl());
|
return redirect($page->getUrl());
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,14 @@ class Image extends Model
|
|||||||
{
|
{
|
||||||
return storage_path() . $this->url;
|
return storage_path() . $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createdBy()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('Oxbow\User', 'created_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedBy()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('Oxbow\User', 'updated_by');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,14 @@ class Page extends Model
|
|||||||
return $this->chapter()->count() > 0;
|
return $this->chapter()->count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parent()
|
public function createdBy()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('Oxbow\Page', 'page_id');
|
return $this->belongsTo('Oxbow\User', 'created_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedBy()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('Oxbow\User', 'updated_by');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUrl()
|
public function getUrl()
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddUsersToEntities extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('pages', function (Blueprint $table) {
|
||||||
|
$table->integer('created_by');
|
||||||
|
$table->integer('updated_by');
|
||||||
|
});
|
||||||
|
Schema::table('chapters', function (Blueprint $table) {
|
||||||
|
$table->integer('created_by');
|
||||||
|
$table->integer('updated_by');
|
||||||
|
});
|
||||||
|
Schema::table('images', function (Blueprint $table) {
|
||||||
|
$table->integer('created_by');
|
||||||
|
$table->integer('updated_by');
|
||||||
|
});
|
||||||
|
Schema::table('books', function (Blueprint $table) {
|
||||||
|
$table->integer('created_by');
|
||||||
|
$table->integer('updated_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('pages', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('created_by');
|
||||||
|
$table->dropColumn('updated_by');
|
||||||
|
});
|
||||||
|
Schema::table('chapters', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('created_by');
|
||||||
|
$table->dropColumn('updated_by');
|
||||||
|
});
|
||||||
|
Schema::table('images', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('created_by');
|
||||||
|
$table->dropColumn('updated_by');
|
||||||
|
});
|
||||||
|
Schema::table('books', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('created_by');
|
||||||
|
$table->dropColumn('updated_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -169,6 +169,9 @@ p.neg, p .neg, span.neg, .text-neg {
|
|||||||
|
|
||||||
p.muted, p .muted, span.muted, .text-muted {
|
p.muted, p .muted, span.muted, .text-muted {
|
||||||
color: lighten($text-dark, 26%);
|
color: lighten($text-dark, 26%);
|
||||||
|
&.small, .small {
|
||||||
|
color: lighten($text-dark, 42%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p.primary, p .primary, span.primary, .text-primary {
|
p.primary, p .primary, span.primary, .text-primary {
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
{{$childElement->getExcerpt()}}
|
{{$childElement->getExcerpt()}}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@if(is_a($childElement, 'Oxbow\Chapter'))
|
@if(is_a($childElement, 'Oxbow\Chapter') && count($childElement->pages) > 0)
|
||||||
<div class="inset-list">
|
<div class="inset-list">
|
||||||
@foreach($childElement->pages as $page)
|
@foreach($childElement->pages as $page)
|
||||||
<h4><a href="{{$page->getUrl()}}"><i class="zmdi zmdi-file-text"></i> {{$page->name}}</a></h4>
|
<h4><a href="{{$page->getUrl()}}"><i class="zmdi zmdi-file-text"></i> {{$page->name}}</a></h4>
|
||||||
@ -49,6 +49,12 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p class="text-muted small">
|
||||||
|
Created {{$book->created_at->diffForHumans()}} @if($book->createdBy) by {{$book->createdBy->name}} @endif
|
||||||
|
<br>
|
||||||
|
Last Updated {{$book->updated_at->diffForHumans()}} @if($book->createdBy) by {{$book->updatedBy->name}} @endif
|
||||||
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +42,12 @@
|
|||||||
@else
|
@else
|
||||||
<p class="text-muted">No pages are in this chapter</p>
|
<p class="text-muted">No pages are in this chapter</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
<p class="text-muted small">
|
||||||
|
Created {{$chapter->created_at->diffForHumans()}} @if($chapter->createdBy) by {{$chapter->createdBy->name}} @endif
|
||||||
|
<br>
|
||||||
|
Last Updated {{$chapter->updated_at->diffForHumans()}} @if($chapter->createdBy) by {{$chapter->updatedBy->name}} @endif
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,6 +41,13 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
{!! $page->html !!}
|
{!! $page->html !!}
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<p class="text-muted small">
|
||||||
|
Created {{$page->created_at->diffForHumans()}} @if($page->createdBy) by {{$page->createdBy->name}} @endif
|
||||||
|
<br>
|
||||||
|
Last Updated {{$page->updated_at->diffForHumans()}} @if($page->createdBy) by {{$page->updatedBy->name}} @endif
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user