- Can I use Laravel Eloquent models with Google BigQuery using this package?
- Yes, this package fully supports Eloquent models for BigQuery. You can define models with a `bigquery` connection and specify tables in the format `dataset.table`. Custom casts handle BigQuery-specific data types like BYTES, TIMESTAMP, and STRUCT for seamless serialization.
- How do I configure the package for a specific dataset in BigQuery?
- Configure the `bigquery` connection in your Laravel `config/database.php` with the required `dataset` and `keyFilePath` (service account JSON). You can also dynamically switch datasets using the facade: `BigQuery::dataset('analytics')->...` or by specifying `dataset.table` in Eloquent models.
- Does this package support write operations like INSERT, UPDATE, or DELETE in BigQuery?
- Write operations are partially supported. Basic queries work, but complex updates or deletes may require manual SQL or explicit WHERE clauses. BigQuery’s serverless nature lacks traditional ACID transactions, so critical writes might need external validation or batch processing.
- What Laravel versions are compatible with pelfox/laravel-bigquery?
- The package is designed for modern Laravel versions (8.x–10.x). Check the [GitHub repository](https://github.com/pelfox8/laravel-bigquery) for the latest compatibility notes. Ensure your Laravel version aligns with the package’s PHP requirements (8.0+).
- How do I handle BigQuery-specific data types like TIMESTAMP or STRUCT in Eloquent?
- Use the provided Eloquent casts (e.g., `AsTimestamp`, `AsStruct`) in your model’s `$casts` array. For STRUCT types, pass a method returning the schema array (e.g., `'field' => AsStruct::class . ':0,getSchemaForFieldColumn'`). Repeated fields require appending `:1` to the cast class name.
- Can I test this package locally without a live BigQuery connection?
- No, this package requires a live BigQuery connection for all operations. Mocking or offline testing isn’t supported, so you’ll need a test dataset in BigQuery or use a staging environment. Consider using Google Cloud’s free tier for development.
- What are the performance considerations for querying BigQuery via Laravel?
- Performance depends on BigQuery’s slot reservations, network latency, and query optimization. The package caches connections to reduce overhead, but complex queries may benefit from partitioning/clustering tables. Monitor BigQuery’s pricing and slot usage to avoid cost overruns.
- How do I secure Google Cloud credentials for this package?
- Store your service account JSON key file securely (e.g., Laravel’s `.env` or a secrets manager like HashiCorp Vault). Avoid hardcoding credentials in configuration files. Use Google Cloud IAM roles to restrict permissions to only what’s necessary for your application.
- Are there alternatives to this package for Laravel + BigQuery integration?
- Alternatives include raw Google Cloud client libraries (e.g., `google/cloud-bigquery`) or third-party packages like `spatie/laravel-bigquery`. However, this package offers native Laravel integration with Eloquent and Query Builder, reducing boilerplate for read-heavy analytics workloads.
- How do I handle schema changes in BigQuery with Laravel migrations?
- BigQuery lacks native migration support. Use external tools like Terraform, custom scripts, or raw SQL to manage schema changes. The package doesn’t provide migration generators, so schema updates must be handled separately from Laravel’s migration system.