added things
This commit is contained in:
8
20250217/F2Ingatlan/app/Http/Controllers/Controller.php
Normal file
8
20250217/F2Ingatlan/app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Ingatlan;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class IngatlanController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse{
|
||||
return response()->json(Ingatlan::getAllWithCategory(), 200);
|
||||
}
|
||||
}
|
||||
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,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
15
20250217/F2Ingatlan/app/Models/Kategoria.php
Normal file
15
20250217/F2Ingatlan/app/Models/Kategoria.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Kategoria extends Model
|
||||
{
|
||||
protected $table='kategoriak';
|
||||
protected $fillable = ['nev'] ;
|
||||
|
||||
public function ingatlanok(){
|
||||
return $this->hasMany(Ingatlan::class, 'kategoria');
|
||||
}
|
||||
}
|
||||
48
20250217/F2Ingatlan/app/Models/User.php
Normal file
48
20250217/F2Ingatlan/app/Models/User.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
24
20250217/F2Ingatlan/app/Providers/AppServiceProvider.php
Normal file
24
20250217/F2Ingatlan/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