├── .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 | {{ RichText::asText($document->data->title) }}
79 |
80 |
|
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 highestIt will automatically order the field from lowest to highest
| 123 | | highest to lowestUse "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_dateThe date that the document was originally published for the first time
| 149 | | last_publication_dateThe 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 | | valueinteger
| 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 | | valueinteger
| 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 | | valuestring
| 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-typestring
| (required) The API-ID of the custom type you are searching for
| 18 | | uidstring
| (required) The UID of the document you want to retrieve
| 19 | | optionsarray
| (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 | | idstring
| (required) The id of the document you want to retrieve
| 51 | | optionsarray
| (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 | | idsarray
| (required) An array of strings with the ids of the documents you want to retrieve
| 83 | | optionsarray
| (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-typestring
| (required) The API ID of the single custom type you want to retrieve
| 117 | | optionsarray
| (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 highestIt will automatically order the field from lowest to highest
| 12 | | highest to lowestUse "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 | | pageThe current page of the pagination of the results
| 62 | | results_per_pageThe number of documents per page of the pagination
| 63 | | results_sizeThe number of documents on this page of the pagination results
| 64 | | total_results_sizeThe total number of documents returned from the query
| 65 | | total_pagesThe total number of pages in the pagination of the results
| 66 | | next_pageThe next page number in the pagination
| 67 | | prev_pageThe previous page number in the pagination
| 68 | | resultsThe 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.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 | tag
58 | if ($element->type === 'image') {
59 | return '';
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 |
{{ $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 | | Primarynon-repeatable
| - A Rich Text field with the API ID of "rich_text"
| 24 | | Itemsrepeatable
| 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 | | Primarynon-repeatable
| - A Title field with the API ID of "gallery_title"
| 33 | | Itemsrepeatable
| - 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 |non-repeatable
| - A Title field with the API ID of "faq_title"
| 74 | | Itemsrepeatable
| - 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 | | Primarynon-repeatable
| None
| 83 | | Itemsrepeatable
| - 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 | | Primarynon-repeatable
| - A Rich Text field with the API ID of "rich_text"
| 92 | | Itemsrepeatable
| 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 = 'string
| The document id
| 55 | | $link->uidstring
| The user-friendly unique id
| 56 | | $link->typestring
| The custom type of the document
| 57 | | $link->tagsarray
| Array of the document tags
| 58 | | $link->langstring
| The language code of the document
| 59 | | $link->isBrokenboolean
| 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).Sorry we were unable to find the page you are looking for.
8 | 9 |