Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Listing languages 29 (#103)
Browse files Browse the repository at this point in the history
* ragnaranks-29 Server language support database + vue

* ragnaranks-29 Server language support database + vue

* ragnaranks-29 Server language support database + vue

* Apply fixes from StyleCI (#101)

[ci skip] [skip ci]

* account design improv

* merge master

* Apply fixes from StyleCI (#104)

[ci skip] [skip ci]

* #29, flags now seed correctly, flag images added, flags now show on homepage.

* #29, tests
  • Loading branch information
marky291 committed Jun 3, 2019
1 parent 98216ce commit f4c1b7a
Show file tree
Hide file tree
Showing 29 changed files with 526 additions and 24 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/ListingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Listings\Listing;
use App\Jobs\RoleAssignment;
use Illuminate\Http\Request;
use App\Listings\ListingLanguage;

/**
* Class ListingController.
Expand Down Expand Up @@ -37,7 +38,7 @@ public function index()
*/
public function create()
{
return view('listing.form')->with(['tags' => Tag::all()]);
return view('listing.form')->with(['tags' => Tag::all(), 'languages' => ListingLanguage::all()]);
}

/**
Expand Down
13 changes: 12 additions & 1 deletion app/Listings/Listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphToMany;

/**
Expand Down Expand Up @@ -134,10 +135,20 @@ public function screenshots(): HasMany
return $this->hasMany(ListingScreenshot::class);
}

/**
* A listing belongs to a country language.
*
* @return BelongsTo|ListingLanguage
*/
public function language() : BelongsTo
{
return $this->belongsTo(ListingLanguage::class);
}

/**
* A listing belongs to a single owner.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function user()
{
Expand Down
2 changes: 1 addition & 1 deletion app/Listings/ListingCacheContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ListingCacheContainer implements ShouldQueue
public function handle()
{
return cache()->remember('listings', 1, static function () {
$listings = Listing::query()->withCount(['votes', 'clicks'])->with(['mode', 'tags', 'screenshots'])->get();
$listings = Listing::query()->withCount(['votes', 'clicks'])->with(['mode', 'tags', 'screenshots', 'language'])->get();

$listings = $listings->sortByDesc(function (Listing $listing) {
return $listing->points;
Expand Down
15 changes: 15 additions & 0 deletions app/Listings/ListingLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Listings;

use Illuminate\Database\Eloquent\Model;

class ListingLanguage extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name'];
}
14 changes: 12 additions & 2 deletions database/factories/ListingFactory.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php


use App\Mode;
use Carbon\Carbon;
use App\Listings\Listing;
use Faker\Generator as Faker;
use App\Listings\ListingLanguage;

$factory->define(\App\Listings\ListingScreenshot::class, function (Faker $faker) {
return [
Expand All @@ -11,6 +14,12 @@
];
});

$factory->define(ListingLanguage::class, function (Faker $faker) {
return [
'name' => $faker->languageCode,
];
});

$factory->define(Listing::class, function (Faker $faker) {
$server = array_random(config('fake.listings'));

Expand All @@ -33,10 +42,11 @@
],
'user_id' => factory('App\User')->create()->id,
'website' => $faker->url,
'mode_id' => \App\Mode::inRandomOrder()->first(),
'mode_id' => Mode::inRandomOrder()->first(),
'description' => $server['description'],
'language_id' => ListingLanguage::all()->random()->getKey(),
'episode' => collect([13.10, 13.09, 13.05, 12.11])->random(),
'banner_url' => $server['banner'],
'created_at' => \Carbon\Carbon::now()->subHours(rand(1, 500)),
'created_at' => Carbon::now()->subHours(rand(1, 500)),
];
});
20 changes: 20 additions & 0 deletions database/migrations/2018_09_16_101736_create_server_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use App\Listings\ListingLanguage;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
Expand Down Expand Up @@ -105,6 +106,23 @@ public function up()
],
]);

Schema::create('listing_languages', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->timestamps();
});

(new ListingLanguage(['name' => 'english']))->save();
(new ListingLanguage(['name' => 'french']))->save();
(new ListingLanguage(['name' => 'german']))->save();
(new ListingLanguage(['name' => 'irish']))->save();
(new ListingLanguage(['name' => 'portuguese']))->save();
(new ListingLanguage(['name' => 'malaysian']))->save();
(new ListingLanguage(['name' => 'mandarin']))->save();
(new ListingLanguage(['name' => 'russian']))->save();
(new ListingLanguage(['name' => 'spanish']))->save();
(new ListingLanguage(['name' => 'tagalog']))->save();

Schema::create('listings', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
Expand All @@ -116,11 +134,13 @@ public function up()
$table->string('website');
$table->unsignedInteger('mode_id');
$table->string('accent')->default('nightmare');
$table->unsignedInteger('language_id')->default(1);
$table->double('episode')->nullable();
$table->timestamps();
$table->index(['episode']);
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade');
$table->foreign('mode_id')->references('id')->on('modes')->onUpdate('cascade');
$table->foreign('language_id')->references('id')->on('listing_languages')->onUpdate('cascade');
});

Schema::create('listing_tag', function (Blueprint $table) {
Expand Down
Binary file added public/img/flags/197373-countrys-flags.zip
Binary file not shown.
Binary file removed public/img/flags/english.png
Binary file not shown.
61 changes: 61 additions & 0 deletions public/img/flags/english.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions public/img/flags/french.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions public/img/flags/german.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions public/img/flags/irish.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions public/img/flags/malaysian.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f4c1b7a

Please sign in to comment.