Skip to content

Commit

Permalink
Merge pull request #56 from kiwilan/develop
Browse files Browse the repository at this point in the history
Add Laravel 11 support
  • Loading branch information
ewilan-riviere authored Mar 16, 2024
2 parents 0cb5fae + 747ae66 commit 040b180
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 59 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ lib/types
.env.testing
*.tgz
CHANGELOG-draft.md
.phpunit.cache
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ docker run --name postgresql \

To install SQL Server with Docker

> [!WARNING]
>
> If you have an error like this: "An invalid attribute was designated on the PDO object", you have to update `msphpsql` driver. Check <https://github.com/laravel/framework/issues/47937> for more information.
```bash
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=12345OHdf%e" \
-p 1433:1433 \
Expand All @@ -236,17 +240,13 @@ docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=12345OHdf%e" \
mcr.microsoft.com/mssql/server:2022-latest
```

> [!WARNING]
>
> If you have an error like this: "An invalid attribute was designated on the PDO object", you have to update `msphpsql` driver. Check <https://github.com/laravel/framework/issues/47937> for more information.
## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Credits

- [Spatie](https://github.com/spatie/package-skeleton-laravel): for spatie/package-skeleton-laravel
- [Spatie](https://github.com/spatie): for [`spatie/package-skeleton-laravel`](https://github.com/spatie/package-skeleton-laravel)
- [Ewilan Riviere](https://github.com/ewilan-riviere): Author package

## License
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kiwilan/typescriptable-laravel",
"description": "PHP package for Laravel to type Eloquent models, routes, Spatie Settings with autogenerated TypeScript. If you want to use some helpers with Inertia, you can install associated NPM package.",
"version": "1.11.40",
"version": "1.12.0",
"keywords": [
"kiwilan",
"laravel",
Expand All @@ -27,9 +27,9 @@
"require": {
"php": "^8.1",
"doctrine/dbal": "^3.5",
"illuminate/contracts": "^9.0 || ^10.0",
"illuminate/database": "^9.0 || ^10.0",
"illuminate/support": "^9.0 || ^10.0",
"illuminate/contracts": "^9.0 || ^10.0 || ^11.0",
"illuminate/database": "^9.0 || ^10.0 || ^11.0",
"illuminate/support": "^9.0 || ^10.0 || ^11.0",
"spatie/laravel-package-tools": "^1.14.0"
},
"require-dev": {
Expand Down
8 changes: 4 additions & 4 deletions lib/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kiwilan/typescriptable-laravel",
"type": "module",
"version": "2.4.1",
"version": "2.4.25",
"description": "Add some helpers for your Inertia app with TypeScript.",
"author": "Ewilan Rivière <ewilan.riviere@gmail.com>",
"license": "MIT",
Expand Down Expand Up @@ -66,13 +66,13 @@
"vue": "^3.x.x"
},
"peerDependenciesMeta": {
"vite": {
"laravel-vite-plugin": {
"optional": true
},
"vue": {
"vite": {
"optional": true
},
"laravel-vite-plugin": {
"vue": {
"optional": true
}
},
Expand Down
2 changes: 0 additions & 2 deletions lib/src/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useDate } from './useDate'
import { useFetch } from './useFetch'
import { useInertia } from './useInertia'
import { useLazy } from './useLazy'
import { usePaginate } from './usePaginate'
import { usePagination } from './usePagination'
import { useQuery } from './useQuery'
import { useRouter } from './useRouter'
Expand All @@ -17,7 +16,6 @@ export {
useFetch,
useInertia,
useLazy,
usePaginate,
usePagination,
useQuery,
useRouter,
Expand Down
34 changes: 0 additions & 34 deletions lib/src/composables/usePaginate.ts

This file was deleted.

24 changes: 23 additions & 1 deletion lib/src/composables/usePagination.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref } from 'vue'
import { computed, ref } from 'vue'

interface PaginateLink extends App.PaginateLink {
isLink?: boolean
Expand Down Expand Up @@ -111,9 +111,31 @@ export function usePagination(models: App.Paginate) {

paginate()

function convertUrl(queryName: string, queryValue: number | string) {
let currentUrl = window.location.href
if (currentUrl.includes(`${queryName}=`))
currentUrl = currentUrl.replace(/page=\d+/, `${queryName}=${queryValue}`)
else if (currentUrl.includes('?'))
currentUrl += `&${queryName}=${queryValue}`
else
currentUrl += `?${queryName}=${queryValue}`

return currentUrl
}

const nextPageLink = computed((): string => {
return convertUrl('page', models.current_page + 1)
})

const previousPageLink = computed((): string => {
return convertUrl('page', models.current_page - 1)
})

return {
pages,
previousPage,
nextPage,
nextPageLink,
previousPageLink,
}
}
3 changes: 3 additions & 0 deletions lib/src/composables/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ export interface SortItem {
}

const current = ref<Query>()
const total = ref<number>()
const isCleared = ref<boolean>(false)
const sort = ref<string>()
const limit = ref<number>(10)
const isReversed = ref(false)

export function useQuery<T>(propQuery: App.Paginate<T>, prop: string = 'query') {
current.value = propQuery
total.value = propQuery.total
sort.value = current.value.sort
limit.value = current.value.per_page

Expand Down Expand Up @@ -172,6 +174,7 @@ export function useQuery<T>(propQuery: App.Paginate<T>, prop: string = 'query')

return {
request: current,
total,
clear,
sortBy,
sortReverse,
Expand Down
1 change: 0 additions & 1 deletion lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export {
useFetch,
useInertia,
useLazy,
usePaginate,
usePagination,
useQuery,
useRouter,
Expand Down
12 changes: 6 additions & 6 deletions lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext", "DOM"],
"jsx": "preserve",
"lib": ["ESNext", "DOM"],
"module": "ES2020",
"moduleResolution": "Node",
"paths": {
Expand All @@ -11,14 +11,14 @@
"~": ["./"],
"~/*": ["./*"]
},
"typeRoots": ["./node_modules/@types", "./*.d.ts"],
"resolveJsonModule": true,
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"typeRoots": ["./node_modules/@types", "./*.d.ts"],
"strict": true,
"strictNullChecks": true,
"noImplicitAny": false
"noImplicitAny": false,
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true
},
"include": [
"src",
Expand Down
2 changes: 1 addition & 1 deletion lib/type-routes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare namespace App.Route {

export type Method = 'HEAD' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
export type Param = string | number | boolean | undefined
export interface Link { name: App.Route.Name; path: App.Route.Path; params?: App.Route.Params[App.Route.Name]; methods: App.Route.Method[] }
export interface Link { name: App.Route.Name, path: App.Route.Path, params?: App.Route.Params[App.Route.Name], methods: App.Route.Method[] }
export interface RouteConfig<T extends App.Route.Name> {
name: T
params?: T extends keyof App.Route.Params ? App.Route.Params[T] : never
Expand Down
2 changes: 1 addition & 1 deletion lib/types-inertia-global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare module 'vue' {
$to: <T extends App.Route.Name>(route: App.Route.RouteConfig<T>) => string
// @ts-expect-error - Routes is defined in the global scope
$page: Inertia.Page
sessions: { agent: { is_desktop: boolean; browser: string; platform: string }; ip_address: string; is_current_device: boolean; last_active: string }[]
sessions: { agent: { is_desktop: boolean, browser: string, platform: string }, ip_address: string, is_current_device: boolean, last_active: string }[]
}
export interface GlobalComponents {
Head: typeof import('@inertiajs/vue3').Head
Expand Down

0 comments on commit 040b180

Please sign in to comment.