Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/Http/Controllers/MainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@

namespace App\Http\Controllers;

use App\Models\Review;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Session;

class MainController extends Controller
{
public function index(){
return view('welcome');
$data = [
'reviews' => Review::validated()->inRandomOrder()->get(),
];

return view('welcome', $data);
}

public function switchBackground($background){
if(file_exists(public_path('images/layout/'.$background.'.png'))){
Session::put('user_bg', $background);
}

return redirect()->route('index');
}
}
24 changes: 24 additions & 0 deletions app/Http/Controllers/ReviewController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Controllers;

use App\Models\Review;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cookie;

class ReviewController extends Controller
{
public function postSiteReview(Request $request){
$data = [
'session' => Cookie::get(session()->getName()),
'scope' => $request->get(),
'stars' => $request->get('stars'),
'text' => $request->get('text'),
'name' => $request->get('name'),
'validated' => $request->get(false),
];

Review::create($data);
return redirect()->route('index');
}
}
30 changes: 30 additions & 0 deletions app/Http/Requests/PostReviewRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class PostReviewRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
48 changes: 48 additions & 0 deletions app/Models/Review.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Str;

class Review extends Model
{
protected $fillable = [
'session',
'scope',
'stars',
'text',
'name',
'validated',
];

use HasFactory;

const SCOPE_SITE = 1;

#ToDo: integrate with skin tool
const SCOPE_SKIN = 2;

public function getValidatedAttribute(){
if($this->attributes['validated'] == false && $this->attributes['stars'] > 3 || (!Str::of($this->attributes['text'])->isEmpty() && !Str::of($this->attributes['name'])->isEmpty())){
$this->update(['validated' => true]);
$this->attributes['validated'] = true;
}

return $this->attributes['validated'];
}

public function getNameAttribute(){
$name = $this->attributes['name'];
if(Str::of($name)->isEmpty()){
$name = 'Anonymous reviewer';
}
return $name;
}

public function scopeValidated($query){
return $query->where('validated', true);
}
}
36 changes: 0 additions & 36 deletions database/migrations/2014_10_12_000000_create_users_table.php

This file was deleted.

This file was deleted.

36 changes: 0 additions & 36 deletions database/migrations/2019_08_19_000000_create_failed_jobs_table.php

This file was deleted.

37 changes: 37 additions & 0 deletions database/migrations/2021_05_04_174705_create_reviews_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateReviewsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('reviews', function (Blueprint $table) {
$table->id();
$table->text('session');
$table->integer('scope')->default(\App\Models\Review::SCOPE_SITE);
$table->integer('stars')->nullable();
$table->text('text')->nullable();
$table->text('name')->nullable();
$table->boolean('validated')->default(false);
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('reviews');
}
}
19,431 changes: 19,424 additions & 7 deletions public/css/main.css

Large diffs are not rendered by default.

Binary file added public/images/mon/staryu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/mon/staryu_bw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/staryu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/staryu_bw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50,687 changes: 50,685 additions & 2 deletions public/js/main.js

Large diffs are not rendered by default.

Binary file added resources/img/mon/staryu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/mon/staryu_bw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions resources/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
})

$(document).ready(function () {

$('.selectBox-square').height($('.selectBox-square').width());
$('.selectBox-square').click(function () {
var selector = $(this).attr('target-input');
$('.selectBox-square').removeClass('selectBox-square-selected')
$(this).addClass('selectBox-square-selected')
$('.selectBox-input[data-selector="'+selector+'"]').click();
})
$("#reviewCollapseButton").click(function () {
$(this).toggleClass('collapsed');
$('#collapseReview').toggleClass('show');
})
})
28 changes: 28 additions & 0 deletions resources/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,31 @@ a {
font-size: 3.5rem;
}
}


#reviewCollapseButton.collapsed:after {
content: '+ Show More';
}

#reviewCollapseButton:not(.collapsed):after {
content: '- Show Less';
}

#reviewbox #collapseReview.collapse:not(.show) {
display: block;
height: 4.5em;
overflow: hidden;
}

#reviewbox #collapseReview.collapsing {
height: 4.5em;
}

#collapseReview {
.row {
margin-bottom: 50px;
div {
min-height: 100%;
}
}
}
33 changes: 33 additions & 0 deletions resources/views/partials/reviews.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div id="reviewbox" class="col-12 row p-3">
<h2 class="col-12 text-dark crystal-textbox text-center">Reviews</h2>
<div class="collapse col-12 m-2 " id="collapseReview" aria-expanded="false">
@foreach($reviews as $review)
@if(($loop->iteration-1) % 2 == 0)
<div class="row col-12">
@endif
<div class="col-12 col-sm-6">
<div class="text-dark crystal-textbox text-center">
<div class="col-10 offset-1">
<img src="{{ $review->stars >= 1 ? asset('images/mon/staryu.png') : asset('images/mon/staryu_bw.png') }}" class="col-2" />
<img src="{{ $review->stars >= 2 ? asset('images/mon/staryu.png') : asset('images/mon/staryu_bw.png') }}" class="col-2" />
<img src="{{ $review->stars >= 3 ? asset('images/mon/staryu.png') : asset('images/mon/staryu_bw.png') }}" class="col-2" />
<img src="{{ $review->stars >= 4 ? asset('images/mon/staryu.png') : asset('images/mon/staryu_bw.png') }}" class="col-2" />
<img src="{{ $review->stars >= 5 ? asset('images/mon/staryu.png') : asset('images/mon/staryu_bw.png') }}" class="col-2" />
<br/>
@if($review->stars == null || $review->stars == 0) (No rating) @else &nbsp; @endif
</div>
{{$review->text}}
<hr class="align-text-bottom"/>
<span class="align-text-bottom">- {{$review->name}}</span>
</div>
</div>
@if(($loop->iteration) % 2 == 0)
</div>
@endif
@endforeach

</div>
</div>
<div class="col-12 align-items-center">
<button role="button" id="reviewCollapseButton" class="col-12 offset-sm-5 col-sm-6 crystal-textbox showoff_item collapsed" data-toggle="collapse" aria-expanded="false" aria-controls="collapseReview"></button>
</div>
1 change: 1 addition & 0 deletions resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<div class="row">
<div class="col-12 col-sm-6">@include('partials.newsbox')</div>
<div class="col-12 col-sm-6">@include('partials.statistics')</div>
<div class="col-12 col-sm-12">@include('partials.reviews')</div>
</div>
</div>
</div>
Expand Down