45 lines
No EOL
1.5 KiB
PHP
Executable file
45 lines
No EOL
1.5 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Draft;
|
|
use App\Models\TravelProgram;
|
|
use HTMLHelper;
|
|
|
|
|
|
class DraftController extends Controller
|
|
{
|
|
public $successStatus = 200;
|
|
|
|
|
|
public function draft($action)
|
|
{
|
|
if($action == "get_draft_list"){
|
|
$drafts = Draft::where('active', true)->get()->sortByDesc("id");
|
|
return response()->json(['success' => $drafts], $this->successStatus);
|
|
}
|
|
|
|
if($action == "get_draft_list_for_table"){
|
|
$ret = [];
|
|
if(request('program_id') && request('program_id') > 0){
|
|
$travel_program = TravelProgram::find(request('program_id'));
|
|
if(count($travel_program->travel_program_drafts)){
|
|
foreach ($travel_program->travel_program_drafts as $travel_program_draft){
|
|
$key = $travel_program_draft->id;
|
|
$ret[$key]['name'] = $travel_program_draft->draft->name;
|
|
if($travel_program_draft->travel_class){
|
|
$ret[$key]['travel_class'] = $travel_program_draft->travel_class->name;
|
|
}else{
|
|
$ret[$key]['travel_class'] = "alle Kategorien";
|
|
}
|
|
$ret[$key]['weekdays'] = HTMLHelper::getWeekdaysString($travel_program_draft->weekdays);
|
|
}
|
|
}
|
|
}
|
|
return response()->json(['success' => $ret], $this->successStatus);
|
|
|
|
|
|
}
|
|
}
|
|
} |