Skip to content

Commit

Permalink
Laravel 11.x upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacarpet committed Apr 3, 2024
1 parent 38ede21 commit 751164b
Show file tree
Hide file tree
Showing 37 changed files with 153 additions and 204 deletions.
8 changes: 5 additions & 3 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<?php

declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = PhpCsFixer\Finder::create()
$finder = Finder::create()
->ignoreDotFiles(false)
->ignoreVCSIgnored(true)
->in(__DIR__)
;

$config = new PhpCsFixer\Config();
$config = new Config();
$config
->setRiskyAllowed(true)
->setRules([
'@PHP81Migration' => true,
'@PHP83Migration' => true,
'@PHP80Migration:risky' => true,
'heredoc_indentation' => false,
'@PhpCsFixer' => true,
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MIT License

Copyright (c) 2021 Arafat Islam
2022 Samuel Melrose <sam.melrose@a1comms.com>
2022 Samuel Melrose <sam.melrose@AffordableMobiles.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Laravel Eloquent for Google Datastore

![Latest Stable Version](https://poser.pugx.org/a1comms/eloquent-datastore/v)
![License](https://poser.pugx.org/a1comms/eloquent-datastore/license)
![Latest Stable Version](https://poser.pugx.org/AffordableMobiles/eloquent-datastore/v)
![License](https://poser.pugx.org/AffordableMobiles/eloquent-datastore/license)

A package for using Google Datastore as a database driver.

Expand All @@ -15,7 +15,7 @@ By using this package, you can use `query builder` and `eloquent` to access data
You can install the package via composer:

```bash
composer require a1comms/eloquent-datastore
composer require affordablemobiles/eloquent-datastore
```

If you are using Laravel Package Auto-Discovery, you don't need you to manually add the ServiceProvider.
Expand All @@ -25,7 +25,7 @@ If you are using Laravel Package Auto-Discovery, you don't need you to manually
If you don't use auto-discovery, add the below ServiceProvider to the `$providers` array in `config/app.php` file.

```php
A1comms\EloquentDatastore\DatastoreServiceProvider::class,
AffordableMobiles\EloquentDatastore\DatastoreServiceProvider::class,
```

## Roadmap
Expand Down Expand Up @@ -59,15 +59,15 @@ You need to add `datastore` connection in `config/database.php` file.

### Access using Eloquent Model

You need to extend `A1comms\EloquentDatastore\Eloquent\Model` class instead of Laravel's default Eloquent model class.
You need to extend `AffordableMobiles\EloquentDatastore\Eloquent\Model` class instead of Laravel's default Eloquent model class.

**Example-**
```php
<?php

namespace App\Models;

use A1comms\EloquentDatastore\Eloquent\Model;
use AffordableMobiles\EloquentDatastore\Eloquent\Model;

class Project extends Model
{
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
{
"name": "a1comms/eloquent-datastore",
"name": "affordablemobiles/eloquent-datastore",
"description": "A package for using Google Datastore as a database driver.",
"type": "package",
"license": "MIT",
"keywords": ["laravel datastore", "eloquent datastore", "datastore", "google datastore"],
"authors": [
{
"name": "Samuel Melrose",
"email": "sam.melrose@a1comms.com"
"email": "sam.melrose@affordablemobilels.co.uk"
},
{
"name": "Appsero",
"email": "help@appsero.com"
}
],
"require": {
"php": "^8.1",
"php": "^8.3",
"ext-json": "*",
"illuminate/support": "^9",
"illuminate/pagination": "^9",
"illuminate/database": "^9",
"illuminate/http": "^9",
"google/cloud-datastore": "^1.13.3",
"rennokki/laravel-eloquent-query-cache": "~3"
"illuminate/support": "~11",
"illuminate/pagination": "~11",
"illuminate/database": "~11",
"illuminate/http": "~11",
"google/cloud-datastore": "^1.28.0",
"affordablemobiles/laravel-eloquent-query-cache": "~11"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^10",
"friendsofphp/php-cs-fixer": "^3.6"
},
"autoload": {
"psr-4": {
"A1comms\\EloquentDatastore\\": "src/"
"AffordableMobiles\\EloquentDatastore\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"A1comms\\EloquentDatastore\\Tests\\": "tests/"
"AffordableMobiles\\EloquentDatastore\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"A1comms\\EloquentDatastore\\DatastoreServiceProvider"
"AffordableMobiles\\EloquentDatastore\\DatastoreServiceProvider"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/Http/Controllers/DMLQueryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Http\Controllers;

use A1comms\EloquentDatastore\Eloquent\Collection;
use AffordableMobiles\EloquentDatastore\Eloquent\Collection;
use App\Models\People;
use Illuminate\Support\Facades\DB;

Expand Down
4 changes: 2 additions & 2 deletions examples/Http/Controllers/Named/QueryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function chunk(): void

// Process all records returned by a query using a closure,
// in pages / chunks, specifying a chunk size of 2 entities at a time.
People::where('last_name', 'Melrose')->chunk(self::CHUNK_SIZE, function ($results, $page) use (&$arr): void {
People::where('last_name', 'Melrose')->chunk(self::CHUNK_SIZE, static function ($results, $page) use (&$arr): void {
foreach ($results as $result) {
$arr[] = [
'first_name' => $result->first_name,
Expand All @@ -154,7 +154,7 @@ public function each(): void
// Process all records returned by a query using a closure,
// fetched from the DB as chunks of 2 entities at a time,
// handled by our closure one record at a time.
People::where('last_name', 'Melrose')->each(function ($result) use (&$arr): void {
People::where('last_name', 'Melrose')->each(static function ($result) use (&$arr): void {
$arr[] = [
'first_name' => $result->first_name,
'last_name' => $result->last_name,
Expand Down
4 changes: 2 additions & 2 deletions examples/Http/Controllers/QueryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function chunk(): void

// Process all records returned by a query using a closure,
// in pages / chunks, specifying a chunk size of 2 entities at a time.
People::where('last_name', 'Melrose')->chunk(self::CHUNK_SIZE, function ($results, $page) use (&$arr): void {
People::where('last_name', 'Melrose')->chunk(self::CHUNK_SIZE, static function ($results, $page) use (&$arr): void {
foreach ($results as $result) {
$arr[] = [
'first_name' => $result->first_name,
Expand All @@ -153,7 +153,7 @@ public function each(): void
// Process all records returned by a query using a closure,
// fetched from the DB as chunks of 2 entities at a time,
// handled by our closure one record at a time.
People::where('last_name', 'Melrose')->each(function ($result) use (&$arr): void {
People::where('last_name', 'Melrose')->each(static function ($result) use (&$arr): void {
$arr[] = [
'first_name' => $result->first_name,
'last_name' => $result->last_name,
Expand Down
2 changes: 1 addition & 1 deletion examples/Models/Basket.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Models;

use A1comms\EloquentDatastore\Eloquent\Model;
use AffordableMobiles\EloquentDatastore\Eloquent\Model;

class Basket extends Model
{
Expand Down
2 changes: 1 addition & 1 deletion examples/Models/BasketCached.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Models;

use A1comms\EloquentDatastore\Eloquent\Model;
use AffordableMobiles\EloquentDatastore\Eloquent\Model;

class BasketCached extends Model
{
Expand Down
2 changes: 1 addition & 1 deletion examples/Models/Named/Basket.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Models\Named;

use A1comms\EloquentDatastore\Eloquent\Model;
use AffordableMobiles\EloquentDatastore\Eloquent\Model;

class Basket extends Model
{
Expand Down
2 changes: 1 addition & 1 deletion examples/Models/Named/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Models\Named;

use A1comms\EloquentDatastore\Eloquent\Model;
use AffordableMobiles\EloquentDatastore\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\AsArrayObject;

class Order extends Model
Expand Down
2 changes: 1 addition & 1 deletion examples/Models/Named/People.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Models\Named;

use A1comms\EloquentDatastore\Eloquent\Model;
use AffordableMobiles\EloquentDatastore\Eloquent\Model;

class People extends Model
{
Expand Down
2 changes: 1 addition & 1 deletion examples/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Models;

use A1comms\EloquentDatastore\Eloquent\Model;
use AffordableMobiles\EloquentDatastore\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\AsArrayObject;

class Order extends Model
Expand Down
2 changes: 1 addition & 1 deletion examples/Models/People.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Models;

use A1comms\EloquentDatastore\Eloquent\Model;
use AffordableMobiles\EloquentDatastore\Eloquent\Model;

class People extends Model
{
Expand Down
17 changes: 8 additions & 9 deletions src/Client/DatastoreClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

declare(strict_types=1);

namespace A1comms\EloquentDatastore\Client;
namespace AffordableMobiles\EloquentDatastore\Client;

use DomainException;
use Google\Cloud\Datastore\DatastoreClient as BaseDatastoreClient;
use Google\Cloud\Datastore\EntityInterface;
use Google\Cloud\Datastore\Key;
Expand Down Expand Up @@ -34,7 +33,7 @@ class DatastoreClient extends BaseDatastoreClient
*
* @return Key
*
* @throws DomainException if a conflict occurs, fail
* @throws \DomainException if a conflict occurs, fail
*/
public function insert(EntityInterface $entity, array $options = [])
{
Expand Down Expand Up @@ -103,19 +102,19 @@ public function insertBatch(array $entities, array $options = [])
* @param array $options [optional] {
* Configuration Options
*
* @var bool $allowOverwrite Entities must be updated as an entire
* @var bool $allowOverwrite Entities must be updated as an entire
* resource. Patch operations are not supported. Because entities
* can be created manually, or obtained by a lookup or query, it
* is possible to accidentally overwrite an existing record with a
* new one when manually creating an entity. To provide additional
* safety, this flag must be set to `true` in order to update a
* record when the entity provided was not obtained through a
* lookup or query. **Defaults to** `false`.
* }
* }
*
* @return Key
*
* @throws DomainException if a conflict occurs, fail
* @throws \DomainException if a conflict occurs, fail
*/
public function update(EntityInterface $entity, array $options = [])
{
Expand Down Expand Up @@ -146,15 +145,15 @@ public function update(EntityInterface $entity, array $options = [])
* @param array $options [optional] {
* Configuration Options
*
* @var bool $allowOverwrite Entities must be updated as an entire
* @var bool $allowOverwrite Entities must be updated as an entire
* resource. Patch operations are not supported. Because entities
* can be created manually, or obtained by a lookup or query, it
* is possible to accidentally overwrite an existing record with a
* new one when manually creating an entity. To provide additional
* safety, this flag must be set to `true` in order to update a
* record when the entity provided was not obtained through a
* lookup or query. **Defaults to** `false`.
* }
* }
*
* @return Key[]
*/
Expand Down Expand Up @@ -196,7 +195,7 @@ public function updateBatch(array $entities, array $options = [])
*
* @return Key The entity key
*
* @throws DomainException if a conflict occurs, fail
* @throws \DomainException if a conflict occurs, fail
*/
public function upsert(EntityInterface $entity, array $options = [])
{
Expand Down
7 changes: 3 additions & 4 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

declare(strict_types=1);

namespace A1comms\EloquentDatastore;
namespace AffordableMobiles\EloquentDatastore;

use Illuminate\Support\Collection as BaseCollection;
use Illuminate\Support\Facades\DB;
use LogicException;

class Collection extends BaseCollection
{
Expand All @@ -26,9 +25,9 @@ public function hasNextItems()
*/
public function delete()
{
$this->each(function ($item): void {
$this->each(static function ($item): void {
if (empty($item->__key__)) {
throw new LogicException('Unable to create query for collection with mixed types.');
throw new \LogicException('Unable to create query for collection with mixed types.');
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/Concerns/BuildsQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace A1comms\EloquentDatastore\Concerns;
namespace AffordableMobiles\EloquentDatastore\Concerns;

use Illuminate\Support\LazyCollection;

Expand Down Expand Up @@ -51,7 +51,7 @@ public function chunk($count, callable $callback): bool
*
* @param int $chunkSize
*
* @return \Illuminate\Support\LazyCollection
* @return LazyCollection
*
* @throws \InvalidArgumentException
*/
Expand Down
Loading

0 comments on commit 751164b

Please sign in to comment.