Skip to content

Commit

Permalink
Menambahkan accept dan decline pendaftar kolaborasi yang diminta oleh…
Browse files Browse the repository at this point in the history
… pengguna lain ref # 16
  • Loading branch information
melshnz committed Jun 18, 2021
1 parent af1bfc4 commit 53fd9fc
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 48 deletions.
69 changes: 69 additions & 0 deletions app/Http/Controllers/EventSayaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace App\Http\Controllers;

use App\Models\Events;
use App\Models\EventsTags;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Storage;

class EventSayaController extends Controller
{
public function __construct(NotificationController $notifController)
{
$this->middleware('auth');
$this->notifController = $notifController;
}

// public function index()
// {
// // $events = $this->getAllEvents();
// // return view('event', [
// // 'event' => $events
// // ]);
// }

public function index($id)
{
$events = DB::table('events')
->where('id', '=', $id)
->get();
$event = $events[0];

$events_tags = EventsTags::where('events_id', '=', $id)
->where('status','<>','D')->get();

return view('eventSaya', [
'event_name'=>$event->event_name,
'description'=>$event->description,
'start_date'=>$event->start_date,
'end_date'=>$event->end_date,
'capacity'=>$event->capacity,
'events_tags'=>$events_tags,
'alert'=>''
]);

}

public function acceptTags(Request $request){
$events_tag_a = EventsTags::find($request->eventsTagsId);
$events_tag_a->status = 'A';
$events_tag_a->save();
$data = [$events_tag_a->users->id, 'AE', $events_tag_a->events->id];
$this->notifController->addNotification($data);
return Redirect::to('eventSaya/'.$events_tag_a->events->id);
}

public function declineTags(Request $request){
$events_tag_a = EventsTags::find($request->eventsTagsId);
$events_tag_a->status = 'D';
$events_tag_a->save();
$data = [$events_tag_a->users->id, 'DE', $events_tag_a->events->id];
$this->notifController->addNotification($data);
return $this->index($events_tag_a->events->id);
}

}
6 changes: 3 additions & 3 deletions app/Models/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public function users() {
}

public function comments() {
return $this->belongsTo('App\Models\Events_Comments');
return $this->belongsTo('App\Models\EventsComments');
}

public function tags() {
return $this->belongsTo('App\Models\Events_Tags');
public function events_tags() {
return $this->belongsTo('App\Models\EventsTags');
}

}
14 changes: 12 additions & 2 deletions app/Models/EventsTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,28 @@ class EventsTags extends Model
protected $fillable = [
'events_id',
'users_id',
'created_at',
'updated_at'
];

public function __construct()
{

}

// public function events() {
// return $this->hasMany('App\Models\Events','id');
// }

// public function users() {
// return $this->hasMany('App\Models\Users');
// }

public function events() {
return $this->hasMany('App\Models\Events','id');
return $this->belongsTo('App\Models\Events');
}

public function users() {
return $this->hasMany('App\Models\Users','id');
return $this->belongsTo('App\Models\Users');
}
}
2 changes: 2 additions & 0 deletions app/Models/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Images extends Model
'url',
];

public $timestamps = false;

public function __construct()
{

Expand Down
40 changes: 29 additions & 11 deletions app/Models/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,56 @@ class Users extends Authenticatable

public function __construct()
{

}

public function images() {
public function images()
{
return $this->hasOne('App\Models\Images');
}

public function profile() {
return $this->hasMany('App\Models\Users','id');
public function profile()
{
return $this->hasMany('App\Models\Users', 'id');
}

public function posts() {
public function posts()
{
return $this->hasMany('App\Models\Posts');
}

public function tags() {
public function tags()
{
return $this->belongsTo('App\Models\Tags');
}

public function comments() {
public function comments()
{
return $this->belongsTo('App\Models\Comments');
}

public function events() {
public function events()
{
return $this->belongsTo('App\Models\Events');
}

public function events_tags() {
return $this->belongsTo('App\Models\Events_Tags');
public function eventsTags()
{
return $this->hasMany(EventsTags::class);
}

public function events_comments() {
public function events_comments()
{
return $this->belongsTo('App\Models\Comments');
}

// users that are followed by this user
public function following() {
return $this->belongsToMany(Users::class, 'follows', 'follower_id', 'following_id');
}

// users that follow this user
public function followers() {
return $this->belongsToMany(Users::class, 'follows', 'following_id', 'follower_id');
}

}
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions public/css/coco.css
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,19 @@ body {
margin-left: 5px;
margin-right: 5px;
}

.media .avatar {
width: 32px;
width: 32px;
}

.shadow-textarea textarea.form-control::placeholder {
font-weight: 75;
font-weight: 75;
}

.shadow-textarea textarea.form-control {
padding-left: 0.5rem;
padding-left: 0.5rem;
}

.dropdown-item-custom {
white-space: normal !important;
}
Binary file added public/public/profile-images/unknown.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions resources/views/event.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@
</select> -->
<!-- UNDANG TEMAN -->
<br>
<a href="#">
<img src="\img\undang-teman.png" alt="undangTeman" style="width: 40px; height:auto; margin-left:15px;margin-right:20px">
</a>
<label for="inputJudul" class="form-label"><b>Undang Teman...</b></label>
<br>
<br>
<button type="submit" class="btn" style="float: right; background-color:#F57ABC; color:white;"><b>Buat</b></button>
</form>
Expand Down
82 changes: 58 additions & 24 deletions resources/views/eventSaya.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

@section('main-content')

@if($alert!='')
<div class="alert alert-primary" role="alert">
{{$alert}}
</div>
@endif

<div class="container body--eventSaya" style="background: #FCF2FF; width: 900px;">
<h5 class="" style="text-align:center; font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;margin-top:5px">
Kampanye Mental Health
{{ $event_name }}
</h5>
<center>
<div class="container mt-5">
Expand All @@ -14,34 +20,62 @@
<img src="img/taeyong.jpeg" alt="" style="width: 100px; height: 100px; border-radius:50%; ">
</center> <br>
<p style="text-align:left">Deskripsi Event</p>
<form action="/edit/<?php echo $users[0]->id; ?>" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2" style="height: 100px"></textarea>
<label for="floatingTextarea2"></label> <br>
</div>
<p style="text-align:left">Tanggal Event</p>
<div class="date-group">
<input type="date" id="mulai" name="mulai" style="float: left; padding-left: 30px;"> <label for=""><b>Sampai</b> </label>
<input type="date" id="mulai" name="mulai" style="float: right; padding-left: 30px;">
</div> <br>
<p style="text-align:left">Kapasitas Team</p>
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea"></textarea>
<label for="floatingTextarea"></label> <br>
</div>
<p style="text-align:left">Visibilitas Event</p>
<div class="form-floating">
<textarea class="form-control" id="floatingTextarea2" style="height: 100px" disabled>{{ $description }}</textarea>
<label for="floatingTextarea2"></label> <br>
</div>
<p style="text-align:left">Tanggal Event</p>
<div class="date-group">
<input type="date" id="mulai" name="mulai" style="float: left; padding-left: 30px;" value="{{ $start_date }}" disabled>
<label for=""><b>Sampai</b> </label>
<input type="date" id="mulai" name="mulai" style="float: right; padding-left: 30px;" value="{{ $end_date }}" disabled>
</div> <br>
<p style="text-align:left">Kapasitas Team</p>
<div class="form-floating">
<textarea class="form-control" id="floatingTextarea"> {{ $capacity }} </textarea>
<label for="floatingTextarea"></label> <br>
</div>
<!-- <p style="text-align:left">Visibilitas Event</p>
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea1"></textarea>
<label for="floatingTextarea">Undang Teman</label> <br>
</div> -->
<p style="text-align:left"><b>Kolaborator</b></p>
@foreach ($events_tags as $events_tag)
<div class="row mt-2 md-2">
<div class="col-8">
<img src="{{ url('displayImage/'.$events_tag->users->images_id.'')}}" style="width: 50px; height: 50px; border-radius:50%; float:left;" alt="">
<!-- <img src="img/mark.jpg" style="width: 50px; height: 50px; border-radius:50%; float:left;"> -->
<label style=" float:left; text-indent: 2em;"><a href="#"><b>{{ $events_tag->users->username }}</b></a></label> <label>
</div>
<p style="text-align:left"><b>Kolaborator</b></p>
<img src="img/mark.jpg" style="width: 50px; height: 50px; border-radius:50%; float:left;"> <label style=" float:left; text-indent: 2em;"><b>@mark_nct</b></label> <label>
<div class="btn" style="float: right; padding-left: 250px;">
<button style="background-color: #F57ABC; color: white;" type="button" id="btnSubmit" class="btn btn-sm">Accept</button>
<button style="background-color: #AAA4A7; color: white;" type="button" id="btnCancel" class="btn btn-sm">Decline</button>
<div class="col" style="float: right;">

<div class="row">
@if($events_tag->status=='P')
<div class="col">
<form method="POST" action="{{ route('eventSaya.accept') }}">
@csrf
<input value="{{$events_tag->id}}" name="eventsTagsId" type="hidden" />
<button style="background-color: #F57ABC; color: white;" id="btnSubmit" class="btn btn-sm" type="submit">Accept</button>
</form>
</div>
<div class="col">
<form method="POST" action="{{ route('eventSaya.decline') }}">
@csrf
<input value="{{$events_tag->id}}" name="eventsTagsId" type="hidden" />
<button style="background-color: #AAA4A7; color: white;" id="btnSubmit" class="btn btn-sm" type="submit">Decline</button>
</form>
</div>
@else
<button style="background-color: #F57ABC; color: white;" id="btnSubmit" class="btn btn-sm" type="submit" disabled>Accepted</button>
@endif
</div>
</form>
</div>
</div>
@endforeach
<!-- </form> -->
<!--
{!! $description !!} -->
</div>
</div>
</div>
Expand Down

0 comments on commit 53fd9fc

Please sign in to comment.