v1.5.19d Add the add function in create multiple events

This commit is contained in:
Neerholt 2021-05-04 11:24:56 +02:00
parent 574534fe2a
commit c617012187
3 changed files with 37 additions and 58 deletions

View File

@ -32,9 +32,9 @@ class MultipleEventsController extends Controller
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function index() public function index(Request $request)
{ {
$multiEvents = MultipleEventsParent::query()->join("multiple_events", "multiple_events.multiple_events_parent_id", "=", "multiple_events_parent.id")->orderBY('multiple_events_parent.id' , 'desc')->get(); $multiEvents = MultipleEventsParent::query()->join("multiple_events", "multiple_events.multiple_events_parent_id", "=", "multiple_events_parent.id")->where('multiple_events_parent.id', '=', $request->multiEvent)->orderBY('multiple_events_parent.id' , 'desc')->get();
return Response::detect("multiple-events.index", [ "multiEvents" => $multiEvents]); return Response::detect("multiple-events.index", [ "multiEvents" => $multiEvents]);
} }
@ -59,15 +59,10 @@ class MultipleEventsController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$requestBody = $request->validate([ $requestBody = $request->validate([
"week" => "max:255",
"name" => "array", "name" => "array",
"description" => "array", "description" => "array",
"accountable" => "array", "accountable" => "array",
"date" => "array", "date" => "array",
"name.*" => "max:255",
"description.*" => "max:255",
"accountable.*" => "max:255",
"date.*" => "max:255"
]); ]);
$multipleParent = new MultipleEventsParent(); $multipleParent = new MultipleEventsParent();
@ -100,11 +95,11 @@ class MultipleEventsController extends Controller
if($request->newsoption == true){ if($request->newsoption == true){
$news = new News(); $news = new News();
$news->name = "Nye ugentlig aktivitets"; $news->name = "Nye ugentlig aktivitets";
$news->subname = $event->week; $news->subname = $request->week;
$news->arrangement_id = $multipleParent->id; $news->arrangement_id = $multipleParent->id;
$news->type_id = '5'; $news->type_id = '5';
$news->content = "Den ugentlige aktivitets plan er landet"; $news->content = "Den ugentlige aktivitets plan er landet";
$news->resource_id = $event->resource_id; $news->resource_id = $request->resource_id;
NewsController::storeAndGet($news); NewsController::storeAndGet($news);
} }

View File

@ -40,41 +40,19 @@
<input type="text" name="week" placeholder="Uge"> <input type="text" name="week" placeholder="Uge">
<label id="fileuploadee"for="fileuploade">Baggrundsbillede til nyheden (Valgfri)</label> <label id="fileuploadee"for="fileuploade">Baggrundsbillede til nyheden (Valgfri)</label>
<input id="fileuploade" type="file" name="resource" accept="image/*"> <input id="fileuploade" type="file" name="resource" accept="image/*">
<table> <table class="asd">
<tr> <tr>
<th>Ugedag</th>
<th>Aktivitets navn</th> <th>Aktivitets navn</th>
<th>Aktivitets beskrivelse</th> <th>Aktivitets beskrivelse</th>
<th>Tovholder</th> <th>Tovholder</th>
<th>Tidsrum (Start)</th> <th>Tidsrum (Start)</th>
</tr> </tr>
<tr> <tr>
<td>Mandag</td> <td><input type="text" name="name[]"></td>
<td><input type="text" name="name[]" max="255" value="{{ old("name.0") }}"></td> <td><input type="text" name="description[]"></td>
<td><input type="text" name="description[]" max="255" value="{{ old("description.0") }}"></td> <td><input type="text" name="accountable[]"></td>
<td><input type="text" name="accountable[]" value="{{ old("accountable.0") }}"></td> <td><input type="datetime-local" name="date[]"></td>
<td><input type="datetime-local" name="date[]" value="{{ old("date.0") }}"></td> <td><button type="button" class="btn btn-inline btn-sde-blue" id="add2">Tilføj en kolonne</button></td>
</tr>
<tr>
<td>Tirsdag</td>
<td><input type="text" name="name[]" max="255" value="{{ old("name.1") }}"></td>
<td><input type="text" name="description[]" max="255" value="{{ old("description.1") }}"></td>
<td><input type="text" name="accountable[]" value="{{ old("accountable.1") }}"></td>
<td><input type="datetime-local" name="date[]" value="{{ old("date.1") }}"></td>
</tr>
<tr>
<td>Onsdag</td>
<td><input type="text" name="name[]" max="255" value="{{ old("name.2") }}"></td>
<td><input type="text" name="description[]" max="255" value="{{ old("description.2") }}"></td>
<td><input type="text" name="accountable[]" value="{{ old("accountable.2") }}"></td>
<td><input type="datetime-local" name="date[]" value="{{ old("date.2") }}"></td>
</tr>
<tr>
<td>Torsdag</td>
<td><input type="text" name="name[]" max="255" value="{{ old("name.3") }}"></td>
<td><input type="text" name="description[]" max="255" value="{{ old("description.3") }}"></td>
<td><input type="text" name="accountable[]" value="{{ old("accountable.3") }}"></td>
<td><input type="datetime-local" name="date[]" value="{{ old("date.3") }}"></td>
</tr> </tr>
</table> </table>
@ -148,5 +126,17 @@
} }
}); });
}) })
$(document).ready(function (){
$("#add2").click(function(){
$( ".asd" ).append( "<tr><td><input type='text' name='name[]'></td><td><input type='text' name='description[]'></td><td><input type='text' name='accountable[]'></td><td><input type='datetime-local' name='date[]'><td/></tr>" );
console.log("1");
});
});
</script> </script>
@endsection @endsection

View File

@ -73,31 +73,25 @@
<!--If there is a images to the event do this: Start--> <!--If there is a images to the event do this: Start-->
@if(!$multiEvents->isEmpty()) @if(!$multiEvents->isEmpty())
@if($multiEvents->contains('week', $Week)) {{-- If any of the menues in the menu table has the number of the week in the 'week' column, do this --}}
@foreach($multiEvents as $multiEvent) @foreach($multiEvents as $multiEvent)
@if($multiEvent->week == $Week) <div class="card">
<div class="card"> <div class="container" class="mt-1">
<div class="container" class="mt-1"> <h4 class="m-none">{{ date('l', strtotime($multiEvent->date)) }}</h4>
<h4 class="m-none">{{ date('l', strtotime($multiEvent->date)) }}</h4> <h4 class="m-none">{{$multiEvent->name}}</h4>
<h4 class="m-none">{{$multiEvent->name}}</h4> <p class="mt-0">{{__('msg.af')}}: {{$multiEvent->accountable}}</p>
<p class="mt-0">{{__('msg.af')}}: {{$multiEvent->accountable}}</p> <p class="mt-0">{{$multiEvent->description}}</p>
<p class="mt-0">{{$multiEvent->description}}</p> <p class="m-none">{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($multiEvent->date))->format('d/m/Y \k\l\. H:i') }}</p>
<p class="m-none">{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($multiEvent->date))->format('d/m/Y \k\l\. H:i') }}</p> <div class="row justify-content-space mt-1">
<div class="row justify-content-space mt-1"> @if (count(\App\UserEvent::query()->where('multiple_event_id', '=', $multiEvent->id)->where('user_id', '=', Auth::user()->id)->get()) > 0)
@if (count(\App\UserEvent::query()->where('multiple_event_id', '=', $multiEvent->id)->where('user_id', '=', Auth::user()->id)->get()) > 0) <a class="sde-blue text-center m-none p-none bold" href="javascript:void(0);" onclick="ajaxCall({{ $multiEvent->id }}, this)" >{{__('msg.afmeld')}}</a>
<a class="sde-blue text-center m-none p-none bold" href="javascript:void(0);" onclick="ajaxCall({{ $multiEvent->id }}, this)" >{{__('msg.afmeld')}}</a> @else {{-- ^ If you're already participating in the event, then show a ´cancel´ button - v Else show a ´participate´ button --}}
@else {{-- ^ If you're already participating in the event, then show a ´cancel´ button - v Else show a ´participate´ button --}} <a class="sde-blue text-center m-none p-none bold" href="javascript:void(0);" onclick="ajaxCall({{ $multiEvent->id }}, this)" >{{__('msg.tilmeld')}}</a>
<a class="sde-blue text-center m-none p-none bold" href="javascript:void(0);" onclick="ajaxCall({{ $multiEvent->id }}, this)" >{{__('msg.tilmeld')}}</a> @endif
@endif <a class="sde-blue text-center m-none p-none bold" href="{{route("multiple-events.accountsignups", ["multiEvent" => $multiEvent->id ])}}">{{__('msg.sedeltagere')}}</a>
<a class="sde-blue text-center m-none p-none bold" href="{{route("multiple-events.accountsignups", ["multiEvent" => $multiEvent->id ])}}">{{__('msg.sedeltagere')}}</a>
</div>
</div> </div>
</div> </div>
@endif </div>
@endforeach @endforeach
@else
<p class="text-center">{{__('msg.dereringenugentligeaktiviteter')}}!</p>
@endif
@endif @endif
<button onclick="document.location = document.referrer;" class="btn btn-sde-blue text-white mb-1 mt-auto">{{ __('msg.tilbage') }}</button> <button onclick="document.location = document.referrer;" class="btn btn-sde-blue text-white mb-1 mt-auto">{{ __('msg.tilbage') }}</button>
</main> </main>