impact-blue / laravel-job-posting
Easily add job posting structured data to your job posts.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: ^7.1.3
- illuminate/view: ^5.7
Requires (Dev)
- laravel/framework: ^5.7
- phpstan/phpstan: ^0.10.5
- phpunit/phpunit: ^7.4
This package is auto-updated.
Last update: 2022-09-26 11:54:17 UTC
README
laravel-job-posting
Easily add job posting structured data to your job posts.
Introduction
Google is bringing their job search experience to more and more countries, and with that comes the need to have properly structured job posting data.
This package supplies the JobPosting
facade, allowing you to easily add properly structured json-ld job postings to any blade template using {!! JobPosting::render($job) !!}
.
Installation
You may use Composer to install laravel-job-posting into your Laravel project:
composer require impact-blue/laravel-job-posting
After installing laravel-job-posting, publish its config usinfg the vendor:publish Artisan command:
php artisan vendor:publish
Configuration
After publishing laravel-job-posting's config its primary configuration file will be located at config/job-posting.php. This configuration file allows you to configure what data to use for the required properties described here: https://developers.google.com/search/docs/data-types/job-posting
You may use any model attributes available in the model passed to {!! JobPosting::render($job) !!}
.
If the defined string is not a model attribute the defined string will be used as is.
If you plan on defining a required property using the second parameter of the render function (see below) you may set the property to false
in the configuration file and it will be skipped during the property check.
Optional properties
The configuration file only defines Google's required properties, but you are free to add any optional (or required) properties using a collection or array as the second parameter to the render function. The data in the second parameter will be merged with whatever data was defined in the configuration file.
For example:
#!php
<?php
$job = Job::first();
$optionalProperties = [
'baseSalary' => [
'@type' => 'MonetaryAmount',
'currency' => 'JPY',
'value' => [
'@type' => 'QuantitativeValue',
'unitText' => 'HOUR',
'value' => $job->salary,
],
];
And in your blade file:
#!blade
{!! JobPosting::render($job, $optionalProperties) !!}
License
laravel-job-posting is open-sourced software licensed under the MIT license.