Skip to content

Commit

Permalink
Merge pull request #47 from datasektionen/rank-entities
Browse files Browse the repository at this point in the history
Fixat så att det går att ranka entities >:)
  • Loading branch information
Herkarl authored Sep 12, 2024
2 parents 6ab5eb4 + b3ea99f commit 0c59a2d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/Http/Controllers/Admin/EntityAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function postNew(Request $request)
$entity->part_of = $request->input('part_of');
$entity->fa_icon = $request->input('fa_icon');
$entity->contract_url = $request->input('contract') === 'yes' ? $request->input('contract_url') : null;
$entity->rank = $request->input('rank');
$entity->save();

return redirect('/admin/entities')
Expand Down Expand Up @@ -115,6 +116,7 @@ public function postEdit($id, Request $request)
$entity->part_of = $request->input('part_of');
$entity->fa_icon = $request->input('fa_icon');
$entity->contract_url = $request->input('contract') === 'yes' ? $request->input('contract_url') : null;
$entity->rank = $request->input('rank');
$entity->save();

return redirect('/admin/entities')
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public function getIndex(Request $request)
{
$hidden = $request->query('hidden');
$entities = Entity::query();
$entities->orderBy("rank");
if (!$hidden) {
$entities->orWhere("id", "<>", 15);
// Tack Adam
}

return view('welcome')
Expand Down
32 changes: 32 additions & 0 deletions database/migrations/2024_09_12_180106_add_rank.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

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

class AddRank extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('entities', function (Blueprint $table) {
$table->text('rank')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('entities', function (Blueprint $table) {
$table->dropColumn('rank');
});
}
}
12 changes: 12 additions & 0 deletions resources/views/admin/entities/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@
</div>
</div>

<div class="form-entry">
<span class="description">
Rank:
</span>
<p>
Hur högt upp ska denna entitet vara på startsidan?
</p>
<div class="input">
{!! Form::number('rank', $entity->rank, array('placeholder' => '1 = viktigast <-> 100 = mindre prioriterad')) !!}
</div>
</div>

<div class="form-entry">
<div class="input">
{!! Form::submit('Ändra entitet', NULL) !!}
Expand Down
12 changes: 12 additions & 0 deletions resources/views/admin/entities/new.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@
</div>
</div>
</div>

<div class="form-entry">
<span class="description">
Rank:
</span>
<p>
Hur högt upp ska denna entitet vara på startsidan?
</p>
<div class="input">
{!! Form::number('rank', NULL, array('placeholder' => '1 = viktigast <-> 100 = mindre prioriterad')) !!}
</div>
</div>

<div class="form-entry">
<div class="input">
Expand Down

0 comments on commit 0c59a2d

Please sign in to comment.