Skip to content
Open
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
62 changes: 62 additions & 0 deletions app/Enums/CaseType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace App\Enums;

use BenSampo\Enum\Enum;

/**
* @method static static Burried_People()
* @method static static BurBasic_Needsried()
* @method static static Clothing()
* @method static static Response_Centers()
* @method static static Shelters()
* @method static static Transportation()
* @method static static Safe_Centers()
* @method static static Dialysis()
* @method static static Medical_Centers()
* @method static static Volunteers()
* @method static static Other()
*/
final class CaseType extends Enum
{
const Burried_People = 1;
const Basic_Needs = 2;
const Clothing = 3;
const Response_Centers = 4;
const Shelters = 5;
const Transportation = 6;
const Safe_Centers = 7;
const Dialysis = 8;
const Medical_Centers = 9;
const Volunteers = 10;
const Other = 11;

public static $transalations = [
self::Burried_People => 'اشخاص عالقين تحت الانقاض',
self::Basic_Needs => 'مراكز يتوفر فيها حاجات اساسية مثل الطعام والشراب',
self::Clothing => 'مراكز يتوفر فيها ملابس وتدفئة',
self::Response_Centers => 'مراكز استجابة، فرق تطوعية',
self::Shelters => 'مراكز ايواء',
self::Transportation => 'مراكز يتوفر فيها مواصلات',
self::Safe_Centers => 'مراكز أمنة',
self::Dialysis => 'مراكز غسيل كلية',
self::Medical_Centers => 'مراكز ونقاط طبية',
self::Volunteers => 'تقديم المساعدة والتطوع',
self::Other => 'أخرى',
];

public function getTranslation(){
return data_get(self::$transalations, $this->value);
}

public static function asTranslatedSelectArray(): array
{
$translatedSelectArray = [];

foreach (self::getInstances() as $type) {
$translatedSelectArray[$type->value] = $type->getTranslation();
}

return $translatedSelectArray;
}
}
6 changes: 4 additions & 2 deletions app/Http/Controllers/CasesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\Enums\CaseType;
use App\Http\Export\CasesExport;
use App\Models\Cases;
use Illuminate\Http\Request;
Expand All @@ -19,9 +20,10 @@ public function store(Request $request)
public function map()
{

$data =Cases::where('display_on_map', 1)->get();
$data = Cases::where('display_on_map', 1)->get();
$case_types = CaseType::asTranslatedSelectArray();

return view('map', ['data' => $data]);
return view('map', compact('data','case_types'));
}

public function export()
Expand Down
14 changes: 14 additions & 0 deletions app/Http/Controllers/IndexController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Http\Controllers;

use App\Enums\CaseType;
use Illuminate\Http\Request;

class IndexController extends Controller
{
public function index(){
$case_types = CaseType::getInstances();
return view('index', compact('case_types'));
}
}
8 changes: 8 additions & 0 deletions app/Models/Cases.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace App\Models;

use App\Enums\CaseType;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;


Expand All @@ -26,4 +28,10 @@ public function getCreatedAtAttribute($val){
return Carbon::parse($val)->addHours(3)->format('Y-m-d H:i:s');
}

public function scopeTypeFilter(Builder $query,$type = null){
if(!is_null($type)){
$query->where('type', $type);
}
}

}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"bensampo/laravel-enum": "4.2.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.75",
Expand Down
202 changes: 200 additions & 2 deletions composer.lock

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

14 changes: 3 additions & 11 deletions resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,9 @@
<div class="form-group my-4">
<label for="case">حدد نوع الحالة <span style="color: red">* </span></label>
<select name="type" class="form-control" id="cases" required>
<option value="1" selected>انقاض، اشخاص عالقين تحت الانقاض.</option>
<option value="2">مراكز يتوفر فيها حاجات اساسية مثل الطعام والشراب</option>
<option value="3">مراكز يتوفر فيها ملابس وتدفئة</option>
<option value="4">فريق استجابة، فرق تطوعية</option>
<option value="5">مراكز ايواء</option>
<option value="6">مراكز يتوفر فيها مواصلات</option>
<option value="7">مراكز أمنة</option>
<option value="8">مراكز غسيل كلية</option>
<option value="9">مراكز ونقاط طبية</option>
<option value="10">تقديم المساعدة والتطوع</option>
<option value="11">أخرى</option>
@foreach ($case_types as $case_type)
<option value="{{ $case_type->value }}"> {{ $case_type->getTranslation() }}</option>
@endforeach
</select>
</div>

Expand Down
Loading