• 03-10-2022, 21:04:36
    #1
    Merhaba akdaşarlar. aşağıdaki kodda bu haftanın notlarını göstermesini nasıl sağlarım. yardımcı olabilr misinz?

    <?php
    use PsrHttpMessageServerRequestInterface as Request;
    use PsrHttpMessageResponseInterface as Response;

    ## App Config ##
    $app->get('/api/app_config', function (Request $request, Response $response, array $args) {
    $newResponse = $response->withHeader('Content-type', 'application/json');
    global $return_messages;

    $classes = array();
    $get_classes = DB::query( "SELECT * FROM app_config" );
    $config = null;
    foreach( $get_classes as $class ){
    $config = $class;
    $classes[] = $class;
    }
    if( empty($classes) ){
    mk_json( 1, $config, 2);
    }else{
    mk_json( 2, $config, 2);
    }
    return $newResponse;
    });

    ## List Classes ##
    $app->get('/api/list/classes', function (Request $request, Response $response, array $args) {
    $newResponse = $response->withHeader('Content-type', 'application/json');
    global $return_messages;

    $classes = array();
    $get_classes = DB::query( "SELECT * FROM classes" );
    foreach( $get_classes as $class ){
    $classes[] = $class;
    }
    if( empty($classes) ){
    mk_json( 1, $classes, 2);
    }else{
    mk_json( 2, $classes, 2);
    }
    return $newResponse;
    });

    ## List Lessons ##
    $app->get('/api/list/lessons/{class:[0-9]+}', function (Request $request, Response $response, array $args) {
    $newResponse = $response->withHeader('Content-type', 'application/json');
    global $return_messages;

    $class_id = intval($args['class']);
    $lessons = array();
    $get_lessons = DB::query( "SELECT * FROM lessons WHERE class_id = $class_id" );

    foreach( $get_lessons as $lesson ){
    $lessons[] = $lesson;
    }

    if( empty($lessons) ){
    mk_json( 1, $lessons, 2);
    }else{
    mk_json( 2, $lessons, 2);
    }


    return $newResponse;
    });

    ## List Lessons ##
    $app->get('/api/list/notess/{lesson:[0-9]+}', function (Request $request, Response $response, array $args) {
    $newResponse = $response->withHeader('Content-type', 'application/json');
    global $return_messages;

    $lesson_id= intval($args['lesson']);
    $notes = array();
    $year = date(Y);
    //$get_week_index = getVar( "SELECT " )
    $get_notes = DB::query( "SELECT * FROM lesson_notes WHERE lesson_id = $lesson_id order BY lesson_year ASC" );

    foreach( $get_notes as $note ){
    $note_week_start = getStartAndEndDate($note->lesson_week, $note->lesson_year)['week_start'];
    $note_week_start_usa = getStartAndEndDate($note->lesson_week, $note->lesson_year)['week_start_usa'];
    $note_week_end = getStartAndEndDate($note->lesson_week, $note->lesson_year)['week_end'];
    $getMonth = getMonthFromWeek($note->lesson_week);
    $getWeekOfMonth = weekOfMonth($note_week_start_usa);
    $getWeekOfMonth= ( $getWeekOfMonth == '-47' ? 0 : $getWeekOfMonth );

    $notes[] = array(
    'lesson_note' => $note->lesson_note,
    'lesson_week_of_month' => '',
    'lesson_week' => $note->lesson_week,
    'note_week_start' => $note_week_start,
    'note_week_end' => $note_week_end,
    );
    }

    if( empty($notes) ){
    mk_json( 1, $notes, 2);
    }else{
    mk_json( 2, $notes, 2);
    }


    return $newResponse;
    });


    ## List Lessons ##
    $app->get('/api/list/notes/{lesson:[0-9]+}', function (Request $request, Response $response, array $args) {
    $newResponse = $response->withHeader('Content-type', 'application/json');
    global $return_messages;

    $lesson_id= intval($args['lesson']);
    $notes = array();
    $get_notes = DB::query( "SELECT weeks.id as lesson_week, DATE_FORMAT(weeks.date, "%d-%m-%Y") as note_week_start, notes.id as id , notes.lesson_note, notes.lesson_id , DATE_FORMAT(DATE_ADD(weeks.date, INTERVAL 5 DAY), "%d-%m-%Y") as note_week_end FROM weeks INNER JOIN notes ON weeks.id=notes.lesson_week WHERE notes.lesson_id = $lesson_id ORDER BY weeks.id ASC" );


    foreach( $get_notes as $note ){
    $notes[] = $note;
    }

    if( empty($notes) ){
    mk_json( 1, $notes, 2);
    }else{
    mk_json( 2, $notes, 2);
    }


    return $newResponse;
    });
  • 04-10-2022, 00:46:48
    #2
    Konuyu yanlış yere açmışsınız. Burada yardım eden çıkar mı bilmem. @Report;
  • 04-10-2022, 07:01:04
    #3
    bana ücretli veya ücretsiz yardım eden olabilir diye buraya açmıştım. ama yanlış yere açmışsam konuyu lütfen doğru yere taşıyabilir miyiz? @Report;