added things
This commit is contained in:
8
20250130/13ingatlan/app/Http/Controllers/Controller.php
Normal file
8
20250130/13ingatlan/app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ingatlan;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class IngatlanController extends Controller
|
||||
{
|
||||
//
|
||||
|
||||
public function index(){
|
||||
$ingatlanlista = ingatlan::with('kategoria.nev')->get();
|
||||
|
||||
return response()->json($ingatlanlista->map(function($ingatlan){
|
||||
return [
|
||||
'id' => $ingatlan->id,
|
||||
'kategoria' => $ingatlan->kategoria->nev,
|
||||
'leiras' => $ingatlan->leiras,
|
||||
'hirdetesDatuma' => $ingatlan->hirdetesDatuma,
|
||||
'tehermentes' => $ingatlan->tehermentes,
|
||||
'ar' => $ingatlan->ar,
|
||||
'kepUrl' => $ingatlan->kepUrl
|
||||
];
|
||||
}), 200);
|
||||
}
|
||||
}
|
||||
18
20250130/13ingatlan/app/Models/ingatlan.php
Normal file
18
20250130/13ingatlan/app/Models/ingatlan.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ingatlan extends Model
|
||||
{
|
||||
//
|
||||
protected $fillable = ['kategoria', 'leiras', 'hirdetesDatuma', 'tehermentes', 'ar', 'kepUrl'];
|
||||
|
||||
protected $table = "ingatlanok";
|
||||
|
||||
public function kategoria(){
|
||||
return $this->belongsTo(kategoria::class,
|
||||
'kategoria');
|
||||
}
|
||||
}
|
||||
19
20250130/13ingatlan/app/Models/kategoria.php
Normal file
19
20250130/13ingatlan/app/Models/kategoria.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
class kategoria extends Model
|
||||
{
|
||||
//
|
||||
protected $fillable = ['nev'];
|
||||
|
||||
protected $table = "kategoriak";
|
||||
|
||||
public function ingatlanok(){
|
||||
return $this->hasMany(ingatlan::class,
|
||||
"kategoria");
|
||||
}
|
||||
}
|
||||
24
20250130/13ingatlan/app/Providers/AppServiceProvider.php
Normal file
24
20250130/13ingatlan/app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user