added things
This commit is contained in:
33
20250217/F2Ingatlan/app/Models/Ingatlan.php
Normal file
33
20250217/F2Ingatlan/app/Models/Ingatlan.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Ingatlan extends Model
|
||||
{
|
||||
//use HashFactory;
|
||||
protected $table='ingatlanok';
|
||||
protected $fillable = ['kategoria', 'leiras', 'hirdetesDatuma', 'tehermentes', 'ar', 'kepUrl'] ;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function kategoriak(){
|
||||
return $this->belongsTo(Kategoria::class, 'kategoria');
|
||||
}
|
||||
|
||||
public static function getAllWithCategory(){
|
||||
return self::with('kategoriak:id,nev')->get()->map(function ($ingatlan){
|
||||
return [
|
||||
'id' => $ingatlan->id,
|
||||
'kategoria' => $ingatlan->kategoriak->nev ?? null,
|
||||
'leiras' => $ingatlan->leiras,
|
||||
'hirdetesDatuma' => $ingatlan->hirdetesDatuma,
|
||||
'tehermentes' => $ingatlan->tehermentes,
|
||||
'ar' => $ingatlan->ar,
|
||||
'kepUrl' => $ingatlan->kepUrl,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user