Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2015-08-23 14:20:34 +0100
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
0b222c7734ad0a42770ad0320a5ca631d43dbfb9
0b222c77
1 parent
40b629d3
Fixed entity messages on delete. Fixes #21.
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
10 deletions
app/Http/Controllers/BookController.php
app/Http/Controllers/ChapterController.php
app/Http/Controllers/ImageController.php
app/Http/Controllers/PageController.php
app/Http/routes.php
app/Services/ActivityService.php
app/Http/Controllers/BookController.php
View file @
0b222c7
...
...
@@ -135,9 +135,9 @@ class BookController extends Controller
*/
public
function
destroy
(
$bookSlug
)
{
$bookName
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
)
->
name
;
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
Activity
::
addMessage
(
'book_delete'
,
0
,
$book
->
name
);
$this
->
bookRepo
->
destroyBySlug
(
$bookSlug
);
Activity
::
addMessage
(
'book_delete'
,
0
,
$bookName
);
return
redirect
(
'/books'
);
}
}
...
...
app/Http/Controllers/ChapterController.php
View file @
0b222c7
...
...
@@ -137,15 +137,15 @@ class ChapterController extends Controller
{
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$chapter
=
$this
->
chapterRepo
->
getBySlug
(
$chapterSlug
,
$book
->
id
);
$chapterName
=
$chapter
->
name
;
if
(
count
(
$chapter
->
pages
)
>
0
)
{
foreach
(
$chapter
->
pages
as
$page
)
{
$page
->
chapter_id
=
0
;
$page
->
save
();
}
}
Activity
::
removeEntity
(
$chapter
);
Activity
::
addMessage
(
'chapter_delete'
,
$book
->
id
,
$chapter
->
name
);
$chapter
->
delete
();
Activity
::
addMessage
(
'chapter_delete'
,
$book
->
id
,
$chapterName
);
return
redirect
(
$book
->
getUrl
());
}
}
...
...
app/Http/Controllers/ImageController.php
View file @
0b222c7
...
...
@@ -4,15 +4,11 @@ namespace Oxbow\Http\Controllers;
use
Illuminate\Filesystem\Filesystem
as
File
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Intervention\Image\Facades\Image
as
ImageTool
;
use
Illuminate\Support\Facades\DB
;
use
Oxbow\Http\Requests
;
use
Oxbow\Image
;
use
RecursiveDirectoryIterator
;
use
RecursiveIteratorIterator
;
use
RegexIterator
;
class
ImageController
extends
Controller
{
...
...
app/Http/Controllers/PageController.php
View file @
0b222c7
...
...
@@ -219,6 +219,7 @@ class PageController extends Controller
$book
=
$this
->
bookRepo
->
getBySlug
(
$bookSlug
);
$page
=
$this
->
pageRepo
->
getBySlug
(
$pageSlug
,
$book
->
id
);
Activity
::
addMessage
(
'page_delete'
,
$book
->
id
,
$page
->
name
);
Activity
::
removeEntity
(
$page
);
$page
->
delete
();
return
redirect
(
$book
->
getUrl
());
}
...
...
app/Http/routes.php
View file @
0b222c7
...
...
@@ -70,7 +70,6 @@ Route::group(['middleware' => 'auth'], function() {
Route
::
get
(
'/images/all'
,
'ImageController@getAll'
);
Route
::
put
(
'/images/update/{imageId}'
,
'ImageController@update'
);
Route
::
delete
(
'/images/{imageId}'
,
'ImageController@destroy'
);
Route
::
get
(
'/images/{imageId}/delete'
,
'ImageController@destroy'
);
Route
::
get
(
'/images/all/{page}'
,
'ImageController@getAll'
);
Route
::
get
(
'/images/{any}'
,
'ImageController@getImage'
)
->
where
(
'any'
,
'.*'
);
...
...
app/Services/ActivityService.php
View file @
0b222c7
...
...
@@ -21,9 +21,10 @@ class ActivityService
/**
* Add activity data to database.
* @para Entity $entity
* @para
m
Entity $entity
* @param $activityKey
* @param int $bookId
* @param bool $extra
*/
public
function
add
(
Entity
$entity
,
$activityKey
,
$bookId
=
0
,
$extra
=
false
)
{
...
...
@@ -54,6 +55,25 @@ class ActivityService
}
/**
* Removes the entity attachment from each of its activities
* and instead uses the 'extra' field with the entities name.
* Used when an entity is deleted.
* @param Entity $entity
* @return mixed
*/
public
function
removeEntity
(
Entity
$entity
)
{
$activities
=
$entity
->
activity
;
foreach
(
$activities
as
$activity
)
{
$activity
->
extra
=
$entity
->
name
;
$activity
->
entity_id
=
0
;
$activity
->
entity_type
=
null
;
$activity
->
save
();
}
return
$activities
;
}
/**
* Gets the latest activity.
* @param int $count
* @param int $page
...
...
Please
register
or
sign in
to post a comment