Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/light-it-labs/laravel-google-jobs
Google Job Posting integration for Laravel
https://github.com/light-it-labs/laravel-google-jobs
google-api google-job-discovery google-job-posting google-jobs json laravel laravel6 laravel7 seo seo-optimization
Last synced: 3 months ago
JSON representation
Google Job Posting integration for Laravel
- Host: GitHub
- URL: https://github.com/light-it-labs/laravel-google-jobs
- Owner: Light-it-labs
- License: mit
- Created: 2020-01-24T17:05:28.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-27T13:57:12.000Z (about 1 year ago)
- Last Synced: 2024-10-11T11:04:54.594Z (3 months ago)
- Topics: google-api, google-job-discovery, google-job-posting, google-jobs, json, laravel, laravel6, laravel7, seo, seo-optimization
- Language: PHP
- Homepage:
- Size: 48.8 KB
- Stars: 11
- Watchers: 5
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Google Job Posting Metadata Generator
[![Build Status](https://travis-ci.com/Light-it-labs/laravel-google-jobs.svg?branch=master)](https://travis-ci.com/Light-it-labs/laravel-google-jobs)This package allows you to generate the required metadata for Google Jobs Announcements in a easy and Laravel way.
## Installation
You can install this package via composer
`composer require lightit/laravel-google-jobs`The service provider will be auto discovered and then automatically added to your providers array.
## Usage
Laravel Google Jobs provides two different ways of json generation:1) You can use the `GJob` facade available at:
`Lightit\LaravelGoogleJobs\Facades` namespace2) You can use Laravel's dependency injection system. From your class constructor, inject the `GJobContract`. This will return a singleton instance
of `Lightit\LaravelGoogleJobs\GJob` class.```php
use Lightit\LaravelGoogleJobs\Contracts\GJobContract;class JobOfferController extends Controller
{
/* @var GjobContract */
private $gjob;public function __construct(GJobContract $gjob)
{
// $this->gjob is now a GJob class singleton instance
$this->gjob = $gjob;
}}
```## Available API
Google Job Posting allows a specific set of fields for your jobs. Check: https://developers.google.com/search/docs/data-types/job-posting for more information.Some of these fields are required, and others are optional. This package will help you through the
process of generating and validating all this data properly, so you don't have to care about the formatting or the definitions of the JSON.#### Methods
`$this->gjob->fields(array $parameters): GJob`This method adds all `array $parameters` into your current instance and performs data validations.
If one of the required parameters is missing from the array a`Lightit\LaravelGoogleJobs\Exceptions\FieldsValidationsException` will be thrown specifying the missing required fields.-----
`$this->gjob->withOptionals(array $parameters): GJob`
As the name says, this method adds all `array $parameters` into your current instance, performing data validations. Only format validations are performed over these fields.
-----
`$this->gjob->generate(): string`
Generates the proper JSON format and validates all the instance parameters.
## Example
```php
public function show(Request $request, $id)
{
// Lets say we want to allow google to render our job offer// Cool! Is time to do some magic with this package, we are going to use the Facade for this example
// All You have to do is create an array like this one.
// We strongly recomend the use of a model accessor in order to avoid duplicated code and provide one single source of truth for your job offer array representation
$jobArray = [
'datePosted' => '...',
'text' => '...',
'hiringOrganization' => [
'@type' => '...',
'name' => '...',
'sameAs' => '...',
'logo' => '...'
],
'jobLocation' => [
'@type' => '...',
'streetAddress'=> '...',
'addressLocality'=> '...',
'addressRegion'=> '...',
'postalCode'=> '...',
'addressCountry'=> '...'
],
'title' => '...',
'validThrough' => '...'
];// Add your array into the singleton instance
GJob::fields($jobArray);return view('details');
}
```Now, all you have to do is call to the `generate()` method directly on your view before you close the `