|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Http\Controllers\Api\v1; |
| 4 | + |
| 5 | +use App\Http\Controllers\Controller; |
| 6 | +use App\Http\Requests\v1\StorePropertyRequest; |
| 7 | +use App\Http\Requests\v1\UpdatePropertyRequest; |
| 8 | +use Spatie\QueryBuilder\QueryBuilder; |
| 9 | +use App\Models\Property; |
| 10 | +use App\Http\Resources\v1\PropertyResource; |
| 11 | +use Illuminate\Http\Response; |
| 12 | + |
| 13 | +class PropertyController extends Controller |
| 14 | +{ |
| 15 | + /** |
| 16 | + * Display a listing of the resource. |
| 17 | + */ |
| 18 | + public function index() |
| 19 | + { |
| 20 | + $properties = QueryBuilder::for(Property::class) |
| 21 | + ->allowedFields([ |
| 22 | + 'id', |
| 23 | + 'name', |
| 24 | + 'slug', |
| 25 | + 'owner_id', |
| 26 | + 'status_id', |
| 27 | + 'created_at', |
| 28 | + 'updated_at', |
| 29 | + 'owner.id', |
| 30 | + 'owner.name', |
| 31 | + 'status.id', |
| 32 | + 'status.name', |
| 33 | + 'address.id', |
| 34 | + 'address.city_id', |
| 35 | + 'address.address_line', |
| 36 | + ]) |
| 37 | + ->defaultSort('-created_at') |
| 38 | + ->allowedIncludes(['owner', 'status', 'address', 'address.city', 'address.city.country']) |
| 39 | + ->paginate() |
| 40 | + ->appends(request()->query()); |
| 41 | + |
| 42 | + return PropertyResource::collection($properties)->response()->setStatusCode(Response::HTTP_OK); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Store a newly created resource in storage. |
| 47 | + */ |
| 48 | + public function store(StorePropertyRequest $request) |
| 49 | + { |
| 50 | + // |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Display the specified resource. |
| 55 | + */ |
| 56 | + public function show(Property $property) |
| 57 | + { |
| 58 | + // |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Update the specified resource in storage. |
| 63 | + */ |
| 64 | + public function update(UpdatePropertyRequest $request, Property $property) |
| 65 | + { |
| 66 | + // |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Remove the specified resource from storage. |
| 71 | + */ |
| 72 | + public function destroy(Property $property) |
| 73 | + { |
| 74 | + // |
| 75 | + } |
| 76 | +} |
0 commit comments