├── .editorconfig ├── .env.example ├── .gitattributes ├── .gitignore ├── README.md ├── app ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── RegisterController.php │ │ │ └── ResetPasswordController.php │ │ └── Controller.php │ ├── Kernel.php │ ├── Middleware │ │ ├── ConnectToPrismic.php │ │ ├── EncryptCookies.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ └── VerifyCsrfToken.php │ └── ViewComposers │ │ └── PrismicComposer.php ├── LinkResolver.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ ├── PrismicServiceProvider.php │ └── RouteServiceProvider.php └── User.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── database.php ├── filesystems.php ├── hashing.php ├── logging.php ├── mail.php ├── prismic.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ └── 2014_10_12_100000_create_password_resets_table.php └── seeds │ └── DatabaseSeeder.php ├── docs ├── 01-getting-started │ ├── 01-starting-from-scratch.md │ └── 02-integrating-with-existing-project.md ├── 02-query-the-api │ ├── 01-how-to-query-the-api.md │ ├── 02-query-predicate-reference.md │ ├── 03-date-and-time-based-predicate-reference.md │ ├── 04-query-options-reference.md │ ├── 05-query-helper-functions.md │ ├── 06-query-single-type.md │ ├── 07-query-by-id-or-uid.md │ ├── 08-query-all-documents.md │ ├── 09-query-by-type.md │ ├── 10-query-by-tag.md │ ├── 11-query-by-date.md │ ├── 12-query-by-a-field.md │ ├── 13-query-by-content-relationship.md │ ├── 14-fulltext-search.md │ ├── 15-use-multiple-predicates.md │ ├── 16-fetch-linked-items.md │ ├── 17-order-your-results.md │ ├── 18-pagination-for-results.md │ └── 19-query-by-language.md ├── 03-templating │ ├── 01-the-response-object.md │ ├── 02-the-document-object.md │ ├── 03-boolean.md │ ├── 04-color.md │ ├── 05-date.md │ ├── 06-embed.md │ ├── 07-geopoint.md │ ├── 08-group.md │ ├── 09-images.md │ ├── 10-key-text.md │ ├── 11-links-and-content-relationship.md │ ├── 12-multi-language-info.md │ ├── 13-number.md │ ├── 14-rich-text-and-title.md │ ├── 15-select.md │ ├── 16-slices.md │ ├── 17-timestamp.md │ └── 18-uid.md ├── 04-beyond-the-api │ ├── 01-link-resolving.md │ ├── 02-previews-and-the-prismic-toolbar.md │ └── 03-html-serializer.md └── README.md ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── css │ └── tutorial.min.css ├── img │ ├── arrow.svg │ ├── bb.gif │ ├── open.svg │ ├── punch.png │ └── rocket.svg ├── index.php ├── mix-manifest.json └── robots.txt ├── resources ├── assets │ ├── js │ │ ├── app.js │ │ ├── bootstrap.js │ │ └── components │ │ │ └── ExampleComponent.vue │ └── sass │ │ ├── _variables.scss │ │ └── app.scss ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php └── views │ ├── 404.blade.php │ ├── layouts │ └── app.blade.php │ └── tutorial.blade.php ├── routes ├── api.php ├── channels.php ├── console.php └── web.php ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore └── framework │ ├── .gitignore │ ├── cache │ └── .gitignore │ ├── sessions │ └── .gitignore │ ├── testing │ └── .gitignore │ └── views │ └── .gitignore ├── tests ├── CreatesApplication.php ├── Feature │ └── ExampleTest.php ├── TestCase.php └── Unit │ └── ExampleTest.php └── webpack.mix.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=homestead 13 | DB_USERNAME=homestead 14 | DB_PASSWORD=secret 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | SESSION_DRIVER=file 19 | SESSION_LIFETIME=120 20 | QUEUE_DRIVER=sync 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_DRIVER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | 33 | PUSHER_APP_ID= 34 | PUSHER_APP_KEY= 35 | PUSHER_APP_SECRET= 36 | PUSHER_APP_CLUSTER=mt1 37 | 38 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 39 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 40 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel starter 2 | 3 | This is a blank [Laravel](https://laravel.com) project that will connect to any prismic.io repository. It uses the prismic.io PHP development kit, and provides a few helpers to integrate with a Laravel website. 4 | 5 | ## Getting started 6 | 7 | ### Launch the starter project 8 | 9 | _(Assuming you've [installed Laravel](https://laravel.com/docs/5.5/installation))_ 10 | 11 | Fork this repository, then clone your fork, and run this in your newly created directory: 12 | 13 | ```bash 14 | composer install 15 | ``` 16 | 17 | Next you need to make a copy of the `.env.example` file and rename it to `.env` inside your project root. 18 | 19 | Run the following command to generate your app key: 20 | 21 | ``` 22 | php artisan key:generate 23 | ``` 24 | 25 | Then start your server: 26 | 27 | ``` 28 | php artisan serve 29 | ``` 30 | 31 | Your Laravel starter project is now up and running! 32 | 33 | ### Configure the starter project 34 | 35 | Edit the `config/prismic.php` prismic configuration file to get the application connected to the correct repository: 36 | 37 | ``` 38 | 'url' => 'https://your-repo-name.prismic.io/api/v2', 39 | ``` 40 | 41 | You may have to restart your server. 42 | 43 | ### Create your routes and pages 44 | 45 | When the project is first launched and viewed, it will by default display a help page. Here you will find some documentation to help you get started with your Laravel project. 46 | 47 | It includes an example that shows how to create a route and query a document of the custom type "page". It then shows how to integrate the content into the Laravel templates. 48 | 49 | Check it out to get a better understanding of how you would create your own routes and templates for your project. You can also explore our documentation to learn more about how to [query the API](./docs/02-query-the-api/01-how-to-query-the-api.md) and how to integrate content fields like [Rich Text](./docs/03-templating/14-rich-text-and-title.md), [Images](./docs/03-templating/09-images.md), and more. 50 | 51 | ## Deploying your Laravel application 52 | 53 | Once you've created your website, an easy way to deploy your Laravel application is to use [Heroku](http://www.heroku.com). Just follow these few simple steps once you have successfully [signed up](https://id.heroku.com/signup/www-header) and [installed the Heroku toolbelt](https://toolbelt.heroku.com/): 54 | 55 | Create a new Heroku application 56 | 57 | ``` 58 | $ heroku create 59 | ``` 60 | 61 | Initialize a new Git repository: 62 | 63 | ``` 64 | $ git init 65 | $ heroku git:remote -a your-heroku-app-name 66 | ``` 67 | 68 | Commit your code to the Git repository if you haven't already: 69 | 70 | ``` 71 | $ git add . 72 | $ git commit -am "make it better" 73 | ``` 74 | 75 | Set a Laravel encryption key: 76 | 77 | ``` 78 | $ heroku config:set APP_KEY=$(php artisan --no-ansi key:generate --show) 79 | ``` 80 | 81 | Push to Heroku: 82 | 83 | ``` 84 | $ git push heroku master 85 | ``` 86 | 87 | You can now browse your application online: 88 | 89 | ``` 90 | $ heroku open 91 | ``` 92 | 93 | You can read more about launching your project with Heroku here in their [Laravel & Heroku guide](https://devcenter.heroku.com/articles/getting-started-with-laravel). 94 | 95 | ## Learn more about prismic.io 96 | 97 | If you are looking for more resources to learn more about prismic.io, you can find out [how to get started with prismic.io](https://prismic.io/docs) and learn more by exploring [our full documentation](./docs). 98 | 99 | ### Understand the PHP development kit 100 | 101 | You'll find more information about how to use the development kit included in this starter project, by reading its README file and exploring its project files on GitHub [prismic/php-kit](https://github.com/prismicio/php-kit). 102 | 103 | ## Licence 104 | 105 | This software is licensed under the Apache 2 license, quoted below. 106 | 107 | Copyright 2018 Prismic.io (https://prismic.io). 108 | 109 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. 110 | 111 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 112 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | $this->load(__DIR__.'/Commands'); 39 | 40 | require base_path('routes/console.php'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 41 | } 42 | 43 | /** 44 | * Get a validator for an incoming registration request. 45 | * 46 | * @param array $data 47 | * @return \Illuminate\Contracts\Validation\Validator 48 | */ 49 | protected function validator(array $data) 50 | { 51 | return Validator::make($data, [ 52 | 'name' => 'required|string|max:255', 53 | 'email' => 'required|string|email|max:255|unique:users', 54 | 'password' => 'required|string|min:6|confirmed', 55 | ]); 56 | } 57 | 58 | /** 59 | * Create a new user instance after a valid registration. 60 | * 61 | * @param array $data 62 | * @return \App\User 63 | */ 64 | protected function create(array $data) 65 | { 66 | return User::create([ 67 | 'name' => $data['name'], 68 | 'email' => $data['email'], 69 | 'password' => Hash::make($data['password']), 70 | ]); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | [ 32 | \App\Http\Middleware\EncryptCookies::class, 33 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 34 | \Illuminate\Session\Middleware\StartSession::class, 35 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 36 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 37 | \App\Http\Middleware\VerifyCsrfToken::class, 38 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 39 | ], 40 | 41 | 'api' => [ 42 | 'throttle:60,1', 43 | 'bindings', 44 | ], 45 | ]; 46 | 47 | /** 48 | * The application's route middleware. 49 | * 50 | * These middleware may be assigned to groups or used individually. 51 | * 52 | * @var array 53 | */ 54 | protected $routeMiddleware = [ 55 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 56 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 57 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 58 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 59 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 60 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 61 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 62 | ]; 63 | } 64 | -------------------------------------------------------------------------------- /app/Http/Middleware/ConnectToPrismic.php: -------------------------------------------------------------------------------- 1 | attributes->set('endpoint', config('prismic.url')); 22 | 23 | // Define the link resolver 24 | $request->attributes->set('linkResolver', new LinkResolver()); 25 | 26 | // Connect to the prismic.io repository 27 | if (config('prismic.url') !== 'https://your-repo-name.prismic.io/api/v2') { 28 | $request->attributes->set('api', Api::get(config('prismic.url'), config('prismic.token'))); 29 | } 30 | 31 | // Return the request 32 | return $next($request); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | endpoint = $request->attributes->get('endpoint'); 20 | 21 | // Define the link resolver 22 | $this->linkResolver = $request->attributes->get('linkResolver'); 23 | } 24 | 25 | /** 26 | * Bind the link resolver and the menu content to the view. 27 | * 28 | * @param View $view 29 | * @return void 30 | */ 31 | public function compose(View $view) 32 | { 33 | $view->with('endpoint', $this->endpoint); 34 | $view->with('linkResolver', $this->linkResolver); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/LinkResolver.php: -------------------------------------------------------------------------------- 1 | type === 'page') { 27 | return '/page/' . $link->uid; 28 | } 29 | 30 | // Default case returns the homepage 31 | return '/'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'App\Listeners\EventListener', 18 | ], 19 | ]; 20 | 21 | /** 22 | * Register any events for your application. 23 | * 24 | * @return void 25 | */ 26 | public function boot() 27 | { 28 | parent::boot(); 29 | 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Providers/PrismicServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 39 | 40 | $this->mapWebRoutes(); 41 | 42 | // 43 | } 44 | 45 | /** 46 | * Define the "web" routes for the application. 47 | * 48 | * These routes all receive session state, CSRF protection, etc. 49 | * 50 | * @return void 51 | */ 52 | protected function mapWebRoutes() 53 | { 54 | Route::middleware('web') 55 | ->namespace($this->namespace) 56 | ->group(base_path('routes/web.php')); 57 | } 58 | 59 | /** 60 | * Define the "api" routes for the application. 61 | * 62 | * These routes are typically stateless. 63 | * 64 | * @return void 65 | */ 66 | protected function mapApiRoutes() 67 | { 68 | Route::prefix('api') 69 | ->middleware('api') 70 | ->namespace($this->namespace) 71 | ->group(base_path('routes/api.php')); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/User.php: -------------------------------------------------------------------------------- 1 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "type": "project", 7 | "require": { 8 | "php": ">=7.1.3", 9 | "fideloper/proxy": "~4.0", 10 | "laravel/framework": "5.7.*", 11 | "laravel/tinker": "~1.0", 12 | "prismic/php-sdk": "5.0.1" 13 | }, 14 | "require-dev": { 15 | "filp/whoops": "~2.0", 16 | "fzaninotto/faker": "~1.4", 17 | "mockery/mockery": "~1.0", 18 | "nunomaduro/collision": "~2.0", 19 | "phpunit/phpunit": "~7.0", 20 | "symfony/thanks": "^1.0" 21 | }, 22 | "autoload": { 23 | "classmap": [ 24 | "database/seeds", 25 | "database/factories" 26 | ], 27 | "psr-4": { 28 | "App\\": "app/" 29 | } 30 | }, 31 | "autoload-dev": { 32 | "psr-4": { 33 | "Tests\\": "tests/" 34 | } 35 | }, 36 | "extra": { 37 | "laravel": { 38 | "dont-discover": [ 39 | ] 40 | } 41 | }, 42 | "scripts": { 43 | "post-root-package-install": [ 44 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 45 | ], 46 | "post-create-project-cmd": [ 47 | "@php artisan key:generate" 48 | ], 49 | "post-autoload-dump": [ 50 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 51 | "@php artisan package:discover" 52 | ] 53 | }, 54 | "config": { 55 | "preferred-install": "dist", 56 | "sort-packages": true, 57 | "optimize-autoloader": true 58 | }, 59 | "minimum-stability": "dev", 60 | "prefer-stable": true 61 | } 62 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'users' => [ 69 | 'driver' => 'eloquent', 70 | 'model' => App\User::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | You may specify multiple password reset configurations if you have more 85 | | than one user table or model in the application and you want to have 86 | | separate password reset settings based on the specific user types. 87 | | 88 | | The expire time is the number of minutes that the reset token should be 89 | | considered valid. This security feature keeps tokens short-lived so 90 | | they have less time to be guessed. You may change this as needed. 91 | | 92 | */ 93 | 94 | 'passwords' => [ 95 | 'users' => [ 96 | 'provider' => 'users', 97 | 'table' => 'password_resets', 98 | 'expire' => 60, 99 | ], 100 | ], 101 | 102 | ]; 103 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | // 40 | ], 41 | ], 42 | 43 | 'redis' => [ 44 | 'driver' => 'redis', 45 | 'connection' => 'default', 46 | ], 47 | 48 | 'log' => [ 49 | 'driver' => 'log', 50 | ], 51 | 52 | 'null' => [ 53 | 'driver' => 'null', 54 | ], 55 | 56 | ], 57 | 58 | ]; 59 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | */ 30 | 31 | 'stores' => [ 32 | 33 | 'apc' => [ 34 | 'driver' => 'apc', 35 | ], 36 | 37 | 'array' => [ 38 | 'driver' => 'array', 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'table' => 'cache', 44 | 'connection' => null, 45 | ], 46 | 47 | 'file' => [ 48 | 'driver' => 'file', 49 | 'path' => storage_path('framework/cache/data'), 50 | ], 51 | 52 | 'memcached' => [ 53 | 'driver' => 'memcached', 54 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 55 | 'sasl' => [ 56 | env('MEMCACHED_USERNAME'), 57 | env('MEMCACHED_PASSWORD'), 58 | ], 59 | 'options' => [ 60 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 61 | ], 62 | 'servers' => [ 63 | [ 64 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 65 | 'port' => env('MEMCACHED_PORT', 11211), 66 | 'weight' => 100, 67 | ], 68 | ], 69 | ], 70 | 71 | 'redis' => [ 72 | 'driver' => 'redis', 73 | 'connection' => 'default', 74 | ], 75 | 76 | ], 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Cache Key Prefix 81 | |-------------------------------------------------------------------------- 82 | | 83 | | When utilizing a RAM based store such as APC or Memcached, there might 84 | | be other applications utilizing the same cache. So, we'll specify a 85 | | value to get prefixed to all our keys so we can avoid collisions. 86 | | 87 | */ 88 | 89 | 'prefix' => env( 90 | 'CACHE_PREFIX', 91 | str_slug(env('APP_NAME', 'laravel'), '_').'_cache' 92 | ), 93 | 94 | ]; 95 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Database Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here are each of the database connections setup for your application. 24 | | Of course, examples of configuring each database platform that is 25 | | supported by Laravel is shown below to make development simple. 26 | | 27 | | 28 | | All database work in Laravel is done through the PHP PDO facilities 29 | | so make sure you have the driver for your particular database of 30 | | choice installed on your machine before you begin development. 31 | | 32 | */ 33 | 34 | 'connections' => [ 35 | 36 | 'sqlite' => [ 37 | 'driver' => 'sqlite', 38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 39 | 'prefix' => '', 40 | ], 41 | 42 | 'mysql' => [ 43 | 'driver' => 'mysql', 44 | 'host' => env('DB_HOST', '127.0.0.1'), 45 | 'port' => env('DB_PORT', '3306'), 46 | 'database' => env('DB_DATABASE', 'forge'), 47 | 'username' => env('DB_USERNAME', 'forge'), 48 | 'password' => env('DB_PASSWORD', ''), 49 | 'unix_socket' => env('DB_SOCKET', ''), 50 | 'charset' => 'utf8mb4', 51 | 'collation' => 'utf8mb4_unicode_ci', 52 | 'prefix' => '', 53 | 'strict' => true, 54 | 'engine' => null, 55 | ], 56 | 57 | 'pgsql' => [ 58 | 'driver' => 'pgsql', 59 | 'host' => env('DB_HOST', '127.0.0.1'), 60 | 'port' => env('DB_PORT', '5432'), 61 | 'database' => env('DB_DATABASE', 'forge'), 62 | 'username' => env('DB_USERNAME', 'forge'), 63 | 'password' => env('DB_PASSWORD', ''), 64 | 'charset' => 'utf8', 65 | 'prefix' => '', 66 | 'schema' => 'public', 67 | 'sslmode' => 'prefer', 68 | ], 69 | 70 | 'sqlsrv' => [ 71 | 'driver' => 'sqlsrv', 72 | 'host' => env('DB_HOST', 'localhost'), 73 | 'port' => env('DB_PORT', '1433'), 74 | 'database' => env('DB_DATABASE', 'forge'), 75 | 'username' => env('DB_USERNAME', 'forge'), 76 | 'password' => env('DB_PASSWORD', ''), 77 | 'charset' => 'utf8', 78 | 'prefix' => '', 79 | ], 80 | 81 | ], 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Migration Repository Table 86 | |-------------------------------------------------------------------------- 87 | | 88 | | This table keeps track of all the migrations that have already run for 89 | | your application. Using this information, we can determine which of 90 | | the migrations on disk haven't actually been run in the database. 91 | | 92 | */ 93 | 94 | 'migrations' => 'migrations', 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Redis Databases 99 | |-------------------------------------------------------------------------- 100 | | 101 | | Redis is an open source, fast, and advanced key-value store that also 102 | | provides a richer set of commands than a typical key-value systems 103 | | such as APC or Memcached. Laravel makes it easy to dig right in. 104 | | 105 | */ 106 | 107 | 'redis' => [ 108 | 109 | 'client' => 'predis', 110 | 111 | 'default' => [ 112 | 'host' => env('REDIS_HOST', '127.0.0.1'), 113 | 'password' => env('REDIS_PASSWORD', null), 114 | 'port' => env('REDIS_PORT', 6379), 115 | 'database' => 0, 116 | ], 117 | 118 | ], 119 | 120 | ]; 121 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "s3", "rackspace" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 's3' => [ 59 | 'driver' => 's3', 60 | 'key' => env('AWS_ACCESS_KEY_ID'), 61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 62 | 'region' => env('AWS_DEFAULT_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | 'url' => env('AWS_URL'), 65 | ], 66 | 67 | ], 68 | 69 | ]; 70 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | ]; 21 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Log Channels 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the log channels for your application. Out of 24 | | the box, Laravel uses the Monolog PHP logging library. This gives 25 | | you a variety of powerful log handlers / formatters to utilize. 26 | | 27 | | Available Drivers: "single", "daily", "slack", "syslog", 28 | | "errorlog", "custom", "stack" 29 | | 30 | */ 31 | 32 | 'channels' => [ 33 | 'stack' => [ 34 | 'driver' => 'stack', 35 | 'channels' => ['single'], 36 | ], 37 | 38 | 'single' => [ 39 | 'driver' => 'single', 40 | 'path' => storage_path('logs/laravel.log'), 41 | 'level' => 'debug', 42 | ], 43 | 44 | 'daily' => [ 45 | 'driver' => 'daily', 46 | 'path' => storage_path('logs/laravel.log'), 47 | 'level' => 'debug', 48 | 'days' => 7, 49 | ], 50 | 51 | 'slack' => [ 52 | 'driver' => 'slack', 53 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 54 | 'username' => 'Laravel Log', 55 | 'emoji' => ':boom:', 56 | 'level' => 'critical', 57 | ], 58 | 59 | 'syslog' => [ 60 | 'driver' => 'syslog', 61 | 'level' => 'debug', 62 | ], 63 | 64 | 'errorlog' => [ 65 | 'driver' => 'errorlog', 66 | 'level' => 'debug', 67 | ], 68 | ], 69 | 70 | ]; 71 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | SMTP Host Address 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may provide the host address of the SMTP server used by your 27 | | applications. A default option is provided that is compatible with 28 | | the Mailgun mail service which will provide reliable deliveries. 29 | | 30 | */ 31 | 32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | SMTP Host Port 37 | |-------------------------------------------------------------------------- 38 | | 39 | | This is the SMTP port used by your application to deliver e-mails to 40 | | users of the application. Like the host we have set this value to 41 | | stay compatible with the Mailgun e-mail application by default. 42 | | 43 | */ 44 | 45 | 'port' => env('MAIL_PORT', 587), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Global "From" Address 50 | |-------------------------------------------------------------------------- 51 | | 52 | | You may wish for all e-mails sent by your application to be sent from 53 | | the same address. Here, you may specify a name and address that is 54 | | used globally for all e-mails that are sent by your application. 55 | | 56 | */ 57 | 58 | 'from' => [ 59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 60 | 'name' => env('MAIL_FROM_NAME', 'Example'), 61 | ], 62 | 63 | /* 64 | |-------------------------------------------------------------------------- 65 | | E-Mail Encryption Protocol 66 | |-------------------------------------------------------------------------- 67 | | 68 | | Here you may specify the encryption protocol that should be used when 69 | | the application send e-mail messages. A sensible default using the 70 | | transport layer security protocol should provide great security. 71 | | 72 | */ 73 | 74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | SMTP Server Username 79 | |-------------------------------------------------------------------------- 80 | | 81 | | If your SMTP server requires a username for authentication, you should 82 | | set it here. This will get used to authenticate with your server on 83 | | connection. You may also set the "password" value below this one. 84 | | 85 | */ 86 | 87 | 'username' => env('MAIL_USERNAME'), 88 | 89 | 'password' => env('MAIL_PASSWORD'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Sendmail System Path 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using the "sendmail" driver to send e-mails, we will need to know 97 | | the path to where Sendmail lives on this server. A default path has 98 | | been provided here, which will work well on most of your systems. 99 | | 100 | */ 101 | 102 | 'sendmail' => '/usr/sbin/sendmail -bs', 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Markdown Mail Settings 107 | |-------------------------------------------------------------------------- 108 | | 109 | | If you are using Markdown based email rendering, you may configure your 110 | | theme and component paths here, allowing you to customize the design 111 | | of the emails. Or, you may simply stick with the Laravel defaults! 112 | | 113 | */ 114 | 115 | 'markdown' => [ 116 | 'theme' => 'default', 117 | 118 | 'paths' => [ 119 | resource_path('views/vendor/mail'), 120 | ], 121 | ], 122 | 123 | ]; 124 | -------------------------------------------------------------------------------- /config/prismic.php: -------------------------------------------------------------------------------- 1 | 'https://your-repo-name.prismic.io/api/v2', 16 | 17 | /* 18 | |-------------------------------------------------------------------------- 19 | | prismic.io API Access Token 20 | |-------------------------------------------------------------------------- 21 | | 22 | | Here you can specify your API Access Token if you are using a private API. 23 | | If you are not using a private API, then leave this configuration set to 24 | | the default value of null. 25 | | 26 | */ 27 | 28 | 'token' => null, 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_DRIVER', 'sync'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | ], 50 | 51 | 'sqs' => [ 52 | 'driver' => 'sqs', 53 | 'key' => 'your-public-key', 54 | 'secret' => 'your-secret-key', 55 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', 56 | 'queue' => 'your-queue-name', 57 | 'region' => 'us-east-1', 58 | ], 59 | 60 | 'redis' => [ 61 | 'driver' => 'redis', 62 | 'connection' => 'default', 63 | 'queue' => 'default', 64 | 'retry_after' => 90, 65 | 'block_for' => null, 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Failed Queue Jobs 73 | |-------------------------------------------------------------------------- 74 | | 75 | | These options configure the behavior of failed queue job logging so you 76 | | can control which database and table are used to store the jobs that 77 | | have failed. You may change them to any database / table you wish. 78 | | 79 | */ 80 | 81 | 'failed' => [ 82 | 'database' => env('DB_CONNECTION', 'mysql'), 83 | 'table' => 'failed_jobs', 84 | ], 85 | 86 | ]; 87 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'ses' => [ 23 | 'key' => env('SES_KEY'), 24 | 'secret' => env('SES_SECRET'), 25 | 'region' => 'us-east-1', 26 | ], 27 | 28 | 'sparkpost' => [ 29 | 'secret' => env('SPARKPOST_SECRET'), 30 | ], 31 | 32 | 'stripe' => [ 33 | 'model' => App\User::class, 34 | 'key' => env('STRIPE_KEY'), 35 | 'secret' => env('STRIPE_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => env('SESSION_LIFETIME', 120), 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session Encryption 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This option allows you to easily specify that all of your session data 42 | | should be encrypted before it is stored. All encryption will be run 43 | | automatically by Laravel and you can use the Session like normal. 44 | | 45 | */ 46 | 47 | 'encrypt' => false, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session File Location 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the native session driver, we need a location where session 55 | | files may be stored. A default has been set for you but a different 56 | | location may be specified. This is only needed for file sessions. 57 | | 58 | */ 59 | 60 | 'files' => storage_path('framework/sessions'), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Connection 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" or "redis" session drivers, you may specify a 68 | | connection that should be used to manage these sessions. This should 69 | | correspond to a connection in your database configuration options. 70 | | 71 | */ 72 | 73 | 'connection' => null, 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Database Table 78 | |-------------------------------------------------------------------------- 79 | | 80 | | When using the "database" session driver, you may specify the table we 81 | | should use to manage the sessions. Of course, a sensible default is 82 | | provided for you; however, you are free to change this as needed. 83 | | 84 | */ 85 | 86 | 'table' => 'sessions', 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Cache Store 91 | |-------------------------------------------------------------------------- 92 | | 93 | | When using the "apc" or "memcached" session drivers, you may specify a 94 | | cache store that should be used for these sessions. This value must 95 | | correspond with one of the application's configured cache stores. 96 | | 97 | */ 98 | 99 | 'store' => null, 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Sweeping Lottery 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Some session drivers must manually sweep their storage location to get 107 | | rid of old sessions from storage. Here are the chances that it will 108 | | happen on a given request. By default, the odds are 2 out of 100. 109 | | 110 | */ 111 | 112 | 'lottery' => [2, 100], 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Name 117 | |-------------------------------------------------------------------------- 118 | | 119 | | Here you may change the name of the cookie used to identify a session 120 | | instance by ID. The name specified here will get used every time a 121 | | new session cookie is created by the framework for every driver. 122 | | 123 | */ 124 | 125 | 'cookie' => env( 126 | 'SESSION_COOKIE', 127 | str_slug(env('APP_NAME', 'laravel'), '_').'_session' 128 | ), 129 | 130 | /* 131 | |-------------------------------------------------------------------------- 132 | | Session Cookie Path 133 | |-------------------------------------------------------------------------- 134 | | 135 | | The session cookie path determines the path for which the cookie will 136 | | be regarded as available. Typically, this will be the root path of 137 | | your application but you are free to change this when necessary. 138 | | 139 | */ 140 | 141 | 'path' => '/', 142 | 143 | /* 144 | |-------------------------------------------------------------------------- 145 | | Session Cookie Domain 146 | |-------------------------------------------------------------------------- 147 | | 148 | | Here you may change the domain of the cookie used to identify a session 149 | | in your application. This will determine which domains the cookie is 150 | | available to in your application. A sensible default has been set. 151 | | 152 | */ 153 | 154 | 'domain' => env('SESSION_DOMAIN', null), 155 | 156 | /* 157 | |-------------------------------------------------------------------------- 158 | | HTTPS Only Cookies 159 | |-------------------------------------------------------------------------- 160 | | 161 | | By setting this option to true, session cookies will only be sent back 162 | | to the server if the browser has a HTTPS connection. This will keep 163 | | the cookie from being sent to you if it can not be done securely. 164 | | 165 | */ 166 | 167 | 'secure' => env('SESSION_SECURE_COOKIE', false), 168 | 169 | /* 170 | |-------------------------------------------------------------------------- 171 | | HTTP Access Only 172 | |-------------------------------------------------------------------------- 173 | | 174 | | Setting this value to true will prevent JavaScript from accessing the 175 | | value of the cookie and the cookie will only be accessible through 176 | | the HTTP protocol. You are free to modify this option if needed. 177 | | 178 | */ 179 | 180 | 'http_only' => true, 181 | 182 | /* 183 | |-------------------------------------------------------------------------- 184 | | Same-Site Cookies 185 | |-------------------------------------------------------------------------- 186 | | 187 | | This option determines how your cookies behave when cross-site requests 188 | | take place, and can be used to mitigate CSRF attacks. By default, we 189 | | do not enable this as other CSRF protection services are in place. 190 | | 191 | | Supported: "lax", "strict" 192 | | 193 | */ 194 | 195 | 'same_site' => null, 196 | 197 | ]; 198 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(App\User::class, function (Faker $faker) { 17 | static $password; 18 | 19 | return [ 20 | 'name' => $faker->name, 21 | 'email' => $faker->unique()->safeEmail, 22 | 'password' => $password ?: $password = bcrypt('secret'), 23 | 'remember_token' => str_random(10), 24 | ]; 25 | }); 26 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->string('password'); 21 | $table->rememberToken(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('users'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /docs/01-getting-started/01-starting-from-scratch.md: -------------------------------------------------------------------------------- 1 | # Getting started 2 | 3 | Prismic makes it easy to get started on a new Laravel project by providing a specific Laravel starter project. 4 | 5 | ## Create a content repository 6 | 7 | A content repository is where you can define, edit, and publish your website content. 8 | 9 | [**Create a new repository**](https://prismic.io/dashboard/new-repository/) 10 | 11 | ## Download the Laravel Starter 12 | 13 | The starter kit allows you to query and retrieve content from your Prismic content repository and integrate it into your website templates. It's the easiest way to get started with a new project. 14 | 15 | [**Download the Starter**](https://github.com/prismicio/php-laravel-starter/archive/master.zip) 16 | 17 | Unzip the downloaded project files into the desired location for your new project. 18 | 19 | ## Configure your project 20 | 21 | Replace the repository URL in your Prismic configuration file (located at config/prismic.php) with your repository’s API endpoint: 22 | 23 | ``` 24 | // In config/prismic.php 25 | 'url' => 'https://your-repo-name.cdn.prismic.io/api/v2', 26 | ``` 27 | 28 | Fire up a terminal (command prompt or similar on Windows), point it to your project location and run the following commands! 29 | 30 | > Note that you will need to make sure to first have [Composer](https://getcomposer.org/) installed before running this command. Check out the [Composer Getting Started](https://getcomposer.org/doc/00-intro.md) page for installation instructions. You may also need to update the version of PHP on your computer to get the project working correctly. 31 | 32 | First you'll need to install the dependencies for the project. Run the following command: 33 | 34 | ```bash 35 | composer install 36 | ``` 37 | 38 | Next you need to make a copy of the .env.example file and rename it to .env inside your Laravel project root: 39 | 40 | ```bash 41 | cp .env.example .env 42 | ``` 43 | 44 | Then run the following command to generate your app key: 45 | 46 | ```bash 47 | php artisan key:generate 48 | ``` 49 | 50 | Now you can launch your local server: 51 | 52 | ```bash 53 | php artisan serve 54 | ``` 55 | 56 | You can now open your browser to [http://localhost:8000](http://localhost:8000), where you will find a tutorial page. This page contains information helpful to getting started. You will learn how to query the API and start building pages for your new site. 57 | 58 | > **Pagination of API Results** 59 | > 60 | > When querying a Prismic repository, your results will be paginated. By default, there are 20 documents per page in the results. You can read more about how to manipulate the pagination in the [Pagination for Results](../02-query-the-api/18-pagination-for-results.md) page. 61 | 62 | ## And your Prismic journey begins! 63 | 64 | Now you're all set to start building your new website with the Prismic content management system. Here are the next steps you need to take. 65 | 66 | ### Define your Custom Types 67 | 68 | First you will need to model your pages, blog posts, articles, etc. into different Custom Types. Refer to our documentation to learn more about [constructing your Custom Types](https://user-guides.prismic.io/content-modeling-and-custom-types/structure-your-content/introduction-to-custom-type-building) using our easy drag and drop builder. 69 | 70 | ### Query your documents 71 | 72 | After you have created and published some documents in your content repository, you will be able to query your API and retrieve the content. We provide explanations and plenty of examples of queries in the documentation. Start by learning more on the [How to Query the API](../02-query-the-api/01-how-to-query-the-api.md) page. 73 | 74 | ### Integrate content into your templates 75 | 76 | The final step will be to integrate your content into the website templates. Check out the [templating documentation](../03-templating/01-the-response-object.md) to learn how to integrate each content field type. 77 | -------------------------------------------------------------------------------- /docs/01-getting-started/02-integrating-with-existing-project.md: -------------------------------------------------------------------------------- 1 | # Integrating with an existing project 2 | 3 | If you already have an existing Laravel project that you want to integrate with Prismic, then you simply need to add the PHP Prismic development kit library as a dependency. Here we will show you all the steps needed to get Prismic integrated into your site. 4 | 5 | ## 1. Create a content repository 6 | 7 | A content repository is where you can define, edit, and publish your website content. 8 | 9 | [**Create a new repository**](https://prismic.io/dashboard/new-repository/) 10 | 11 | Next you will need to model your content, create your custom types, and publish some documents to your content repository. 12 | 13 | Now, let’s take a look at how to retrieve and integrate this new content with your project. 14 | 15 | ## 2. Add the PHP kit as a dependency 16 | 17 | Now let’s add the Prismic PHP kit as a dependency to your project. Launch the terminal (command prompt or similar on Windows), and point it to your project location. 18 | 19 | > Note that you will need to make sure to first have [Composer](https://getcomposer.org/) installed before running this command. Check out the [Composer Getting Started](https://getcomposer.org/doc/00-intro.md) page for installation instructions. 20 | 21 | Run the following command: 22 | 23 | ```bash 24 | composer require prismic/php-sdk 25 | ``` 26 | 27 | ## 3. Include the dependency 28 | 29 | To use the Prismic PHP library, you will need to include an instance of it. Simply add the following code: 30 | 31 | ``` 32 | query(Predicates::at('document.type', 'page')); 48 | ``` 49 | 50 | If you are using a private repository, then you’ll need to [generate an access token](https://intercom.help/prismicio/api-application-and-token-management/generating-an-access-token) and then include it like this: 51 | 52 | ``` 53 | query(Predicates::at('document.type', 'page')); 58 | ``` 59 | 60 | To learn more about querying the API, check out the [How to Query the API](../02-query-the-api/01-how-to-query-the-api.md) page. 61 | 62 | ### Pagination of API Results 63 | 64 | When querying a Prismic repository, your results will be paginated. By default, there are 20 documents per page in the results. You can read more about how to manipulate the pagination in the [Pagination for Results](../02-query-the-api/18-pagination-for-results.md) page. 65 | 66 | ## 5. Add the content to your templates 67 | 68 | Once you have retrieved your content, you can include the content in your template using the helper functions in the PHP development kit. Here is a simple example: 69 | 70 | ``` 71 | results[0]; 75 | ?> 76 | 77 |
78 |

{{ RichText::asText($document->data->title) }}

79 | {{ $document->data->image->alt }} 80 |
81 | {!! RichText::asHtml($document->data->description) !!} 82 |
83 |
84 | ``` 85 | 86 | You can read more about templating your content in the Templating section of the documentation. 87 | 88 | ## 6. Take advantage of Previews and the Prismic Toolbar 89 | 90 | In order to take advantage of all that Prismic has to offer, check out the [Previews and the Prismic Toolbar](../04-beyond-the-api/02-previews-and-the-prismic-toolbar.md) page to learn how to add these great features to your project! 91 | -------------------------------------------------------------------------------- /docs/02-query-the-api/01-how-to-query-the-api.md: -------------------------------------------------------------------------------- 1 | # How to Query the API 2 | 3 | In order to retrieve the content from your repository, you will need to query the repository API. When you create your query you will specify exactly what it is you are looking for. You could query the repository for all the documents of certain type or retrieve the one specific document you need. 4 | 5 | Let’s take a look at how to put together queries for whatever case you need. 6 | 7 | > Check out the [Integrating with an existing Laravel project](../01-getting-started/02-integrating-with-existing-project.md) page to learn how to get set up to query documents. 8 | 9 | ## The Basics 10 | 11 | In order to do any query, you'll first need to get the API object. 12 | 13 | ``` 14 | query( 29 | Predicates::at('document.type', 'blog-post'), 30 | [ 'orderings' => '[my.blog-post.date desc]' ] 31 | ); 32 | // $response contains the response object, $response->results holds the retrieved documents 33 | ``` 34 | 35 | This is the basic format of a query. In the query you have two parts, the Predicates and the Query Options. 36 | 37 | ### Predicates 38 | 39 | In the above example we had the following predicate. 40 | 41 | ``` 42 | Predicates::at('document.type', 'blog-post') 43 | ``` 44 | 45 | The predicate(s) will define which documents are retrieved from the content repository. This particular example will retrieve all of the documents of the type "blog-post". 46 | 47 | The first part, "document.type" is the **path**, or what the query will be looking for. The second part the predicate in the above example is "blog-post" this is the **value** that the query is looking for. 48 | 49 | You can combine more than one predicate together to refine your query. You just need to put all your predicates into a comma-separated array like the following example. 50 | 51 | ``` 52 | [ Predicates::at('document.type', 'blog-post'), 53 | Predicates::at('document.tags', ['featured']) ] 54 | ``` 55 | 56 | This particular query will retrieve all the documents of the "blog-post" type that also have the tag "featured". 57 | 58 | > You will find a list and description of all the available predicates on the [Query Predicates Reference](../02-query-the-api/02-query-predicate-reference.md) page. 59 | 60 | ### Options 61 | 62 | In the second part of the query, you can include the options needed for that query. In the above example we had the following option. 63 | 64 | ``` 65 | [ 'orderings' => '[my.blog-post.date desc]' ] 66 | ``` 67 | 68 | The above specifies how the returned list of documents will be ordered. You can include more than one option, by comma separating them as shown below. 69 | 70 | ``` 71 | [ 'pageSize' => 10, 'page' => 2 ] 72 | ``` 73 | 74 | > You will find a list and description of all the available options on the [Query Options Reference](../02-query-the-api/04-query-options-reference.md) page. 75 | 76 | > **Pagination of API Results** 77 | > 78 | > When querying a Prismic repository, your results will be paginated. By default, there are 20 documents per page in the results. You can read more about how to manipulate the pagination in the [Pagination for Results](../02-query-the-api/18-pagination-for-results.md) page. 79 | 80 | Here's another example of a more advanced query with multiple predicates and multiple options. 81 | 82 | ``` 83 | query( 85 | [ Predicates::at('document.type', 'blog-post'), 86 | Predicates::at('document.tags', ['featured']) ], 87 | [ 'pageSize' => 25, 'page' => 1, 'orderings' => '[my.blog-post.date desc]' ] 88 | ); 89 | // $response contains the response object, $response->results holds the retrieved documents 90 | ``` 91 | 92 | Whenever you query your content, you end up with the response object stored in the defined variable. In this case, the response object is stored in the `$response` variable. 93 | -------------------------------------------------------------------------------- /docs/02-query-the-api/04-query-options-reference.md: -------------------------------------------------------------------------------- 1 | # Query Options reference 2 | 3 | Here you will find a complete reference about the various query options. 4 | 5 | ## after 6 | 7 | The `after` option can be used along with the orderings option. It will remove all the documents except for those after the specified document in the list. 8 | 9 | To clarify, let’s say you have a query that return the following documents in this order: 10 | 11 | - `V9Zt3icAAAl8Uzob (Page 1)` 12 | - `PqZtvCcAALuRUzmO (Page 2)` 13 | - `VkRmhykAAFA6PoBj (Page 3)` 14 | - `V4Fs8rDbAAH9Pfow (Page 4)` 15 | - `G8ZtxQhAALuSix6R (Page 5)` 16 | - `Ww9yuAvdAhl87wh6 (Page 6)` 17 | 18 | If you add the `after` option and specify page 3, “`VkRmhykAAFA6PoBj`”, your query will return the following: 19 | 20 | - `V4Fs8rDbAAH9Pfow (Page 4)` 21 | - `G8ZtxQhAALuSix6R (Page 5)` 22 | - `Ww9yuAvdAhl87wh6 (Page 6)` 23 | 24 | By reversing the orderings in your query, you can use this same method to retrieve all the documents before the specified document. 25 | 26 | This option is useful when creating a navigation for a blog. 27 | 28 | ``` 29 | [ 'after' => 'VkRmhykAAFA6PoBj' ] 30 | ``` 31 | 32 | ## fetch 33 | 34 | The `fetch` option is used to make queries faster by only retrieving the specified field(s). 35 | 36 | To retrieve a single field, simply specify the field as shown below. 37 | 38 | ```css 39 | [ 'fetch' => 'product.title' ] 40 | ``` 41 | 42 | To retrieve more than one field, you just need to comma separate all the fields you wish included in the response. 43 | 44 | ```css 45 | [ 'fetch' => 'product.title, product.price'] 46 | ``` 47 | 48 | ## fetchLinks 49 | 50 | The `fetchLinks` option allows you to retrieve a specific content field from a linked document and add it to the document response object. 51 | 52 | Note that this will only retrieve content of the following field types: 53 | 54 | - Color 55 | - Content Relationship 56 | - Date 57 | - Image 58 | - Key Text 59 | - Number 60 | - Rich Text (but only the first element) 61 | - Select 62 | - Timestamp 63 | 64 | It is **not** possible to retrieve the following content field types: 65 | 66 | - Embed 67 | - GeoPoint 68 | - Link 69 | - Link to Media 70 | - Rich Text (anything other than the first element) 71 | - Title 72 | - Any field in a Group or Slice 73 | 74 | The value you enter for the fetchLinks option needs to take the following format: 75 | 76 | ```css 77 | [ 'fetchLinks' => '{custom-type}.{field}' ] 78 | ``` 79 | 80 | | Property | Description | 81 | | ----------------------------------- | ---------------------------------------------------------------------------- | 82 | | {custom-type}
|

The custom type API-ID of the linked document

| 83 | | {field}
|

The API-ID of the field you wish to retrieve from the linked document

| 84 | 85 | To view a complete example of how this option works, view the example on the [Fetch Linked Document Fields](../02-query-the-api/16-fetch-linked-items.md) page. 86 | 87 | ```css 88 | [ 'fetchLinks' => 'author.full_name' ] 89 | [ 'fetchLinks' => 'author.first-name, author.last-name' ] 90 | ``` 91 | 92 | ## lang 93 | 94 | The `lang` option defines the language code for the results of your query. 95 | 96 | ### Specify a particular language/region 97 | 98 | You can use the *lang* option to specify a particular language/region you wish to query by. You just need to set the lang value to the desired language code, for example "en-us" for American English. 99 | 100 | > If no *lang* option is provided, then the query will default to the master language of the repository. 101 | 102 | ```css 103 | [ 'lang' => 'en-us' ] 104 | ``` 105 | 106 | ### Query all languages 107 | 108 | You can also use the *lang* option to specify that you want to query documents in all available languages. Simply set the *lang* option to the wildcard value `*`. 109 | 110 | ``` 111 | [ 'lang' => '*' ] 112 | ``` 113 | 114 | To view a complete example of how this option works, view the examples on the [Query by Language](../02-query-the-api/19-query-by-language.md) page. 115 | 116 | ## orderings 117 | 118 | The `orderings` option orders the results by the specified field(s). You can specify as many fields as you want. 119 | 120 | | Property | Description | 121 | | --------------------------------------- | ---------------------------------------------------------------------------------------------- | 122 | | lowest to highest
|

It will automatically order the field from lowest to highest

| 123 | | highest to lowest
|

Use "desc" next to the field name to instead order it from greatest to lowest

| 124 | 125 | ```javascript 126 | [ 'orderings' => '[my.product.price]' ] // lowest to highest 127 | [ 'orderings' => '[my.product.price desc]' ] // highest to lowest 128 | ``` 129 | 130 | ### Multiple orderings 131 | 132 | You can specify more than one field to order your results by. To do so, simply add more than one field in the array. 133 | 134 | The results will be ordered by the first field in the array. If any of the results have the same value for that initial sort, they will then be sorted by the next specified field. 135 | 136 | Here is an example that first sorts the products by price from lowest to highest. If any of the products have the same price, then they will be sorted by their titles. 137 | 138 | ```css 139 | [ 'orderings' => '[my.product.price, my.product.title]' ] 140 | ``` 141 | 142 | ### Sort by publication date 143 | 144 | It is also possible to order documents by their first or last publication dates. 145 | 146 | | Property | Description | 147 | | -------------------------------------------- | ------------------------------------------------------------------------------ | 148 | | first_publication_date
|

The date that the document was originally published for the first time

| 149 | | last_publication_date
|

The most recent date that the document has been published after editing

| 150 | 151 | ```css 152 | [ 'orderings' => '[document.first_publication_date]' ] 153 | [ 'orderings' => '[document.last_publication_date]' ] 154 | ``` 155 | 156 | ## page 157 | 158 | The `page` option defines the pagination for the result of your query. 159 | 160 | Defaults to "1", corresponding to the first page. 161 | 162 | | Property | Description | 163 | | ----------------------------------------------- | --------------------------------------------------- | 164 | | value
integer |

page index (1 = 1st page, 2 = 2nd page, ...)

| 165 | 166 | ```css 167 | [ 'page' => 2 ] 168 | ``` 169 | 170 | ## pageSize 171 | 172 | The `pageSize` option defines the maximum number of documents that the API will return for your query. 173 | 174 | Default is 20, max is 100. 175 | 176 | | Property | Description | 177 | | ----------------------------------------------- | ------------------------------------ | 178 | | value
integer |

page size (between 1 and 100)

| 179 | 180 | ```css 181 | [ 'pageSize' => 100 ] 182 | ``` 183 | 184 | ## ref 185 | 186 | The `ref` option defines which version of your content to query. 187 | 188 | By default the Prismic PHP development kit will use the master ref to retrieve the currently published documents. 189 | 190 | | Property | Description | 191 | | ---------------------------------------------- | -------------------------------------------------- | 192 | | value
string |

Master, Release, Experiment, or Preview ref

| 193 | 194 | ```css 195 | [ 'ref' => 'Wst7PCgAAHUAvviX' ] 196 | ``` 197 | -------------------------------------------------------------------------------- /docs/02-query-the-api/05-query-helper-functions.md: -------------------------------------------------------------------------------- 1 | # Query Helper Functions 2 | 3 | We've included helper functions to make creating certain queries quicker and easier when developing with Prismic and Laravel. 4 | 5 | ## getByUID 6 | 7 | ```css 8 | getByUID( custom-type, uid, options ) 9 | ``` 10 | 11 | The `getByUID` function is used to query the specified custom type by a certain UID value. This requires that the custom type of the document contains the UID field. 12 | 13 | This function will only ever retrieve one document as there can only be one instance of a given UID value for each custom type & language. 14 | 15 | | Property | Description | 16 | | ---------------------------------------------------- | --------------------------------------------------------------------- | 17 | | custom-type
string |

(required) The API-ID of the custom type you are searching for

| 18 | | uid
string |

(required) The UID of the document you want to retrieve

| 19 | | options
array |

(optional) An array with option parameters and values

| 20 | 21 | Here is an example that queries a document of the type “page” by its uid “about-us”. 22 | 23 | ```php 24 | getByUID('page', 'about-us'); 26 | // $document contains the document content 27 | ``` 28 | 29 | Here is an example with options that specifies a particular language to query. 30 | 31 | ```php 32 | 'en-us' ]; 34 | $document = $api->getByUID('page', 'about-us', $options); 35 | // $document contains the document content 36 | ``` 37 | 38 | ## getByID 39 | 40 | ```css 41 | getByID( id, options ) 42 | ``` 43 | 44 | The `getByID` function is used to query a certain document by its document ID. Every document is automatically assigned a unique id when it is created. The ID will look something like this: ‘WAjgAygABN3B0a-a’. 45 | 46 | This function will only ever retrieve one document as each document has a unique ID value. 47 | 48 | | Property | Description | 49 | | ----------------------------------------------- | ------------------------------------------------------------- | 50 | | id
string |

(required) The id of the document you want to retrieve

| 51 | | options
array |

(optional) An array with option parameters and values

| 52 | 53 | Here is an example that queries a document by its ID "WAjgAygABN3B0a-a". 54 | 55 | ```php 56 | getByID('WAjgAygABN3B0a-a'); 58 | // $document contains the document content 59 | ``` 60 | 61 | Here is an example that adds options. 62 | 63 | ```php 64 | 'product.title' ]; 66 | $document = $api->getByID('WAjgAygABN3B0a-a', $options); 67 | // $document contains the document content 68 | ``` 69 | 70 | ## getByIDs 71 | 72 | ```css 73 | getByIDs( ids, options ) 74 | ``` 75 | 76 | The `getByIDs` function is used to query multiple documents by their ids. 77 | 78 | This will return the documents in the same order specified in the array, unless options are added to sort them otherwise. 79 | 80 | | Property | Description | 81 | | ----------------------------------------------- | ---------------------------------------------------------------------------------------- | 82 | | ids
array |

(required) An array of strings with the ids of the documents you want to retrieve

| 83 | | options
array |

(optional) An array with option parameters and values

| 84 | 85 | Here is an example that queries multiple documents by their ids. 86 | 87 | ```php 88 | getByIDs($ids); 91 | // $response contains the response object, $response->results holds the retrieved documents 92 | ``` 93 | 94 | Here is an example with options that sort the documents by their titles. 95 | 96 | ```php 97 | '[my.page.title]' ]; 100 | $response = $api->getByIDs($ids); 101 | // $response contains the response object, $response->results holds the retrieved documents 102 | ``` 103 | 104 | ## getSingle 105 | 106 | ```css 107 | getSingle( custom-type, options ) 108 | ``` 109 | 110 | The `getSingle` function is used to query the document of a Single custom type. Single custom types only allow for the creation of one document of that type. 111 | 112 | This will only ever retrieve one document. 113 | 114 | | Property | Description | 115 | | ---------------------------------------------------- | --------------------------------------------------------------------------- | 116 | | custom-type
string |

(required) The API ID of the single custom type you want to retrieve

| 117 | | options
array |

(optional) An array with option parameters and values

| 118 | 119 | Here is an example that retrieves the document of the Single type "navigation". 120 | 121 | ```php 122 | getSingle('navigation'); 124 | // $document contains the document content 125 | ``` 126 | -------------------------------------------------------------------------------- /docs/02-query-the-api/06-query-single-type.md: -------------------------------------------------------------------------------- 1 | # Query a Single Type document 2 | 3 | Here we discuss how to retrieve the content for a Single type document. 4 | 5 | ## getSingle helper function 6 | 7 | In this example we use the `getSingle` helper function to query the single instance of the custom type "navigation". 8 | 9 | ``` 10 | getSingle('navigation'); 12 | // $document contains the document content 13 | ``` 14 | 15 | ## Without the helper 16 | 17 | You can perform the same query without using the helper function. Here we again query the single document of the type "navigation". 18 | 19 | ``` 20 | query(Predicates::at('document.type', 'navigation')); 22 | $document = $response->results[0]; 23 | // $document contains the document content 24 | ``` 25 | 26 | > **Querying by Language** 27 | > 28 | > Note that if you are trying to query a document that isn't in the master language of your repository this way, you will need to specify the language code or wildcard language value. You can read how to do this on the [Query by Language page](../02-query-the-api/19-query-by-language.md). 29 | > 30 | > If you are using the query helper function above, you do not need to do this. 31 | -------------------------------------------------------------------------------- /docs/02-query-the-api/07-query-by-id-or-uid.md: -------------------------------------------------------------------------------- 1 | # Query Documents by ID or UID 2 | 3 | You can retrieve either multiple documents or a single one by their document ID or UID. 4 | 5 | > **Querying by Language** 6 | > 7 | > Note that if you are trying to query a document that isn't in the master language of your repository, you will need to specify the language code or wildcard language value. You can read how to do this on the [Query by Language page](../02-query-the-api/19-query-by-language.md). 8 | > 9 | > If you are using one of the query helper functions below, you do not need to do this. The only exception is the `getByUID` helper which is explained below. 10 | 11 | ## Query a document by ID 12 | 13 | We've created a helper function that makes it easy to query by ID, but it is also possible to do this without the helper function. 14 | 15 | ### getByID helper function 16 | 17 | Here is an example that shows how to query a document by its ID using the `getByID` helper function. 18 | 19 | ``` 20 | getByID('WAjgAygABN3B0a-a'); 22 | // $document contains the document content 23 | ``` 24 | 25 | ### Without the helper function 26 | 27 | Here we perform the same query for a document by its ID without using the helper function. 28 | 29 | ``` 30 | query( 32 | Predicates::at('document.id', 'WAjgAygAAN3B0a-a'), 33 | [ 'lang' => '*' ] 34 | ); 35 | $document = $response->results[0]; 36 | // $document contains the document content 37 | ``` 38 | 39 | ## Query multiple documents by IDs 40 | 41 | We've created a helper function that makes it easy to query multiple documents by IDs. 42 | 43 | ### getByIDs helper function 44 | 45 | Here is an example of querying multiple documents by their ids using the `getByIDs` helper function. 46 | 47 | ``` 48 | getByIDs($ids); 51 | // $response contains the response object, $response->results holds the retrieved documents 52 | ``` 53 | 54 | ### Without the helper function 55 | 56 | Here is an example of how to perform the same query as above, but this time without using the helper function. 57 | 58 | ``` 59 | query( 62 | Predicates::in('document.id', $ids), 63 | [ 'lang' => '*' ] 64 | ); 65 | // $response contains the response object, $response->results holds the retrieved documents 66 | ``` 67 | 68 | ## Query a document by its UID 69 | 70 | If you have added the UID field to a custom type, you can query a document by its UID. 71 | 72 | ### getByUID helper function 73 | 74 | Here is an example showing how to query a document of the type "page" by its UID "about-us" using the `getByUID` helper function. 75 | 76 | ``` 77 | getByUID('page', 'about-us'); 79 | // $document contains the document content 80 | ``` 81 | 82 | ### Query by language 83 | 84 | It's possible that you may have documents in different languages with the same UID value. In that case, you will need to specify the language code in order to retrieve the correct document. 85 | 86 | ``` 87 | 'fr-fr' ]; 89 | $document = $api->getByUID('page', 'about-us', $options); 90 | // $document contains the fr-fr document content 91 | ``` 92 | 93 | > Note that if you don't specify the language or if you specify the wildcard value `'*'`, the oldest document with this UID value will be returned. 94 | 95 | ### Query all language versions by UID 96 | 97 | The `getByUID` function will always return a single document. If you need to query all the language versions that share the same UID, then you can use the following method (without the helper function) to retrieve them all at the same time. 98 | 99 | ### Without the helper function 100 | 101 | Here is an example of the same query without using the helper function. It will query the document(s) of the type "page" that contains the UID "about us". 102 | 103 | ``` 104 | query( 106 | Predicates::at('my.page.uid', 'about-us'), 107 | [ 'lang' => '*' ] 108 | ); 109 | // $response contains the response object 110 | ``` 111 | -------------------------------------------------------------------------------- /docs/02-query-the-api/08-query-all-documents.md: -------------------------------------------------------------------------------- 1 | # Query all your Documents 2 | 3 | If you need to query all of the documents in your repository, you can just run a query with an empty string. 4 | 5 | ## Without query options 6 | 7 | Here is an example that will query your repository for all documents. By default, the API will paginate the results, with 20 documents per page. 8 | 9 | ``` 10 | query(''); 12 | // $response contains the response object, $response->results holds the retrieved documents 13 | ``` 14 | 15 | ## With query options 16 | 17 | You can add options to this query. In the following example we allow 100 documents per page for the query response. 18 | 19 | ``` 20 | query('', [ 'pageSize' => 100 ]); 22 | // $response contains the response object, $response->results holds the retrieved documents 23 | ``` 24 | -------------------------------------------------------------------------------- /docs/02-query-the-api/09-query-by-type.md: -------------------------------------------------------------------------------- 1 | # Query by Type 2 | 3 | Here we discuss how to query all the documents of a certain custom type from your content repository. 4 | 5 | ## By One Type 6 | 7 | ### Example 1 8 | 9 | This first example shows how to query all of the documents of the custom type "blog-post". The option included in this query will sort the results by their "date" field (from most recent to the oldest). 10 | 11 | ``` 12 | query( 14 | Predicates::at('document.type', 'blog-post'), 15 | [ 'orderings' => '[my.blog-post.date desc]' ] 16 | ); 17 | // $response contains the response object, $response->results holds the retrieved documents 18 | ``` 19 | 20 | ### Example 2 21 | 22 | The following example shows how to query all of the documents of the custom type "video-game". The options will make it so that the results are sorted alphabetically, limited to 10 games per page, and showing the second page of results. 23 | 24 | ``` 25 | query( 27 | Predicates::at('document.type', 'video-game'), 28 | [ 'pageSize' => 10, 'page' => 2, 'orderings' => '[my.video-game.title]' ] 29 | ); 30 | // $response contains the response object, $response->results holds the retrieved documents 31 | ``` 32 | 33 | ## By Multiple Types 34 | 35 | This example shows how to query all of the documents of two different custom types: "article" and "blog_post". 36 | 37 | ``` 38 | query( 40 | Predicates::any('document.type', ['article', 'blog_post']) 41 | ); 42 | // $response contains the response object, $response->results holds the retrieved documents 43 | ``` 44 | -------------------------------------------------------------------------------- /docs/02-query-the-api/10-query-by-tag.md: -------------------------------------------------------------------------------- 1 | # Query by Tag 2 | 3 | Here we show how to query all of the documents with a certain tag. 4 | 5 | ## Query a single tag 6 | 7 | This example shows how to query all the documents with the tag "English". 8 | 9 | ``` 10 | query( 12 | Predicates::at('document.tags', ['English']) 13 | ); 14 | // $response contains the response object, $response->results holds the retrieved documents 15 | ``` 16 | 17 | ## Query multiple tags 18 | 19 | The following example shows how to query all of the documents with either the tag "Tag 1" or "Tag 2". 20 | 21 | ``` 22 | query( 24 | Predicates::any('document.tags', ['Tag 1', 'Tag 2']) 25 | ); 26 | // $response contains the response object, $response->results holds the retrieved documents 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/02-query-the-api/11-query-by-date.md: -------------------------------------------------------------------------------- 1 | # Query by Date 2 | 3 | This page shows multiple ways to query documents based on a date field. 4 | 5 | Here we use a few predicates that can query based on Date or Timestamp fields. Feel free to explore the [Date & Time based Predicate Reference](../02-query-the-api/03-date-and-time-based-predicate-reference.md) page to learn more about this. 6 | 7 | ## Query by an exact date 8 | 9 | The following is an example that shows how to query for all the documents of the type "article" with the release-date field ("date") equal to January 22, 2020. Note that this type of query will only work for the Date Field, not the Timestamp field. 10 | 11 | ``` 12 | query( 14 | Predicates::at('my.article.release-date', '2020-01-22') 15 | ); 16 | // $response contains the response object, $response->results holds the retrieved documents 17 | ``` 18 | 19 | ## Query by month and year 20 | 21 | Here is an example of a query for all documents of the type "blog-post" whose release-date is in the month of May in the year 2020. This might be useful for a blog archive. 22 | 23 | ``` 24 | query( 26 | [ Predicates::month('my.blog-post.release-date', 'May'), 27 | Predicates::year('my.blog-post.release-date', 2020) ] 28 | ); 29 | // $response contains the response object, $response->results holds the retrieved documents 30 | ``` 31 | 32 | ## Query by publication date 33 | 34 | You can also query documents by their first or last publication dates. 35 | 36 | Here is an example of a query for all documents of the type "blog-post" whose original publication date is in the month of May in the year 2020. 37 | 38 | ``` 39 | query( 41 | [ Predicates::at('document.type', 'blog-post'), 42 | Predicates::month('document.first_publication_date', 'May'), 43 | Predicates::year('document.first_publication_date', 2020) ] 44 | ); 45 | // $response contains the response object, $response->results holds the retrieved documents 46 | ``` 47 | -------------------------------------------------------------------------------- /docs/02-query-the-api/12-query-by-a-field.md: -------------------------------------------------------------------------------- 1 | # Query by a Field 2 | 3 | There are a number of fields that you can query by. Here we give a examples that show how to query by the Boolean, Number, Key Text, Document Link, and Select fields. 4 | 5 | ## Boolean Field 6 | 7 | The following example queries all the "post" custom type documents with the ** "**switch"\*\* **field equal to _true_ by using the** \*\*at predicate. It also sorts the results by their title. 8 | 9 | ``` 10 | query( 12 | Predicates::at('my.post.switch', true), 13 | [ 'orderings' => '[my.post.title]' ] 14 | ); 15 | // $response contains the response object, $response->results holds the retrieved documents 16 | ``` 17 | 18 | ## Number field 19 | 20 | The following example shows how to query all the products with the "price" field (Number) less than 100. 21 | 22 | ``` 23 | query( 25 | Predicates::lt('my.product.price', 100) 26 | ); 27 | // $response contains the response object, $response->results holds the retrieved documents 28 | ``` 29 | 30 | You can find more query predicates for Number fields on the [Query Predicate Reference](../02-query-the-api/02-query-predicate-reference.md) page. 31 | 32 | ## Key Text field 33 | 34 | The following example shows how to query all the "employee" custom type documents with the "job-title" field (Key Text) equal to either "Developer" or "Designer". 35 | 36 | ``` 37 | query( 39 | Predicates::any('my.employee.job-title', ['Developer', 'Designer']) 40 | ); 41 | // $response contains the response object, $response->results holds the retrieved documents 42 | ``` 43 | 44 | ## Content Relationship / Document Link Field 45 | 46 | To query by a particular document link value, you must use the ID of the document you are looking for. 47 | 48 | The following example queries all the "blog_post" custom type documents with the "category_link" field (a Document Link) equal to the category with a document ID of "WNje3SUAAEGBu8bc". 49 | 50 | ``` 51 | query( 53 | [ Predicates::at('document.type', 'blog_post'), 54 | Predicates::at('my.blog_post.category_link', 'WNje3SUAAEGBu8bc') ] 55 | ); 56 | // $response contains the response object, $response->results holds the retrieved documents 57 | ``` 58 | 59 | ## Select field 60 | 61 | The following demonstrates how to query all the "book" custom type documents with the "author" field (Select) equal to "John Doe". It also sorts the results by their titles. 62 | 63 | ``` 64 | query( 66 | Predicates::at('my.book.author', 'John Doe'), 67 | [ 'orderings' => '[my.book.title]' ] 68 | ); 69 | // $response contains the response object, $response->results holds the retrieved documents 70 | ``` 71 | 72 | ## Select field within a Group 73 | 74 | It is also possible to query by a field inside of a group. The following queries all the "book" custom type documents with the "name" field (Select) equal to "John Doe". In this case the "name" field is in a group field named "author-info". 75 | 76 | ``` 77 | query( 79 | Predicates::at('my.book.author-info.name', 'John Doe'), 80 | [ 'orderings' => '[my.book.title]' ] 81 | ); 82 | // $response contains the response object, $response->results holds the retrieved documents 83 | ``` 84 | -------------------------------------------------------------------------------- /docs/02-query-the-api/13-query-by-content-relationship.md: -------------------------------------------------------------------------------- 1 | # Query by Content Relationship Field 2 | 3 | To query by a particular Content Relationship / Document link value, you must use the ID of the document you are looking for. 4 | 5 | > **You must use the document ID** 6 | > 7 | > Note that you must use the document ID to make this query. It does not work if you try to query using a UID value. 8 | 9 | ## By a Content Relationship field 10 | 11 | The following example queries all the "blog_post" custom type documents with the "category_link" field (a Content Relationship) equal to the category with a document ID of "WNje3SUAAEGBu8bc". 12 | 13 | ``` 14 | query( 16 | [ Predicates::at('document.type', 'blog_post'), 17 | Predicates::at('my.blog_post.category_link', 'WNje3SUAAEGBu8bc') ] 18 | ); 19 | // $response contains the response object, $response->results holds the retrieved documents 20 | ``` 21 | 22 | ## By a Content Relationship field in a Group 23 | 24 | If your Content Relationship field is inside a group, you just need to specify the Group, then the Content Relationship field. 25 | 26 | Here is an example that queries all the "blog_post" custom type documents with the "category_link" field (a Content Relationship) equal to the category with a document ID of "WNje3SUAAEGBu8bc". In this case, the Content Relationship field is inside a Group field with the API ID of "categories". 27 | 28 | ``` 29 | query( 31 | [ Predicates::at('document.type', 'blog_post'), 32 | Predicates::at('my.blog_post.categories.category_link', 'WNje3SUAAEGBu8bc') ] 33 | ); 34 | // $response contains the response object, $response->results holds the retrieved documents 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/02-query-the-api/14-fulltext-search.md: -------------------------------------------------------------------------------- 1 | # Fulltext Search with Laravel 2 | 3 | You can use the Fulltext predicate to search a document for a given term or terms. 4 | 5 | The `fulltext` predicate searches the term in any of the following fields: 6 | 7 | - Rich Text 8 | - Title 9 | - Key Text 10 | - UID 11 | - Select 12 | 13 | To learn more about this predicate checkout the [Query Predicate Reference](../02-query-the-api/02-query-predicate-reference.md) page. 14 | 15 | > Note that the fulltext search is not case sensitive. 16 | 17 | ## Example Query 18 | 19 | This example shows how to query for all the documents of the custom type "blog-post" that contain the word "news". 20 | 21 | ``` 22 | query( 24 | [ Predicates::at('document.type', 'blog-post'), 25 | Predicates::fulltext('document', 'news') ] 26 | ); 27 | // $response contains the response object, $response->results holds the retrieved documents 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/02-query-the-api/15-use-multiple-predicates.md: -------------------------------------------------------------------------------- 1 | # Use Multiple Predicates 2 | 3 | You can combine multiple predicates in a single query, for example querying for a certain custom type with a given tag. 4 | 5 | You simply need to put all the predicates into a comma-separated array. 6 | 7 | ## Example 1 8 | 9 | Here is an example that queries all of the documents of the custom type "blog-post" that have the tag "featured". 10 | 11 | ``` 12 | query( 14 | [ Predicates::at('document.type', 'blog-post'), 15 | Predicates::at('document.tags', ['featured']) ] 16 | ); 17 | // $response contains the response object, $response->results holds the retrieved documents 18 | ``` 19 | 20 | ## Example 2 21 | 22 | Here is an example that queries all of the documents of the custom type "employee" excluding those with the tag "manager". 23 | 24 | ``` 25 | query( 27 | [ Predicates::at('document.type', 'employee'), 28 | Predicates::not('document.tags', ['manager']) ] 29 | ); 30 | // $response contains the response object, $response->results holds the retrieved documents 31 | ``` 32 | -------------------------------------------------------------------------------- /docs/02-query-the-api/16-fetch-linked-items.md: -------------------------------------------------------------------------------- 1 | # Fetch Linked Document Fields 2 | 3 | Here we explore an example that fetches a specific content field from a linked document. 4 | 5 | ## The fetchLinks option 6 | 7 | The `fetchLinks` option allows you to retrieve a specific content field from a linked document and add it to the document response object. 8 | 9 | Note that this will only retrieve content of the following field types: 10 | 11 | - Color 12 | - Content Relationship 13 | - Date 14 | - Image 15 | - Key Text 16 | - Number 17 | - Rich Text (but only returns the first element) 18 | - Select 19 | - Timestamp 20 | 21 | It is **not** possible to retrieve the following content field types: 22 | 23 | - Embed 24 | - GeoPoint 25 | - Link 26 | - Link to Media 27 | - Rich Text (anything other than the first element) 28 | - Title 29 | - Any field in a Group or Slice 30 | 31 | The value you enter for the fetchLinks option needs to take the following format: 32 | 33 | ``` 34 | [ 'fetchLinks' => '{custom-type}.{field}' ] 35 | ``` 36 | 37 | | Property | Description | 38 | | ----------------------------------- | ---------------------------------------------------------------------------- | 39 | | {custom-type}
|

The custom type API-ID of the linked document

| 40 | | {field}
|

The API-ID of the field you wish to retrieve from the linked document

| 41 | 42 | ## A simple example 43 | 44 | The following is an example that uses the *fetchLinks* option. We are querying for a "recipe" document with the uid "chocolate-chip-cookies". 45 | 46 | The "recipe" Custom Type has a Content Relationship (AKA Document Link) field with the API ID `author_link` which links to an "author" document. 47 | 48 | Inside the "author" document you have a Key Text field with the API ID `name`. 49 | 50 | The following will show you how to retrieve the author name field when querying the recipe. 51 | 52 | ``` 53 | $response = $api->query( 54 | Predicates::at('my.recipe.uid', 'chocolate-chip-cookies'), 55 | [ 'fetchLinks' => 'author.name' ] 56 | ); 57 | 58 | $document = $response->results[0]; 59 | 60 | $author = $document->data->author_link; 61 | // $author now works like a top-level document 62 | 63 | $authorName = $author->data->name; 64 | // $authorName contains the text from the "name" field 65 | ``` 66 | 67 | ## Fetch multiple fields 68 | 69 | In order to fetch more than one field from the linked document, you just need to provide an array of fields. Here is an example that fetches the fields `name` and `picture` from the `author` custom type. 70 | 71 | ```css 72 | [ 'fetchLinks' => 'author.name, author.picture' ] 73 | ``` 74 | -------------------------------------------------------------------------------- /docs/02-query-the-api/17-order-your-results.md: -------------------------------------------------------------------------------- 1 | # Order your results 2 | 3 | This page shows how to order the results of your query for prismic.io. It explains how to use the orderings and after predicate options. 4 | 5 | ## orderings 6 | 7 | The `orderings` option orders the results by the specified field(s). You can specify as many fields as you want. 8 | 9 | | Property | Description | 10 | | --------------------------------------- | ---------------------------------------------------------------------------------------------- | 11 | | lowest to highest
|

It will automatically order the field from lowest to highest

| 12 | | highest to lowest
|

Use "desc" next to the field name to instead order it from greatest to lowest

| 13 | 14 | ```css 15 | [ 'orderings' => '[my.product.price]' ] // lowest to highest 16 | [ 'orderings' => '[my.product.price desc]' ] // highest to lowest 17 | ``` 18 | 19 | ### Specifying multiple orderings 20 | 21 | You can specify more than one field to order your results by. To do so, simply add more than one field in the array. 22 | 23 | The results will be ordered by the first field in the array. If any of the results have the same value for that initial sort, they will then be sorted by the next specified field. 24 | 25 | Here is an example that first sorts the products by price from lowest to highest. If any of the products have the same price, then they will be sorted by their titles. 26 | 27 | ```css 28 | [ 'orderings' => '[my.product.price, my.product.title]' ] 29 | ``` 30 | 31 | ### Order by publication dates 32 | 33 | It is also possible to order documents by their first or last publication dates. 34 | 35 | The **first publication date** is the date that the document was originally published for the first time. The **last publication date** is the most recent date that the document has been published after editing. 36 | 37 | ```javascript 38 | [ 'orderings' => '[document.first_publication_date]' ] 39 | [ 'orderings' => '[document.last_publication_date]' ] 40 | ``` 41 | 42 | ## after 43 | 44 | The `after` option can be used along with the orderings option. It will remove all the documents except for those after the specified document in the list. 45 | 46 | To clarify, let’s say you have a query that return the following documents in this order: 47 | 48 | - `V9Zt3icAAAl8Uzob (Page 1)` 49 | - `PqZtvCcAALuRUzmO (Page 2)` 50 | - `VkRmhykAAFA6PoBj (Page 3)` 51 | - `V4Fs8rDbAAH9Pfow (Page 4)` 52 | - `G8ZtxQhAALuSix6R (Page 5)` 53 | - `Ww9yuAvdAhl87wh6 (Page 6)` 54 | 55 | If you add the `after` option and specify page 3, “`VkRmhykAAFA6PoBj`”, your query will return the following: 56 | 57 | - `V4Fs8rDbAAH9Pfow (Page 4)` 58 | - `G8ZtxQhAALuSix6R (Page 5)` 59 | - `Ww9yuAvdAhl87wh6 (Page 6)` 60 | 61 | By reversing the orderings in your query, you can use this same method to retrieve all the documents before the specified document. 62 | 63 | This option is useful when creating a navigation for a blog. 64 | 65 | Simply use the `after` parameter in your query options as shown below. 66 | 67 | ```css 68 | [ 'after' => 'VkRmhykAAFA6PoBj' ] 69 | ``` 70 | -------------------------------------------------------------------------------- /docs/02-query-the-api/18-pagination-for-results.md: -------------------------------------------------------------------------------- 1 | # Pagination for Results 2 | 3 | The results retrieved from the prismic.io repository will automatically be paginated. Here you will find an explanation for how to modify the pagination parameters. 4 | 5 | ## pageSize 6 | 7 | The `pageSize` option defines the maximum number of documents that the API will return for your query. The default is 20, and the maximum is 100. 8 | 9 | Here is an example that shows how to query all of the documents of the custom type "recipe," allowing 100 documents per page. 10 | 11 | ``` 12 | query( 14 | Predicates::at('document.type', 'recipe'), 15 | [ 'pageSize' => 100 ] 16 | ); 17 | // $response contains the response object, $response->results holds the retrieved documents 18 | ``` 19 | 20 | ## page 21 | 22 | The `page` option defines the pagination for the results of your query. 23 | 24 | If left unspecified, it will default to 1, which corresponds to the first page. 25 | 26 | Here is an example that show how to query all of the documents of the custom type "recipe". The options entered will limit the results to 50 recipes per page, and will display the third page of results. 27 | 28 | ``` 29 | query( 31 | Predicates::at('document.type', 'recipe'), 32 | [ 'pageSize' => 50, 'page' => 3 ] 33 | ); 34 | // $response contains the response object, $response->results holds the retrieved documents 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/02-query-the-api/19-query-by-language.md: -------------------------------------------------------------------------------- 1 | # Query by Language 2 | 3 | When querying the API, you can query by language. 4 | 5 | ## Query a specific language 6 | 7 | You simply need to add the `lang` query option and set it to the language code you are querying (example, "en-us" for American English). 8 | 9 | > If you don't specify a `lang` the query will automatically query the documents in your master language. 10 | 11 | Here is an example of how to query for all the documents of the type "blog-post" in French (language code "fr-fr"). 12 | 13 | ``` 14 | query( 16 | Predicates::at('document.type', 'blog-post'), 17 | [ 'lang' => 'fr-fr' ] 18 | ); 19 | // $response contains the response object, $response->results holds the retrieved documents 20 | ``` 21 | 22 | ## Query for all languages 23 | 24 | If you want to query all the document in all languages you can add the wildcard, `'*'`, as your lang option. 25 | 26 | This example shows this by querying all documents of the type "blog-post" in all languages. 27 | 28 | ``` 29 | query( 31 | Predicates::at('document.type', 'blog-post'), 32 | [ 'lang' => '*' ] 33 | ); 34 | // $response contains the response object, $response->results holds the retrieved documents 35 | ``` 36 | 37 | ## Query by UID & language 38 | 39 | To learn more about how to query your documents by UID and language, check out the [Query by ID and UID](../02-query-the-api/07-query-by-id-or-uid.md) page. 40 | -------------------------------------------------------------------------------- /docs/03-templating/01-the-response-object.md: -------------------------------------------------------------------------------- 1 | # The Response Object 2 | 3 | Once you have set up your Custom Types and queried your content from the API, it’s time to integrate that content into your templates. 4 | 5 | First we’ll go over the response object returned from the API, then we’ll discuss how to retrieve your content. 6 | 7 | ## An example response 8 | 9 | Let’s start by taking a look at the Response Object returned when querying the API. Here is a simple example of response object with one document that contains a couple of fields. 10 | 11 | ``` 12 | { 13 | "page": 1, 14 | "results_per_page": 20, 15 | "results_size": 1, 16 | "total_results_size": 1, 17 | "total_pages": 1, 18 | "next_page": null, 19 | "prev_page": null, 20 | "results": [ 21 | { 22 | "id": "WKxlPCUEEIZ10AHU", 23 | "uid": "example-page", 24 | "type": "page", 25 | "href": "https://your-repo-name.prismic.io/api/v2/documents/search...", 26 | "tags": [], 27 | "first_publication_date": "2017-01-13T11:45:21.000Z", 28 | "last_publication_date": "2017-02-21T16:05:19.000Z", 29 | "slugs": [ 30 | "example-page" 31 | ], 32 | "linked_documents": [], 33 | "lang": "en-us", 34 | "alternate_languages": [ 35 | { 36 | "id": "WZcAEyoAACcA0LHi", 37 | "uid": "example-page-french", 38 | "type": "page", 39 | "lang": "fr-fr" 40 | } 41 | ], 42 | "data": { 43 | "title": [ 44 | { 45 | "type": "heading1", 46 | "text": "Example Page", 47 | "spans": [] 48 | } 49 | ], 50 | "date": "2017-01-13" 51 | } 52 | } 53 | ] 54 | } 55 | ``` 56 | 57 | At the topmost level of the response object, you mostly have information about the number of results returned from the query and the pagination of the results. 58 | 59 | | Property | Description | 60 | | ---------------------------------------- | ------------------------------------------------------------------------------------- | 61 | | page
|

The current page of the pagination of the results

| 62 | | results_per_page
|

The number of documents per page of the pagination

| 63 | | results_size
|

The number of documents on this page of the pagination results

| 64 | | total_results_size
|

The total number of documents returned from the query

| 65 | | total_pages
|

The total number of pages in the pagination of the results

| 66 | | next_page
|

The next page number in the pagination

| 67 | | prev_page
|

The previous page number in the pagination

| 68 | | results
|

The documents and their content for this page of the pagination of the results

| 69 | 70 | > Note that when using certain helper functions such as getSingle(), getByUID(), or getByID(), the first document of the results array will automatically be returned. 71 | 72 | ## The Query Results 73 | 74 | The actual content of the returned documents can be found under "results". This will always be an array of the documents, even if there is only one document returned. 75 | 76 | Let’s say that you saved your response object in a variable named `$response`. This would mean that your documents could be accessed with the following: 77 | 78 | ``` 79 | results; 81 | ``` 82 | 83 | And if you only returned one document, it would be accessed with the following: 84 | 85 | ``` 86 | results[0]; 88 | ``` 89 | 90 | > Note: As mentioned above, this is not the case when using certain helper functions such as getSingle(), getByUID(), or getByID(). These will automatically return the first document of the results array. 91 | 92 | Each document in the results array will contain information such as its document ID, uid, type, tags, slugs, first publication date, & last publication date. The content for each document will be found inside the "data" property. 93 | -------------------------------------------------------------------------------- /docs/03-templating/02-the-document-object.md: -------------------------------------------------------------------------------- 1 | # The Document Object 2 | 3 | Here we breakdown the document object returned from the Prismic API when developing with a Laravel project. 4 | 5 | > **Before Reading** 6 | > 7 | > This article assumes that you have queried your API and saved the document object in a variable named `$document`. 8 | 9 | ## An example response 10 | 11 | Let's start by taking a look at the Document Object returned when querying the API. Here is a simple example of a document that contains a couple of fields. 12 | 13 | ```json 14 | { 15 | "id": "WKxlPCUEEIZ10AHU", 16 | "uid": "example-page", 17 | "type": "page", 18 | "href": "https://your-repo-name.prismic.io/api/v2/documents/search...", 19 | "tags": ["Tag 1", "Tag 2"], 20 | "first_publication_date": "2017-01-13T11:45:21.000Z", 21 | "last_publication_date": "2017-02-21T16:05:19.000Z", 22 | "slugs": ["example-page"], 23 | "linked_documents": [], 24 | "lang": "en-us", 25 | "alternate_languages": [ 26 | { 27 | "id": "WZcAEyoAACcA0LHi", 28 | "uid": "example-page-french", 29 | "type": "page", 30 | "lang": "fr-fr" 31 | } 32 | ], 33 | "data": { 34 | "title": [ 35 | { 36 | "type": "heading1", 37 | "text": "Example Page", 38 | "spans": [] 39 | } 40 | ], 41 | "date": "2017-01-13" 42 | } 43 | } 44 | ``` 45 | 46 | ## Accessing Document Fields 47 | 48 | Here is how to access each document field. 49 | 50 | ### ID 51 | 52 | ```bash 53 | $document->id 54 | ``` 55 | 56 | ### UID 57 | 58 | ```bash 59 | $document->uid 60 | ``` 61 | 62 | ### Type 63 | 64 | ```bash 65 | $document->type 66 | ``` 67 | 68 | ### API Url 69 | 70 | ```bash 71 | $document->href 72 | ``` 73 | 74 | ### Tags 75 | 76 | ```bash 77 | $document->tags 78 | // returns an array 79 | ``` 80 | 81 | ### First Publication Date 82 | 83 | ```bash 84 | $document->first_publication_date 85 | ``` 86 | 87 | ### Last Publication Date 88 | 89 | ```bash 90 | $document->last_publication_date 91 | ``` 92 | 93 | ### Language 94 | 95 | ```bash 96 | $document->lang 97 | ``` 98 | 99 | ### Alternate Language Versions 100 | 101 | ```bash 102 | $document->alternate_languages 103 | // returns an array 104 | ``` 105 | 106 | You can read more about this in the [Multi-language Templating](../03-templating/12-multi-language-info.md) page. 107 | 108 | ## Document Content 109 | 110 | To retrieve the content fields from the document you must specify the API ID of the field. Here is an example that retrieves a Date field's content from the document. Here the Date field has the API ID of `date`. 111 | 112 | ```bash 113 | $document->data->date 114 | ``` 115 | 116 | Refer to the specific templating documentation for each field to learn how to add content fields to your pages. 117 | -------------------------------------------------------------------------------- /docs/03-templating/03-boolean.md: -------------------------------------------------------------------------------- 1 | # Templating the Boolean Field 2 | 3 | The Boolean field will add a switch for a true or false values for the content authors to pick from. 4 | 5 | ## Get the boolean value 6 | 7 | Here is an example of how to retrieve the value from a Boolean field which has the API ID switch. 8 | 9 | ``` 10 | @php 11 | $example = $document->data->switch 12 | if ($example) echo 'This is printed if value is true.
'; 13 | @endphp 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/03-templating/04-color.md: -------------------------------------------------------------------------------- 1 | # Templating the Color Field 2 | 3 | The Color field allows content writers to select a color through a color picker or to manually write a hexadecimal value. 4 | 5 | ## Get the color value 6 | 7 | Color value is a string representing a color in hexadecimal format such as "#1e89ce". 8 | 9 | Here is an example of how to retrieve the value from a Color field. In this case, the API ID of the field is `color`. 10 | 11 | ``` 12 |

Colorful Title

13 | // Outputs: 14 |

Colorful Title

15 | ``` 16 | -------------------------------------------------------------------------------- /docs/03-templating/05-date.md: -------------------------------------------------------------------------------- 1 | # Templating the Date field 2 | 3 | The Date field allows content writers to add a date that represents a calendar day. 4 | 5 | ## Get the date value 6 | 7 | Date value is a string formatted as YYYY-MM-DD (example: 2020-02-19). 8 | 9 | Here is an example that retrieves the value of a Date field with the API ID of `date`. 10 | 11 | ```html 12 | // Outputs: 2020-02-19 13 | ``` 14 | 15 | ## Format the Date 16 | 17 | You can also customize the output of the Date field. 18 | 19 | ``` 20 | @php 21 | use Prismic\Dom\Date; 22 | $date = Date::asDate($document->data->date); 23 | @endphp 24 | 25 | 26 | // Outputs: Sunday Feb 19th, 2020 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/03-templating/06-embed.md: -------------------------------------------------------------------------------- 1 | # Templating the Embed field 2 | 3 | The Embed field will let content writers paste an oEmbed supported service resource URL (YouTube, Vimeo, Soundcloud, etc.), and add the embedded content to your website. 4 | 5 | ## Display as HTML 6 | 7 | Here's an example of how to integrate the Embed field into your templates. In this case the Embed field has an API ID of `video`. 8 | 9 | ```html 10 |
{!! $document->data->video->html !!}
11 | ``` 12 | -------------------------------------------------------------------------------- /docs/03-templating/07-geopoint.md: -------------------------------------------------------------------------------- 1 | # Templating the GeoPoint field 2 | 3 | The GeoPoint field is used for Geolocation coordinates. It works by adding coordinates or by pasting a Google Maps URL. 4 | 5 | ## Get the latitude and longitude 6 | 7 | Here's an example of how to integrate the GeoPoint field into your templates. In this case the GeoPoint field has the API ID of `location`. 8 | 9 | ``` 10 | @php 11 | $latitude = $document->data->location->latitude; 12 | $longitude = $document->data->location->longitude; 13 | @endphp 14 | 15 |

Location: {{ $latitude . ', ' . $longitude }}

16 | // Outputs: Location: 48.880401900547, 2.3423677682877 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/03-templating/08-group.md: -------------------------------------------------------------------------------- 1 | # Templating the Group Field 2 | 3 | The Group field is used to create a repeatable collection of fields. 4 | 5 | ## Repeatable Group 6 | 7 | ### Looping through the Group content 8 | 9 | Here's how to integrate a repeatable Group field into your templates. First get the group which is an array. Then loop through each item in the group as shown in the following example. 10 | 11 | This example uses a Group field with an API ID of `references`. The group field consists of a Link field with an API ID of `link` and a Rich Text field with the API ID of `label`. 12 | 13 | ``` 14 | @php 15 | use Prismic\Dom\Link; 16 | use Prismic\Dom\RichText; 17 | @endphp 18 | 19 | 28 | ``` 29 | 30 | ### Example 2 31 | 32 | Here's another example that shows how to integrate a group of images (e.g. a photo gallery) into a page. 33 | 34 | This example has a Group field with the API ID of `photo_gallery`. The group contains an Image field with the API ID of `photo` and a Rich Text field with the API ID of `caption`. 35 | 36 | ``` 37 | @php 38 | use Prismic\Dom\RichText; 39 | @endphp 40 | 41 | @foreach ($document->data->photo_gallery as $item) 42 |
43 | {{ $item->photo->alt }} 44 |
{{ RichText::asText($item->caption) }}
45 |
46 | @endforeach 47 | ``` 48 | 49 | ## Non-repeatable Group 50 | 51 | Even if the group is non-repeatable, the Group field will be an array. You simply need to get the first (and only) group in the array and you can retrieve the fields in the group like any other. 52 | 53 | Here is an example showing how to integrate the fields of a non-repeatable Group into your templates. In this case the Group field has an API ID of `banner_group`. The group consists of an Image field `banner_image`, a Rich Text field `banner_desc`, a Link field `banner_link`, and a Rich Text field `banner_link_label`. 54 | 55 | ``` 56 | @php 57 | use Prismic\Dom\RichText; 58 | use Prismic\Dom\Link; 59 | 60 | $bannerGroup = $document->data->banner_group[0]; 61 | $bannerImage = $bannerGroup->banner_image; 62 | $bannerDesc = RichText::asHtml($bannerGroup->banner_desc); 63 | $bannerLinkUrl = Link::asUrl($bannerGroup->banner_link); 64 | $bannerLinkLabel = RichText::asText($bannerGroup->banner_link_label); 65 | @endphp 66 | 67 | 72 | ``` 73 | -------------------------------------------------------------------------------- /docs/03-templating/09-images.md: -------------------------------------------------------------------------------- 1 | # Templating the Image field 2 | 3 | The Image field allows content writers to upload an image that can be configured with size constraints and responsive image views. 4 | 5 | ## Output an image in your template 6 | 7 | Here's an example of integrating an image. In this case the Image field has the API ID of `illustration`. 8 | 9 | ``` 10 | {{ $document->data->illustration->alt }} 14 | ``` 15 | 16 | > Note that the `alt` attribute is mandatory in HTML5 for image element. We advise to always write an alternative text for each image uploaded to your Prismic's media library. 17 | 18 | Here's an example of integrating an illustration with a caption. In this case we have an Image field with the API ID of `illustration` and a Rich Text field with an API ID of `caption`. 19 | 20 | ```html 21 | @php use Prismic\Dom\RichText; @endphp 22 | 23 |
24 | {{ $document->data->illustration->alt }} 28 |
{{ RichText::asText($document->data->caption) }}
29 |
30 | ``` 31 | 32 | ## Get a responsive image view 33 | 34 | Here is how to add responsive images using the HTML picture element. In this example we have an Image field with the API ID of `responsive_image`. This Image field has the default image view along with views named `tablet` and `mobile`. 35 | 36 | ``` 37 | @php 38 | $mainView = $document->data->responsive_image; 39 | $tabletView = $document->data->responsive_image->tablet; 40 | $mobileView = $document->data->responsive_image->mobile; 41 | @endphp 42 | 43 | 44 |   45 |   46 | 47 | {{ $mainView->alt }} 48 | 49 | ``` 50 | 51 | ## Get the image width & height 52 | 53 | You can retrieve the main image's width or height. In this example we have an Image field with the API ID of `featured_image`. 54 | 55 | ```java 56 | @php 57 | $width = $document->data->featured_image->dimensions->width; 58 | $height = $document->data->featured_image->dimensions->height; 59 | @endphp 60 | ``` 61 | 62 | Here is how to retrieve the alt, width, and height value for a responsive image view. In this case the Image field has the API ID of `featured_image`. 63 | 64 | ```java 65 | @php 66 | $mobileView = $document->data->featured_image->mobile; 67 | $alt = $mobileView->alt; 68 | $width = $mobileView->dimensions->width; 69 | $height = $mobileView->dimensions->height; 70 | @endphp 71 | ``` 72 | -------------------------------------------------------------------------------- /docs/03-templating/10-key-text.md: -------------------------------------------------------------------------------- 1 | # Templating the Key Text Field 2 | 3 | The Key Text field allows content writers to enter a single string. 4 | 5 | ## Get the Key Text value 6 | 7 | Here is an example that shows how to get the value of a Key Text field. In this case, the Key Text field has the API ID of `title`. 8 | 9 | ```html 10 |

{{ $document->data->title }}

11 | ``` 12 | -------------------------------------------------------------------------------- /docs/03-templating/11-links-and-content-relationship.md: -------------------------------------------------------------------------------- 1 | # Templating Link & Content Relationship fields 2 | 3 | The Link field is used for adding links to the Web, to files in your prismic.io media library, or to documents in your prismic.io repository. The Content Relationship field is a Link field specifically used to link to a Document. 4 | 5 | > **Before Reading** 6 | > 7 | > This page assumes that you have retrieved your content and stored it in a variable named `$document`. 8 | > 9 | > It is also assumed that you have set up a Link Resolver stored in the variable `$linkResolver`. When integrating a Link in your templates, a link resolver might be necessary as shown & discussed below. To learn more about this, check out our [Link Resolving](../04-beyond-the-api/01-link-resolving.md) page. 10 | 11 | ## Adding a hyperlink 12 | 13 | Here's the basic integration of a Link or Content Relationship. This will work for any kind of link: Link to the Web, Link to a Media Item, or a Link to a Document / Content Relationship. 14 | 15 | In this example, the Link field has an API ID of `my_link`. 16 | 17 | ``` 18 | @php 19 | use Prismic\Dom\Link; 20 | 21 | $link = $document->data->my_link; 22 | $linkUrl = Link::asUrl($link, $linkResolver); 23 | $targetAttr = property_exists($link, 'target') ? 'target="' . $link->target . '" rel="noopener"' : ''; 24 | @endphp 25 | 26 | Click here 27 | ``` 28 | 29 | ## Using a Link Resolver 30 | 31 | Note that the example above uses a Link Resolver to output the link. This is only required for a Link to a Document / Content Relationship. 32 | 33 | If you know that your link will always be to Media Item or to the Web, then you can remove this. If the link is to or might be to a Document, then you should always use the Link Resolver. 34 | -------------------------------------------------------------------------------- /docs/03-templating/12-multi-language-info.md: -------------------------------------------------------------------------------- 1 | # Templating Multi-language Info 2 | 3 | This page shows you how to access the language code and alternate language versions of a document. 4 | 5 | ## Get the document language code 6 | 7 | You can get the language code of a document by accessing its `lang` property. This might give "en-us" (American english) or "fr-fr" (french) for example. 8 | 9 | ``` 10 | lang; 12 | ``` 13 | 14 | ## Get the alternate language versions 15 | 16 | Next we will access the information about a document's alternate language versions. 17 | 18 | You can get the alternate languages using the `alternate_languages` property. Then simply loop through the array and access the ID, UID, type and language code of each as shown below. 19 | 20 | ``` 21 | alternate_languages; 23 | foreach ($altLangs as $altLang) { 24 | $id = $altLang->id; 25 | $uid = $altLang->uid; 26 | $type = $altLang->type; 27 | $lang = $altLang->lang; 28 | } 29 | ``` 30 | 31 | ## Get a specific language version 32 | 33 | If you need to get a specific alternate language version, use the `getAlternateLanguage` helper method. 34 | 35 | Here's an example of how to get the french version ('fr-fr') of a document. 36 | 37 | ``` 38 | id; 44 | $uid = $frenchVersion->uid; 45 | $type = $frenchVersion->type; 46 | $lang = $frenchVersion->lang; 47 | ``` 48 | -------------------------------------------------------------------------------- /docs/03-templating/13-number.md: -------------------------------------------------------------------------------- 1 | # Templating the Number Field 2 | 3 | The Number field allows content writers to enter or select a number. You can set max and min values for the number. 4 | 5 | ## Get the number value 6 | 7 | Here is an example of how to integrate a Number field into your template. In this case the Number field has the API ID of `price`. 8 | 9 | ```html 10 |
{{ $document->data->price }}
11 | ``` 12 | -------------------------------------------------------------------------------- /docs/03-templating/14-rich-text-and-title.md: -------------------------------------------------------------------------------- 1 | # Templating the Rich Text & Title fields 2 | 3 | The Rich Text field (previously called Structured Text) is a configurable text field with formatting options. This field provides content writers with a WYSIWYG editor where they can define the text as a header or paragraph, make it bold, add links, etc. The Title field is a specific Rich Text field used for titles (HTML elements h1, h2, h3, h4, h5 and h6). 4 | 5 | > **Before Reading** 6 | > 7 | > This page assumes that you have retrieved your content and stored it in a variable named `$document`. 8 | > 9 | > It is also assumed that you have set up a Link Resolver stored in the variable `$linkResolver`. When integrating a Link in your templates, a link resolver might be necessary as shown & discussed below. To learn more about this, check out our [Link Resolving](../04-beyond-the-api/01-link-resolving.md) page. 10 | 11 | ## Output as HTML 12 | 13 | The basic usage of the Rich Text / Title field is to use the `asHtml` helper method to transform the field into HTML. 14 | 15 | The following is an example that will display a section title. In this case, the Rich Text / Title field has the API ID of `title`. 16 | 17 | ``` 18 | @php 19 | use Prismic\Dom\RichText; 20 | 21 | $title = $document->data->title; 22 | $titleHtml = RichText::asHtml($title, $linkResolver); 23 | @endphp 24 | 25 |
26 | {!! $titleHtml !!} 27 |
28 | ``` 29 | 30 | In the previous example when calling the `asHtml` method, you need to pass in a Link Resolver function. This is needed if your content contains any links to documents in your repository. To learn more about how to set up a Link Resolver, check out our [Link Resolving](../04-beyond-the-api/01-link-resolving.md) page. 31 | 32 | ### Example 2 33 | 34 | The following example shows how to display the rich text content of a blog post. In this case, the Rich Text field has the API ID of `blog_post`. 35 | 36 | ``` 37 | @php 38 | use Prismic\Dom\RichText; 39 | @endphp 40 | 41 |
42 | {!! $RichText::asHtml($document->data->blog_post, $linkResolver) !!} 43 |
44 | ``` 45 | 46 | ### Changing the HTML Output 47 | 48 | You can customize the HTML output by passing an HTML serializer to the method. You can learn more about this on the [HTML Serializer](../04-beyond-the-api/03-html-serializer.md) page. 49 | 50 | Here is an example of an HTML serializer function that doesn't wrap images in a paragraph element and replaces all elements with a element with a custom CSS class. 51 | 52 | ``` 53 | @php 54 | use Prismic\Dom\RichText; 55 | 56 | $htmlSerializer = function ($element, $content) use ($linkResolver) { 57 | // Don't wrap images in a

tag 58 | if ($element->type === 'image') { 59 | return '' . $element->alt . ''; 60 | } 61 | // Use a span element with a class instead of an em element 62 | if ($element->type === 'em') { 63 | return '' . $content . ''; 64 | } 65 | // Return null to stick with the default behavior for anything else 66 | return null; 67 | }; 68 | @endphp 69 | 70 |

71 | {!! RichText::asHtml($document->data->blog_post, $linkResolver, $htmlSerializer) !!} 72 |
73 | ``` 74 | 75 | ## Output as plain text 76 | 77 | The `asText` helper method will convert and output the text in the Rich Text / Title field into a string without HTML elements. 78 | 79 | Here is an example of this where the Rich Text / Title field has the API ID of `author`. 80 | 81 | ``` 82 | @php 83 | use Prismic\Dom\RichText; 84 | @endphp 85 | 86 |

87 | {{ RichText::asText($document->data->author) }} 88 |

89 | ``` 90 | -------------------------------------------------------------------------------- /docs/03-templating/15-select.md: -------------------------------------------------------------------------------- 1 | # Templating the Select Field 2 | 3 | The Select field will add a dropdown select box of choices for the content writers to pick from. 4 | 5 | ## Get the Select field value 6 | 7 | Here's an example of how to integrate the selected text value. In this case the Select field has the API ID of `category`. 8 | 9 | ```html 10 |

{{ $document->data->category }}

11 | ``` 12 | -------------------------------------------------------------------------------- /docs/03-templating/16-slices.md: -------------------------------------------------------------------------------- 1 | # Templating Slices 2 | 3 | The Slices field is used to define a dynamic zone for richer page layouts. 4 | 5 | > **Before Reading** 6 | > 7 | > This page assumes that you have retrieved your content and stored it in a variable named `$document`. 8 | > 9 | > It is also assumed that you have set up a Link Resolver stored in the variable `$linkResolver`. When integrating a Link in your templates, a link resolver might be necessary as shown & discussed below. To learn more about this, check out our [Link Resolving](../04-beyond-the-api/01-link-resolving.md) page. 10 | 11 | ## Example 1 12 | 13 | You can retrieve Slices from your documents by accessing the data property containing the slices zone, named by default `body`. 14 | 15 | Here is a simple example that shows how to add slices to your templates. In this example, we have two slice options: a text slice and an image gallery slice. 16 | 17 | ### Text slice 18 | 19 | The "text" slice is simple and only contains one field, which is non-repeatable. 20 | 21 | | Property | Description | 22 | | -------------------------------------------------------- | ------------------------------------------------------------------- | 23 | | Primary
non-repeatable |

- A Rich Text field with the API ID of "rich_text"

| 24 | | Items
repeatable |

None

| 25 | 26 | ### Image gallery slice 27 | 28 | The "image_gallery" slice contains both a repeatable and non-repeatable field. 29 | 30 | | Property | Description | 31 | | -------------------------------------------------------- | -------------------------------------------------------------------- | 32 | | Primary
non-repeatable |

- A Title field with the API ID of "gallery_title"

| 33 | | Items
repeatable |

- An Image field with the API ID of "gallery_image"

| 34 | 35 | ### Integration 36 | 37 | Here is an example of how to integrate these slices into a blog post. 38 | 39 | ``` 40 | @php 41 | use Prismic\Dom\RichText; 42 | 43 | $slices = $document->data->body; 44 | @endphp 45 | 46 |
47 | @foreach ($slices as $slice) 48 | @switch ($slice->slice_type) 49 | @case ('text') 50 | {!! RichText::asHtml($slice->primary->rich_text, $linkResolver) !!} 51 | @break 52 | @case ('image_gallery') 53 | {!! '' !!} 54 | @foreach ($slice->items as $item) 55 | {!! '' . $item->gallery_image->alt . '' !!} 56 | @endforeach 57 | @break 58 | @endswitch 59 | @endforeach 60 |
61 | ``` 62 | 63 | ## Example 2 64 | 65 | The following is a more advanced example that shows how to use Slices for a landing page. In this example, the Slice choices are FAQ question/answers, featured items, and text sections. 66 | 67 | ### FAQ slice 68 | 69 | The "faq" slice takes advantage of both the repeatable and non-repeatable slice sections. 70 | 71 | | Property | Description | 72 | | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | 73 | | Primary
non-repeatable |

- A Title field with the API ID of "faq_title"

| 74 | | Items
repeatable |

- A Title field with the API ID of "question"

- A Rich Text field with the API ID of "answer"

| 75 | 76 | ### Featured Items slice 77 | 78 | The "featured_items" slice contains a repeatable set of an image, title, and summary fields. 79 | 80 | | Property | Description | 81 | | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 82 | | Primary
non-repeatable |

None

| 83 | | Items
repeatable |

- An Image field with the API ID of "image"

- A Title field with the API ID of "title"

- A Rich Text field with the API ID of "summary"

| 84 | 85 | ### Text slice 86 | 87 | The "text" slice contains only a Rich Text field in the non-repeatable section. 88 | 89 | | Property | Description | 90 | | -------------------------------------------------------- | ------------------------------------------------------------------- | 91 | | Primary
non-repeatable |

- A Rich Text field with the API ID of "rich_text"

| 92 | | Items
repeatable |

None

| 93 | 94 | ### Integration 95 | 96 | Here is an example of how to integrate these slices into a landing page. 97 | 98 | ``` 99 | @php 100 | use Prismic\Dom\RichText; 101 | 102 | $returnFaqSlice = function ($slice) use ($linkResolver) { 103 | $html = '
' 104 | . RichText::asHtml($slice->primary->faq_title, $linkResolver); 105 | foreach ($slice->items as $item) { 106 | $html .= '
' 107 | . RichText::asHtml($item->question, $linkResolver) 108 | . RichText::asHtml($item->answer, $linkResolver) 109 | . '
'; 110 | } 111 | $html .= '
'; 112 | return $html; 113 | }; 114 | 115 | $returnFeaturedItemsSlice = function ($slice) use ($linkResolver) { 116 | $html = ''; 125 | return $html; 126 | }; 127 | 128 | $returnTextSlice = function ($slice) use ($linkResolver) { 129 | $html = '
' 130 | . RichText::asHtml($slice->primary->rich_text, $linkResolver) 131 | . '
'; 132 | return $html; 133 | }; 134 | 135 | $slices = $document->data->body; 136 | @endphp 137 | 138 |
139 | @foreach ($slices as $slice) 140 | @switch ($slice->slice_type) 141 | @case ('faq') 142 | {!! $returnFaqSlice($slice) !!} 143 | @break 144 | @case ('featured_items') 145 | {!! $returnFeaturedItemsSlice($slice) !!} 146 | @break 147 | @case ('text') 148 | {!! $returnTextSlice($slice) !!} 149 | @break 150 | @endswitch 151 | @endforeach 152 |
153 | ``` 154 | -------------------------------------------------------------------------------- /docs/03-templating/17-timestamp.md: -------------------------------------------------------------------------------- 1 | # Templating the Timestamp field 2 | 3 | The Timestamp field allows content writers to add a date and time. 4 | 5 | ## Get the Timestamp value 6 | 7 | Timestamp value is a string format as YYYY-MM-DDTHH:MM:SS+0000
(example: 2017-02-17T15:45:00+0000). 8 | 9 | Here is an example that retrieves the value of a Timestamp field with the API ID of `timestamp`. 10 | 11 | ``` 12 | 13 | // Outputs: 2017-02-17T15:45:00+0000 14 | ``` 15 | 16 | ## Format the Timestamp 17 | 18 | You can also output the Timestamp in custom formats. 19 | 20 | Here is an example that outputs a custom format for a Timestamp field with the API ID of `date_and_time`. 21 | 22 | ``` 23 | @php 24 | use Prismic\Dom\Date; 25 | 26 | $timestamp = Date::asDate($document->data->date_and_time); 27 | @endphp 28 | 29 | 30 | // Outputs: 15:45:00 - 17/02/2017 31 | ``` 32 | -------------------------------------------------------------------------------- /docs/03-templating/18-uid.md: -------------------------------------------------------------------------------- 1 | # Templating the UID field 2 | 3 | The UID field is a unique identifier that can be used specifically to create SEO-friendly website URLs. 4 | 5 | ## Get the UID value 6 | 7 | To get the UID value, you just need to access UID property on the retrieved document object as shown below. 8 | 9 | ```java 10 | @php 11 | $uid = $document->uid; 12 | @endphp 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/04-beyond-the-api/01-link-resolving.md: -------------------------------------------------------------------------------- 1 | # Link Resolver 2 | 3 | When working with fields type such as Link or Structured Text, the prismic.io kit will need to generate links to documents within your website. 4 | 5 | ## Define your internal routes 6 | 7 | Since routing is specific to your site, you will need to define it and provide it to some of the methods used on the fields. 8 | 9 | A Link Resolver is provided in every starter kit, but you may need to adapt it or write your own if you're using a different framework. 10 | 11 | ## An example 12 | 13 | Here is an example of a Link Resolver for a Laravel blog site. 14 | 15 | ``` 16 | @php 17 | use Prismic\LinkResolver; 18 | use Prismic\Dom\RichText; 19 | use Prismic\Dom\Link; 20 | 21 | class ExampleLinkResolver extends LinkResolver 22 | { 23 | public function resolve($link) :? string 24 | { 25 | if (property_exists($link, 'isBroken') && $link->isBroken === true) { 26 | return '/404'; 27 | } 28 | if ($link->type === 'category') { 29 | return '/category/' . $link->uid; 30 | } 31 | if ($link->type === 'post') { 32 | return '/post/' . $link->uid; 33 | } 34 | return '/'; 35 | } 36 | } 37 | 38 | $linkResolver = new ExampleLinkResolver(); 39 | @endphp 40 | 41 |
42 | {!! RichText::asHtml($document->data->blog_post, $linkResolver) !!} 43 |
44 | 45 | Click here 46 | ``` 47 | 48 | ## Accessible attributes 49 | 50 | When creating your Link Resolver function when using the API v2, you will have access to certain attributes of the linked document: 51 | 52 | | Property | Description | 53 | | ------------------------------------------------------------ | ------------------------------------------------------- | 54 | | $link->id
string |

The document id

| 55 | | $link->uid
string |

The user-friendly unique id

| 56 | | $link->type
string |

The custom type of the document

| 57 | | $link->tags
array |

Array of the document tags

| 58 | | $link->lang
string |

The language code of the document

| 59 | | $link->isBroken
boolean |

Boolean that states if the link is broken or not

| 60 | -------------------------------------------------------------------------------- /docs/04-beyond-the-api/02-previews-and-the-prismic-toolbar.md: -------------------------------------------------------------------------------- 1 | # Previews and the Prismic Toolbar 2 | 3 | When working in the writing room, you can preview new content on your website without having to publish the document, you can set up one or more websites where the content can be previewed. This allows you to have a production server, staging server, development server, etc.  Discover how to [handle multiple environments in Prismic](https://intercom.help/prismicio/prismic-io-basics/using-multiple-environments-of-one-prismic-repository).
4 | The Toolbar allows you to edit your pages. In your website, just click the button, select the part of the page that they want to edit, and you'll be redirected to the appropriate page in the Writing Room. 5 | 6 | > **New Toolbar Activation for Older Repos** 7 | > 8 | > The current preview toolbar is enabled by default on all new Prismic repos. However, if you're on an older repo, you might be on older version of the toolbar. If your preview script `src` url includes `new=true`, then your preview functionality includes an edit button. If the `src` does not include `new=true` and you would like the new preview toolbar, please [contact us via the Prismic forum](https://community.prismic.io/t/feature-activations-graphql-integration-fields-etc/847) so we can activate it for you. 9 | 10 | ## 1. Configure Previews 11 | 12 | In your repository, navigate to **Settings > Previews**. Here you can add the configuration for a new preview, just add: 13 | 14 | - **The Site Name**: The name of the current site your configuring. 15 | - **Domain URL**: You can add the URL of your live website or a localhost domain, such as: http://localhost:8000. 16 | - **Link Resolver (optional) **: In order to be taken directly to the page you are previewing instead of the homepage, add a Link Resolver which is an endpoint on your server that takes a Prismic document and returns the url for that document. More details on step _3. Add a Link Resolver endpoint._ 17 | 18 | ![](https://images.prismic.io/prismicio-docs-v3/YzI0MDU5ZGEtN2ZhMS00MjRjLWFjNzAtMzkzZTg3MmM5NGRl_7090417a-cf3f-457d-8229-2f8bbc7af4aa_screenshot2020-09-13at20.34.27.pngautocompressformatrect00954834w700h612?auto=compress,format&rect=0,0,700,612&w=960&h=839) 19 | 20 | ## 2. Include the Prismic Toolbar javascript file 21 | 22 | You will need to include the Prismic toolbar script **on every page of your website including your 404 page.** 23 | 24 | You can find the correct script in your repository **Settings** section, under the **Previews** tab. 25 | 26 | **Settings > Previews > Script** 27 | 28 | ``` 29 | 24 | -------------------------------------------------------------------------------- /resources/assets/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | 2 | // Body 3 | $body-bg: #f5f8fa; 4 | 5 | // Borders 6 | $laravel-border-color: darken($body-bg, 10%); 7 | $list-group-border: $laravel-border-color; 8 | $navbar-default-border: $laravel-border-color; 9 | $panel-default-border: $laravel-border-color; 10 | $panel-inner-border: $laravel-border-color; 11 | 12 | // Brands 13 | $brand-primary: #3097D1; 14 | $brand-info: #8eb4cb; 15 | $brand-success: #2ab27b; 16 | $brand-warning: #cbb956; 17 | $brand-danger: #bf5329; 18 | 19 | // Typography 20 | $icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/"; 21 | $font-family-sans-serif: "Raleway", sans-serif; 22 | $font-size-base: 14px; 23 | $line-height-base: 1.6; 24 | $text-color: #636b6f; 25 | 26 | // Navbar 27 | $navbar-default-bg: #fff; 28 | 29 | // Buttons 30 | $btn-default-color: $text-color; 31 | 32 | // Inputs 33 | $input-border: lighten($text-color, 40%); 34 | $input-border-focus: lighten($brand-primary, 25%); 35 | $input-color-placeholder: lighten($text-color, 30%); 36 | 37 | // Panels 38 | $panel-default-heading-bg: #fff; 39 | -------------------------------------------------------------------------------- /resources/assets/sass/app.scss: -------------------------------------------------------------------------------- 1 | 2 | // Fonts 3 | // @import url("https://fonts.googleapis.com/css?family=Raleway:300,400,600"); 4 | 5 | // Variables 6 | // @import "variables"; 7 | 8 | // Bootstrap 9 | // @import "~bootstrap-sass/assets/stylesheets/bootstrap"; 10 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have e-mailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that e-mail address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 20 | 'alpha' => 'The :attribute may only contain letters.', 21 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', 22 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 23 | 'array' => 'The :attribute must be an array.', 24 | 'before' => 'The :attribute must be a date before :date.', 25 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 26 | 'between' => [ 27 | 'numeric' => 'The :attribute must be between :min and :max.', 28 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 29 | 'string' => 'The :attribute must be between :min and :max characters.', 30 | 'array' => 'The :attribute must have between :min and :max items.', 31 | ], 32 | 'boolean' => 'The :attribute field must be true or false.', 33 | 'confirmed' => 'The :attribute confirmation does not match.', 34 | 'date' => 'The :attribute is not a valid date.', 35 | 'date_format' => 'The :attribute does not match the format :format.', 36 | 'different' => 'The :attribute and :other must be different.', 37 | 'digits' => 'The :attribute must be :digits digits.', 38 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 39 | 'dimensions' => 'The :attribute has invalid image dimensions.', 40 | 'distinct' => 'The :attribute field has a duplicate value.', 41 | 'email' => 'The :attribute must be a valid email address.', 42 | 'exists' => 'The selected :attribute is invalid.', 43 | 'file' => 'The :attribute must be a file.', 44 | 'filled' => 'The :attribute field must have a value.', 45 | 'image' => 'The :attribute must be an image.', 46 | 'in' => 'The selected :attribute is invalid.', 47 | 'in_array' => 'The :attribute field does not exist in :other.', 48 | 'integer' => 'The :attribute must be an integer.', 49 | 'ip' => 'The :attribute must be a valid IP address.', 50 | 'ipv4' => 'The :attribute must be a valid IPv4 address.', 51 | 'ipv6' => 'The :attribute must be a valid IPv6 address.', 52 | 'json' => 'The :attribute must be a valid JSON string.', 53 | 'max' => [ 54 | 'numeric' => 'The :attribute may not be greater than :max.', 55 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 56 | 'string' => 'The :attribute may not be greater than :max characters.', 57 | 'array' => 'The :attribute may not have more than :max items.', 58 | ], 59 | 'mimes' => 'The :attribute must be a file of type: :values.', 60 | 'mimetypes' => 'The :attribute must be a file of type: :values.', 61 | 'min' => [ 62 | 'numeric' => 'The :attribute must be at least :min.', 63 | 'file' => 'The :attribute must be at least :min kilobytes.', 64 | 'string' => 'The :attribute must be at least :min characters.', 65 | 'array' => 'The :attribute must have at least :min items.', 66 | ], 67 | 'not_in' => 'The selected :attribute is invalid.', 68 | 'numeric' => 'The :attribute must be a number.', 69 | 'present' => 'The :attribute field must be present.', 70 | 'regex' => 'The :attribute format is invalid.', 71 | 'required' => 'The :attribute field is required.', 72 | 'required_if' => 'The :attribute field is required when :other is :value.', 73 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 74 | 'required_with' => 'The :attribute field is required when :values is present.', 75 | 'required_with_all' => 'The :attribute field is required when :values is present.', 76 | 'required_without' => 'The :attribute field is required when :values is not present.', 77 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 78 | 'same' => 'The :attribute and :other must match.', 79 | 'size' => [ 80 | 'numeric' => 'The :attribute must be :size.', 81 | 'file' => 'The :attribute must be :size kilobytes.', 82 | 'string' => 'The :attribute must be :size characters.', 83 | 'array' => 'The :attribute must contain :size items.', 84 | ], 85 | 'string' => 'The :attribute must be a string.', 86 | 'timezone' => 'The :attribute must be a valid zone.', 87 | 'unique' => 'The :attribute has already been taken.', 88 | 'uploaded' => 'The :attribute failed to upload.', 89 | 'url' => 'The :attribute format is invalid.', 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Custom Validation Language Lines 94 | |-------------------------------------------------------------------------- 95 | | 96 | | Here you may specify custom validation messages for attributes using the 97 | | convention "attribute.rule" to name the lines. This makes it quick to 98 | | specify a specific custom language line for a given attribute rule. 99 | | 100 | */ 101 | 102 | 'custom' => [ 103 | 'attribute-name' => [ 104 | 'rule-name' => 'custom-message', 105 | ], 106 | ], 107 | 108 | /* 109 | |-------------------------------------------------------------------------- 110 | | Custom Validation Attributes 111 | |-------------------------------------------------------------------------- 112 | | 113 | | The following language lines are used to swap attribute place-holders 114 | | with something more reader friendly such as E-Mail Address instead 115 | | of "email". This simply helps us make messages a little cleaner. 116 | | 117 | */ 118 | 119 | 'attributes' => [], 120 | 121 | ]; 122 | -------------------------------------------------------------------------------- /resources/views/404.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 | 5 |
6 |

Page not found

7 |

Sorry we were unable to find the page you are looking for.

8 |

Return to home

9 |
10 | 11 | @stop 12 | -------------------------------------------------------------------------------- /resources/views/layouts/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{-- Meta --}} 5 | 6 | 7 | 8 | 9 | {{-- Meta Title --}} 10 | Laravel starter for prismic.io 11 | 12 | {{-- Scripts --}} 13 | 19 | 20 | 21 | 22 |
23 | @yield('content') 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 17 | return $request->user(); 18 | }); 19 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | input('token'); 27 | if (!isset($token)) { 28 | return abort(400, 'Bad Request'); 29 | } 30 | $url = $request->attributes->get('api')->previewSession($token, $request->attributes->get('linkResolver'), '/'); 31 | return response(null, 302)->header('Location', $url); 32 | }); 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Index route 37 | |-------------------------------------------------------------------------- 38 | */ 39 | 40 | Route::get('/', function () { 41 | return redirect('/tutorial'); 42 | }); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Tutorial route 47 | |-------------------------------------------------------------------------- 48 | */ 49 | 50 | Route::get('/tutorial', function () { 51 | return view('tutorial'); 52 | }); 53 | 54 | /* 55 | |-------------------------------------------------------------------------- 56 | | 404 Page Not Found 57 | |-------------------------------------------------------------------------- 58 | */ 59 | 60 | Route::get('/{path}', function () { 61 | return view('404'); 62 | }); -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 20 | 21 | Hash::driver('bcrypt')->setRounds(4); 22 | 23 | return $app; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | let mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/assets/js/app.js', 'public/js') 15 | .sass('resources/assets/sass/app.scss', 'public/css'); 16 | --------------------------------------------------------------------------------