# Hooks

he resource class has a lot of hooks to handle the data on every method.

### Index Hooks

```php
public function beforeIndex(Request $request): Request
{
    return $request;
}
```

```php
public function beforeIndexQuery($query, Request $request, array $rows): void {}
```

```php
public function beforeIndexQueryAPI($query, Request $request,array $rows): void {}
```

```php
public function afterIndexQuery($query, Request $request, array $rows): void {}
```

```php
public function afterIndexQueryAPI($query, Request $request, array $rows): void {}
```

```php
public function beforeIndexAPI(Request $request): Request 
```

```php
{
   return $request;
}
```

```php
public function afterIndex(LengthAwarePaginator $data,Request $request): void {}
```

```php
public function afterIndexAPI(LengthAwarePaginator $data,Request $request): void {}
```

### Store Hooks

```php
public function beforeStore(Request $request): Request
{
   return $request;
}
```

```php
public function beforeStoreAPI(Request $request): Request
```

```php
{
   return $request;
}
```

```php
public function afterStore(Request $request, $record): void {}
```

```php
public function afterStoreAPI(Request $request, $record): void {}
```

### Show Hooks

```php
public function beforeShow(Request $request, $record)
{
   return $record;
}
```

```php
public function beforeShowQuery($query, Request $request, array $rows): void {}
```

```php
public function beforeShowQueryAPI($query, Request $request,array $rows): void {}
```

```php
public function afterShowQuery($record, Request $request, array $rows): void {}
```

```php
public function afterShowQueryAPI($record, Request $request, array $rows): void {}
```

```php
public function beforeShowAPI(Request $request, $record)
{
   return $record;
}
```

```php
public function afterShow(Request $request, $record): void {}
```

```php
public function afterShowAPI(Request $request, $record): void {}
```

### Update Hooks

```php
public function beforeUpdate(Request $request, $record): Request
{
   return $request;
}
```

```
public function beforeUpdateAPI(Request $request, $record): Request
```

```php
{
   return $request;
}
```

```php
public function afterUpdate(Request $request, $record): void {}
```

```
public function afterUpdateAPI(Request $request, $record): void {}
```

### Destroy Hooks

```php
public function afterDestroy(Request $request, $id): void {}
```

```php
public function beforeDestroy(Request $request, $record): Request
{
   return $request;
}
```

### Bulk Hooks

```php
public function beforeBulk(Request $request): Request
{
   return $request;
}
```

```php
public function afterBulk(Request $request): void {}
```

### Export Hooks

```php
public function beforeExport(Request $request, $record): Request
{
   return $request;
}
```

```php
public function afterExport(Request $request, $record): void {}
```

### Import Hooks

```php
public function beforeImport(Request $request, $record): Request
{
   return $request;
}
```

```php
public function afterImport(Request $request, $record): void {}
```
