v1.5.24bb Added comments
This commit is contained in:
@@ -81,10 +81,14 @@ class EventController extends Controller
|
||||
$event->save();
|
||||
$events = Event::query()->get();
|
||||
|
||||
//If the check on the create pages that is was a news and has to be displayed on the news pages
|
||||
if($request->newsoption == true){
|
||||
//Get all events from the database
|
||||
$events = Event::query()->get();
|
||||
//make a new object of the news calls
|
||||
$news = new News();
|
||||
|
||||
//Get and save the data
|
||||
$news->name = "Ny aktivitet";
|
||||
$news->subname = $event->name;
|
||||
$news->arrangement_id = $event->id;
|
||||
@@ -93,6 +97,7 @@ class EventController extends Controller
|
||||
$news->resource_id = $event->resource_id;
|
||||
$news->news_expiration_date = $events[0]->date;
|
||||
|
||||
//Call the news controller function store and get, pass $news to be saved
|
||||
NewsController::storeAndGet($news);
|
||||
}
|
||||
|
||||
@@ -108,7 +113,9 @@ class EventController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//Get the entity that match with the passed id.
|
||||
$event = Event::query()->where("id", "=", $id)->first();
|
||||
//return the fetch data to the show pages
|
||||
return Response::detect("events.show", [ "event" => $event ]);
|
||||
}
|
||||
|
||||
@@ -164,17 +171,23 @@ class EventController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//Set $data to holde the value of request->all
|
||||
$data = $request->all();
|
||||
|
||||
//Get the event with matching id
|
||||
$event = Event::find($id);
|
||||
|
||||
//get all events that has a match with the passed id
|
||||
$allEvents = Event::query()->where('name', '=', $request->name)->where('id', '!=', $id)->get();
|
||||
|
||||
//If the amount of $allevents is equal to 0 redirect to index
|
||||
if(count($allEvents) > 0){
|
||||
return redirect()->route("events.index", ['events' => $event]);
|
||||
}else{
|
||||
//Call the update function
|
||||
$event->update($data);
|
||||
|
||||
//If the events has a images call the Resource Controllers store function
|
||||
if($request->file("resource")) {
|
||||
$event->resource_id = ResourceController::store($request)->id;
|
||||
}
|
||||
@@ -240,6 +253,7 @@ class EventController extends Controller
|
||||
}
|
||||
|
||||
//Fixes tags that have been substringed
|
||||
//idk yoink this bitch from stackoverflow, you never going to use it, trust me.
|
||||
public function closetags($html) {
|
||||
preg_match_all('#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
|
||||
$openedtags = $result[1];
|
||||
@@ -261,6 +275,7 @@ class EventController extends Controller
|
||||
}
|
||||
|
||||
public function deleteNotifications(Request $request){
|
||||
//If the request is equal to ajax, delete every notification where the user_id is = to the $request->user_id
|
||||
if($request->ajax()){
|
||||
foreach (Notification::query()->where("user_id", "=", $request->user_id)->get() as $notification) {
|
||||
$notification->delete();
|
||||
@@ -273,6 +288,7 @@ class EventController extends Controller
|
||||
|
||||
//Used for checking if the currently typed event name is unique. Create version
|
||||
public function nameCheck(Request $request){
|
||||
//Search the database to check that the name they are typing is uniq
|
||||
$event = Event::query()->where('name', 'LIKE',$request->nameCheck)->get();
|
||||
if(count($event) > 0 && $request->nameCheck !== NULL){
|
||||
return 1;
|
||||
@@ -288,11 +304,9 @@ class EventController extends Controller
|
||||
}
|
||||
|
||||
public function previewPages(Request $request){
|
||||
//if(!Resource::find($request->preview)){
|
||||
// $event = Event::find($request->preview);
|
||||
//}else{
|
||||
$event = Event::where('events.id', '=', $request->preview)->leftJoin('resources', 'resources.id', '=', 'events.resource_id')->first();
|
||||
//}
|
||||
//get the data from the database that match the request and leftjoin the resources table
|
||||
$event = Event::where('events.id', '=', $request->preview)->leftJoin('resources', 'resources.id', '=', 'events.resource_id')->first();
|
||||
//convert dababy to a convertible
|
||||
$convertToJsonArray = json_encode($event);
|
||||
return $convertToJsonArray;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user