v1.5.12 Added the last things to the preview function, its all working now
This commit is contained in:
parent
493a8aeb34
commit
19fdb63ad2
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||||
use App\Event;
|
use App\Event;
|
||||||
use App\News;
|
use App\News;
|
||||||
use App\Notification;
|
use App\Notification;
|
||||||
|
use App\Resource;
|
||||||
use App\UserEvent;
|
use App\UserEvent;
|
||||||
use App\User;
|
use App\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
@ -288,7 +289,11 @@ class EventController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
public function previewPages(Request $request){
|
public function previewPages(Request $request){
|
||||||
$event = Event::find($request->preview);
|
if(!Resource::find($request->preview)){
|
||||||
|
$event = Event::find($request->preview);
|
||||||
|
}else{
|
||||||
|
$event = Event::where('events.id', '=', $request->preview)->join('resources', 'resources.id', '=', 'events.resource_id')->first();
|
||||||
|
}
|
||||||
$convertToJsonArray = json_encode($event);
|
$convertToJsonArray = json_encode($event);
|
||||||
return $convertToJsonArray;
|
return $convertToJsonArray;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Guide;
|
use App\Guide;
|
||||||
use App\News;
|
use App\News;
|
||||||
|
use App\Resource;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use tidy;
|
use tidy;
|
||||||
|
@ -277,7 +278,11 @@ class GuideController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
public function previewPages(Request $request){
|
public function previewPages(Request $request){
|
||||||
$event = Guide::find($request->preview);
|
if(!Resource::find($request->preview)){
|
||||||
|
$event = Guide::find($request->preview);
|
||||||
|
}else{
|
||||||
|
$event = Guide::where('guides.id', '=', $request->preview)->join('resources', 'resources.id', '=', 'events.resource_id')->first();
|
||||||
|
}
|
||||||
$convertToJsonArray = json_encode($event);
|
$convertToJsonArray = json_encode($event);
|
||||||
return $convertToJsonArray;
|
return $convertToJsonArray;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,25 +22,26 @@ class RootController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$perPage = 5;
|
if (File::exists(public_path('uploads'))) {
|
||||||
|
foreach (File::allFiles(public_path('uploads')) as $file) {
|
||||||
|
$resource = Resource::query()->where('filename', '=', '/uploads/' . $file->getFilename())->get();
|
||||||
|
|
||||||
foreach (File::allFiles(public_path('uploads')) as $file) {
|
if(count($resource) < 1)
|
||||||
$resource = Resource::query()->where('filename', '=', '/uploads/' . $file->getFilename())->get();
|
|
||||||
|
|
||||||
if(count($resource) < 1)
|
|
||||||
unlink(public_path() . '/uploads/' . $file->getFilename());
|
|
||||||
else {
|
|
||||||
$events = Event::query()->where('resource_id', '=', $resource[0]->id)->get();
|
|
||||||
$news = News::query()->where('resource_id', '=', $resource[0]->id)->get();
|
|
||||||
$guides = Guide::query()->where('resource_id', '=', $resource[0]->id)->get();
|
|
||||||
$users = User::query()->where('resource_id', '=', $resource[0]->id)->get();
|
|
||||||
|
|
||||||
if(count($events) < 1 && count($news) < 1 && count($guides) < 1 && count($users) < 1) {
|
|
||||||
$resource[0]->delete();
|
|
||||||
unlink(public_path() . '/uploads/' . $file->getFilename());
|
unlink(public_path() . '/uploads/' . $file->getFilename());
|
||||||
|
else {
|
||||||
|
$events = Event::query()->where('resource_id', '=', $resource[0]->id)->get();
|
||||||
|
$news = News::query()->where('resource_id', '=', $resource[0]->id)->get();
|
||||||
|
$guides = Guide::query()->where('resource_id', '=', $resource[0]->id)->get();
|
||||||
|
$users = User::query()->where('resource_id', '=', $resource[0]->id)->get();
|
||||||
|
|
||||||
|
if(count($events) < 1 && count($news) < 1 && count($guides) < 1 && count($users) < 1) {
|
||||||
|
$resource[0]->delete();
|
||||||
|
unlink(public_path() . '/uploads/' . $file->getFilename());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
File::makeDirectory(public_path('uploads'), 0777, true, true);
|
||||||
|
|
||||||
//All news
|
//All news
|
||||||
$newsCollection = News::query()->orderBy('id', 'desc')->get();
|
$newsCollection = News::query()->orderBy('id', 'desc')->get();
|
||||||
|
|
|
@ -11,11 +11,13 @@ class RemoveEvent extends Migration
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
\Illuminate\Support\Facades\DB::unprepared("CREATE OR REPLACE EVENT `remove_event` ON SCHEDULE EVERY 1 HOUR STARTS '2000-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO
|
\Illuminate\Support\Facades\DB::unprepared("CREATE OR REPLACE EVENT `remove_event` ON SCHEDULE EVERY 1 HOUR STARTS '2000-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO
|
||||||
DELETE FROM events WHERE HOUR(TIMEDIFF(NOW(), events.date)) >= 24 AND date(events.date) < CURDATE()");
|
DELETE FROM events WHERE HOUR(TIMEDIFF(NOW(), events.date)) >= 24 AND date(events.date) < CURDATE()");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse the migrations.
|
* Reverse the migrations.
|
||||||
|
|
|
@ -11,11 +11,13 @@ class RemoveNews extends Migration
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
\Illuminate\Support\Facades\DB::unprepared("CREATE OR REPLACE EVENT `remove_news` ON SCHEDULE EVERY 1 HOUR STARTS '2000-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO
|
\Illuminate\Support\Facades\DB::unprepared("CREATE OR REPLACE EVENT `remove_news` ON SCHEDULE EVERY 1 HOUR STARTS '2000-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO
|
||||||
DELETE FROM news WHERE news_expiration_date < NOW();");
|
DELETE FROM news WHERE news_expiration_date < NOW();");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse the migrations.
|
* Reverse the migrations.
|
||||||
|
|
|
@ -11,11 +11,13 @@ class RemoveReservation extends Migration
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
\Illuminate\Support\Facades\DB::unprepared("CREATE OR REPLACE EVENT `remove_reservation` ON SCHEDULE EVERY 1 HOUR STARTS '2000-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO
|
\Illuminate\Support\Facades\DB::unprepared("CREATE OR REPLACE EVENT `remove_reservation` ON SCHEDULE EVERY 1 HOUR STARTS '2000-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO
|
||||||
DELETE FROM washing_reservations WHERE time <= DATE_SUB(NOW(), INTERVAL 1 HOUR)");
|
DELETE FROM washing_reservations WHERE time <= DATE_SUB(NOW(), INTERVAL 1 HOUR)");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse the migrations.
|
* Reverse the migrations.
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
<strong><label for="accountable">Aktivitets ansvarlig</label></strong>
|
<strong><label for="accountable">Aktivitets ansvarlig</label></strong>
|
||||||
<p id="accountable"></p>
|
<p id="accountable"></p>
|
||||||
<hr>
|
<hr>
|
||||||
<img src="{{ asset(\App\Resource::query()->where("id", "=", $events->resource_id)->first()->filename) }}">
|
<img id="eventimg">
|
||||||
<p id="description"></p>
|
<p id="description"></p>
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
|
@ -96,6 +96,11 @@
|
||||||
$("#date").html(l.date);
|
$("#date").html(l.date);
|
||||||
$("#accountable").html(l.accountable);
|
$("#accountable").html(l.accountable);
|
||||||
$("#description").html(l.description);
|
$("#description").html(l.description);
|
||||||
|
|
||||||
|
if (l.filename)
|
||||||
|
$("#eventimg").attr('src', l.filename);
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
error:function (data) {
|
error:function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
@ -105,11 +110,23 @@
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
modalNews.style.display = "none";
|
modalNews.style.display = "none";
|
||||||
|
|
||||||
|
$("#name").html('');
|
||||||
|
$("#date").html('');
|
||||||
|
$("#accountable").html('');
|
||||||
|
$("#description").html('');
|
||||||
|
$("#eventimg").attr('src', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onmousedown = function(event) {
|
window.onmousedown = function(event) {
|
||||||
if (event.target == modalNews) {
|
if (event.target == modalNews) {
|
||||||
modalNews.style.display = "none";
|
modalNews.style.display = "none";
|
||||||
|
|
||||||
|
$("#name").html('');
|
||||||
|
$("#date").html('');
|
||||||
|
$("#accountable").html('');
|
||||||
|
$("#description").html('');
|
||||||
|
$("#eventimg").attr('src', '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -95,6 +95,7 @@
|
||||||
<center>
|
<center>
|
||||||
<h1 id="name"></h1>
|
<h1 id="name"></h1>
|
||||||
<hr>
|
<hr>
|
||||||
|
<img id="eventimg">
|
||||||
<strong><label for="guide_articles">Vejledning</label></strong>
|
<strong><label for="guide_articles">Vejledning</label></strong>
|
||||||
<p id="guide_articles"></p>
|
<p id="guide_articles"></p>
|
||||||
</center>
|
</center>
|
||||||
|
@ -116,7 +117,9 @@
|
||||||
console.log(l);
|
console.log(l);
|
||||||
$("#name").html(l.name);
|
$("#name").html(l.name);
|
||||||
$("#guide_articles").html(l.guide_articles);
|
$("#guide_articles").html(l.guide_articles);
|
||||||
//We need to add guide_category_id and resource_id
|
if (l.filename)
|
||||||
|
$("#eventimg").attr('src', l.filename);
|
||||||
|
|
||||||
},
|
},
|
||||||
error:function (data) {
|
error:function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
@ -126,11 +129,17 @@
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
modalNews.style.display = "none";
|
modalNews.style.display = "none";
|
||||||
|
$("#name").html('');
|
||||||
|
$("#guide_articles").html('');
|
||||||
|
$("#eventimg").attr('src', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onmousedown = function(event) {
|
window.onmousedown = function(event) {
|
||||||
if (event.target == modalNews) {
|
if (event.target == modalNews) {
|
||||||
modalNews.style.display = "none";
|
modalNews.style.display = "none";
|
||||||
|
$("#name").html('');
|
||||||
|
$("#guide_articles").html('');
|
||||||
|
$("#eventimg").attr('src', '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -98,6 +98,11 @@
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
modalNews.style.display = "none";
|
modalNews.style.display = "none";
|
||||||
|
$("#week").html('');
|
||||||
|
$("#monday").html('');
|
||||||
|
$("#tuesday").html('');
|
||||||
|
$("#wednesday").html('');
|
||||||
|
$("#thursday").html('');
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onmousedown = function(event) {
|
window.onmousedown = function(event) {
|
||||||
|
|
|
@ -93,11 +93,17 @@
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
modalNews.style.display = "none";
|
modalNews.style.display = "none";
|
||||||
|
$("#titleEvent").html('');
|
||||||
|
$("#dateEvent").html('');
|
||||||
|
$("#descriptionEvent").html('');
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onmousedown = function(event) {
|
window.onmousedown = function(event) {
|
||||||
if (event.target == modalNews) {
|
if (event.target == modalNews) {
|
||||||
modalNews.style.display = "none";
|
modalNews.style.display = "none";
|
||||||
|
$("#titleEvent").html('');
|
||||||
|
$("#dateEvent").html('');
|
||||||
|
$("#descriptionEvent").html('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue