I am working on a site where a new content is generated when a user uploads an xml feed. The view creates the page, with the id is part of the url eg. news/culture/sa/73 and news/culture/us/79.
First ask was to make a single view active,
I added was an active checkbox which is checked in the controller before rendering the view, what i would like to do is this. if i create news/culture/sa/74, and i set it to active, in the database it should select id 73 (and all other id tagged with sa) and make them inactive.
I tried the following query in my controller:
$culture = Culture::with('saculture.usculture')
->where('id', $cultureId)
->where('template_id', $type)
->where('publish_date', '<=', $now->toDateTimeString())
->where('unpublish_date', '>=', $now->toDateTimeString())
->where('is_live', '=', 1)
->where('id', '<>', $cultureId)
->update('is_live', '=', 0)
->first();
What i am trying to achieve with the above is the following. select * from culture table where the template_id (which is category id) is the the same as the new created one. but what i want to update are all the other ids except this one to not active.
The second ask is the url based questions.
currently the urls generated from the upload have the category_id and post id: www.site.com/2/1, www.site.com/2/2, www.site.com/2/3 ...
what i'm trying to achieve is the following. override the url eg www.site.com/2/1 to www.site.com/culture/sa (which is the active and the user can not access the other pages www.site.com/2/2 or www.site.com/2/3) as these will be disabled via the first query.
hope it makes more sense now.