Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting Photo Album , Video Album, and News Category still leaves news, photos, and videos in db, Fix Included #38

Closed
applecrusher opened this issue Feb 12, 2015 · 2 comments

Comments

@applecrusher
Copy link

When you delete a photo album, video album, or news category the news, photos, and videos are still associated with them still exists in the database. When an album or category is deleted it is smart to keep the photos, video, and news that was once associated with it because a user may want to use it for some other album or category. But the way you retrieve the data in your news, video and photo album has a problem because you set these albums and category to null rather than casaded on delete.

The quick fix is to change in each of the "data" methods for the News, Photo, and Video Controller, the join on the album or category id to a leftJoin rather than a regular join for the two albums and the category. This will these three items to be picked up even if there is a null value associated with an album or category. However if you do this you also need to make sure when you are submitting a new item without it being a part of a category or album that it's id is either (1) set to null or (2) an error is created in the submission process.

Here is how I would rename the variables:

Admin/NewsController.php
public function data()
{
$news = News::join('language', 'language.id', '=', 'news.language_id')
->leftJoin('news_category', 'news_category.id', '=', 'news.newscategory_id')
->select(array('news.id','news.title','news_category.title as category', 'language.name', 'news.created_at'))
->orderBy('news.position', 'ASC');
..............

Admin/PhotoController.php

$photoalbum = Photo::join('language', 'language.id', '=', 'photo.language_id')
->leftJoin('photo_album', 'photo_album.id', '=', 'photo.photo_album_id')
->where('photo.photo_album_id',$condition,$albumid)
->orderBy('photo.position')
->select(array('photo.id',DB::raw($albumid . ' as albumid'), 'photo.name','photo_album.name as category','photo.album_cover','photo.slider',
'language.name as language', 'photo.created_at'));

Admin/VideoController.php

$photoalbum = Video::join('language', 'language.id', '=', 'video.language_id')
->leftJoin('video_album', 'video_album.id', '=', 'video.video_album_id')
->where('video.video_album_id',$condition,$albumid)
->orderBy('video.position')
->select(array('video.id',DB::raw($albumid . ' as albumid'), 'video.name','video_album.name as category',
'video.album_cover','language.name as language', 'video.created_at'));

P.S:
_Also you should rename the variable to videoalbum in the video controller. If you need any more help on this project please get in contact with me. I am interested in this project._

@applecrusher applecrusher changed the title Deleting Photo Album , Video Album, and News Category still leaves news, photos, and videos in db, Fix Deleting Photo Album , Video Album, and News Category still leaves news, photos, and videos in db, Fix Included Feb 12, 2015
@stojankukrika
Copy link
Collaborator

Firstable, I would like to thank you for your comment. But it's start site, so everyone can start at this point to continue developing as he/she wants, for they projects, or start from beginning.
Have a nice day.
P.S. How to contact you, I do not see you contact email in your profile. You contact me (have email on contact).

@kumarramalingam
Copy link

Hello Stojan Kukrika,

Thanks for your response.

Email : [email protected]

skype : argutech

Blogspot : argutech.blogspot.in

On Sat, Feb 14, 2015 at 11:49 AM, Stojan Kukrika [email protected]
wrote:

Closed #38
#38
.


Reply to this email directly or view it on GitHub
#38 (comment)
.

by
R.KUMAR.

@zcosmin20 zcosmin20 mentioned this issue Dec 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants