Change DB tables (remove temperature) (add sensors and readings Models Controllers and migrations) (and respect reallationships)
This commit is contained in:
32
app/Models/Sensor.php
Normal file
32
app/Models/Sensor.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Sensor extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'status',
|
||||
'longitude',
|
||||
'latitude',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\User');
|
||||
}
|
||||
|
||||
public function readings()
|
||||
{
|
||||
return $this->hasMany('App\Models\Reading');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user