It is posible a query for my data?

Posted 8 months ago by joseluisac

Hi, Good night.

I have a doubt with a query.

I have this tables

Schema::create('patients', function (Blueprint $table) {
            $table->bigIncrements('id'); // Example 12
            $table->string('name',100); //Example Jonh Con
            $table->date('birthDate');  // Example 2018-01-01 
        });
schema::create('consultations', function (Blueprint $table) {
            $table->bigIncrements('id'); // Example 2
     $table->bigInteger('patient_id'); //Example 12             
    $table->date('date');  // Example 2018-09-01 

            //More Columns
        });
    }
 Schema::create('anthropometries', function (Blueprint $table) {
            $table->bigIncrements('id'); // Example 2
            $table->bigInteger('consultation_id')->unsigned(); // Example 2
            $table->double('height'); //Example 50 
            $table->string('mHeight'); // Example kg
        //More Columns
        });

My model Consultation

public function anthropometries()
    {
        return $this->hasOne('App\Models\Anthropometries','consultation_id');
    }

Is there some query for get data of anthropometries with average for months ? Example

{
    Juanary : {
        height:50,
    }
    February:{
        height:51,
    }
    etc...
}

PD: there is a query from the date of birth?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.