Revision 1487 | Revision 1518 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?phpnamespace App\Http\Controllers;use App\Http\Requests\ActionRequest;use App\Models\Action;use Illuminate\Contracts\Foundation\Application;use Illuminate\Contracts\View\Factory;use Illuminate\Contracts\View\View;use Illuminate\Http\RedirectResponse;use Illuminate\Http\Request;class ActionController extends Controller{/*** Display a listing of the resource.**/public function index(): Factory|View|Application{//$actions = Action::orderBy( "rank" )->get();foreach ( $actions as $aId => $aktion ){$gVon = strtotime( $aktion->valid_from );$gBis = strtotime( $aktion->valid_to );$jetzt = time();if ( $jetzt >= $gVon && $jetzt <= $gBis ){$status = 0;}elseif ( $jetzt < $gVon ){$status = 1;}else{$status = 2;}$aktion->status = $status;}return view( 'admin/actions', [ "aktionen" => $actions, ] );}/*** Show the form for creating a new resource.**/public function create(): Factory|View|Application{//return view( 'admin/action' );}/*** Store a newly created resource in storage.** @param Request $request* @return RedirectResponse*/public function store( Request $request ): RedirectResponse{//$rules = ['name' => 'bail|max:255',];$request->validate( $rules );$bu = new Action();$bu->update( $request->validated() );return redirect( "/backend/actions" );}/*** Display the specified resource.** @param int $id*/public function show( int $id ){//}/*** Show the form for editing the specified resource.** @param int $id* @return Factory|View|Application*/public function edit( int $id ): Factory|View|Application{//\View::share( "lType", "k" );$action = Action::find( $id );return view( 'admin/action', [ "action" => $action, ] );}/*** Update the specified resource in storage.** @param ActionRequest $request* @param int $id* @return RedirectResponse*/public function update( ActionRequest $request, int $id ): RedirectResponse{//$rules = ['name' => 'bail|max:255',];$request->validate( $rules );$bu = Action::find( $id );$data = $request->validated();$bu->update( $data );return redirect( "/backend/actions" );}/*** Remove the specified resource from storage.** @param int $id* @return RedirectResponse*/public function destroy( int $id ): RedirectResponse{//$bu = Action::find( $id );$bu->delete();return redirect( "/backend/actions" );}}