Skip to content

Commit

Permalink
update container component
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Sep 10, 2023
1 parent 91a6383 commit ca2bfd5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions resources/views/components/container.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<x-slot:header>
{{$label}}
</x-slot:header>
<x-slot:buttons>
{{ $buttons ?? '' }}
</x-slot:buttons>
<div class="bg-white p-6 rounded-xl border ">
<x-splade-modal class="font-main">
<x-slot:title>
Expand Down
2 changes: 1 addition & 1 deletion src/Facade/Tomato.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @method \Illuminate\Http\JsonResponse json(Request $request, string $model, array $data=[],bool|int $paginate=false, ?Builder $query=null,array $filters = [])
* @method \Illuminate\View\View create(string $view, array $data=[])
* @method \Illuminate\View\View edit(string $view, string $model, array $data=[])
* @method \Illuminate\View\View|\Illuminate\Http\JsonResponse get(Model $model, string $view, array $data = [], bool $hasMedia = false, array $collection = [], array $attach = [], ?bool $api = true)
* @method \Illuminate\View\View|\Illuminate\Http\JsonResponse get(Model $model, string $view, array $data = [], bool $hasMedia = false, array $collection = [], array $attach = [], ?bool $api = true, ?string $resource = null,?Builder $query=null)
* @method TomatoResponse|\Illuminate\Http\JsonResponse store(Request $request, string $model,?array $validation = [], ?string $message="Record Updated Success", ?string $redirect=null, ?bool $hasMedia=false, ?array $collection=[], ?bool $api=true): TomatoResponse|JsonResponse
* @method TomatoResponse|\Illuminate\Http\JsonResponse update(\Illuminate\Http\Request $request, string $model,Request $request,Model $model,?array $validation = [],?string $message="Record Updated Success",?string $validationError="Validation Error",?string $redirect=null,?bool $hasMedia=false,?array $collection=[],?bool $api=true): TomatoResponse|JsonResponse
* @method TomatoResponse|\Illuminate\Http\JsonResponse destroy(Model $model,string $message,string $redirect,?bool $hasMedia=false,?array $collection=[],?bool $api=true)
Expand Down
16 changes: 13 additions & 3 deletions src/Services/TomatoRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ public function get(
bool $hasMedia=false,
array $collection=[],
array $attach = [],
?bool $api=true
?bool $api=true,
?string $resource=null,
?Builder $query=null,
): View|JsonResponse
{
$isAPIRequest = Str::contains('splade', \Route::current()->gatherMiddleware());
Expand All @@ -231,8 +233,12 @@ public function get(

unset($model->media);
if($api && (!$isAPIRequest)){
$response = $model;
if($resource){
$response = $resource::collection($response);
}
return ApiResponse::data(
data: $model,
data: $response,
message: "Record Fetched Success"
);
}
Expand All @@ -244,8 +250,12 @@ public function get(
}

if($api && (!$isAPIRequest)){
$response = $model;
if($resource){
$response = $resource::collection($response);
}
return ApiResponse::data(
data: $model,
data: $response,
message: "Record Fetched Success"
);
}
Expand Down

0 comments on commit ca2bfd5

Please sign in to comment.