Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Voyager is super easy to install. After creating your new Laravel application you can include the Voyager package with the following command:
Next make sure to create a new database and add your database credentials to your .env file, you will also want to add your application URL in the APP_URL
variable:
Using Laravel 5.4? If you are installing with Laravel 5.4 you will need to add the Service Provider manually. Otherwise, if you are on 5.5 this happens automatically thanks to package auto-discovery.
Finally, we can install Voyager. You can choose to install Voyager with dummy data or without the dummy data. The dummy data will include 1 admin account (if no users already exist), 1 demo page, 4 demo posts, 2 categories and 7 settings.
To install Voyager without dummy data simply run
If you prefer installing it with the dummy data run the following command:
Specified key was too long error If you see this error message you have an outdated version of MySQL, use the following solution: https://laravel-news.com/laravel-5-4-key-too-long-error
And we're all good to go!
Start up a local development server with php artisan serve
And, visit the URL http://localhost:8000/admin in your browser.
If you installed with the dummy data, a user has been created for you with the following login credentials:
email:
admin@admin.com
password:password
Quick note A dummy user is only created if there are no current users in your database.
If you did not go with the dummy user, you may wish to assign admin priveleges to an existing user. This can easily be done by running this command:
If you wish to create a new admin user you can pass the --create
flag, like so:
And you will be prompted for the users name and password.
This section is meant for users who are installing Voyager on an already existing Laravel installation or for users who want to perform a manual install. If this is not the case, you should go back to the installation documentation or skip this section.
The first thing you should do is publish the assets that come with Voyager. You can do that by running the following commands:
This is only required if you are using Laravel 5.4! If you are on Laravel 5.5+ you can skip this step.
To add the Voyager Service Provider open up your application config/app.php
file and add TCG\Voyager\VoyagerServiceProvider::class,
in the providers
array like so:
After running the voyager installer you will see a few new routes that have been added to your routes/web.php
file which look like the following:
This is where the Voyager routes will be rendered. You can change the admin
prefix if you desire, or set any other route configuration you need, such as middleware
or domain
.
When creating a new BREAD type and specifying a slug for that BREAD, you can then visit that route from the following link:
As an example, if we have a products
table and we specified the slug to be products
. You will now be able to visit the following URL:
Notice You may not see a link to your newly created routes or BREAD inside your admin menu. To create a new link in your admin menu visit the documentation for the menu section.
With the installation of Voyager you will find a new configuration file located at config/voyager.php
.
In this file you can find various options to change the configuration of your Voyager installation.
If you cache your configuration files please make sure to run php artisan config:clear
after you changed something.
Below we will take a deep dive into the configuration file and give a detailed description of each configuration set.
add_default_role_on_register: Specify whether you would like to add the default role to any new user that is created. default_role: You can also specify what the default_role is of the user. admin_permission: The permission needed to view the admin dashboard. namespace: The namespace of your apps User Class. redirect: Redirect path after the user logged in.
You can specify the default controller
namespace of Voyager. If you ever wish to override any of the core functionality of Voyager you can do so by duplicating the Voyager controllers and specifying the location of your custom controllers.
Overwrite a single controller
If you only want to overwrite a single controller, you might consider adding the following piece of code to your AppServiceProvider
class in the register
method.
$this->app->bind(VoyagerBreadController::class, MyBreadController::class);
You can specify the namespace or location of your models. This is used when creating the Models from the database section of Voyager. If not defined the default application namespace will be used.
You may wish to specify a different asset path. If your site lives in a subfolder you may need to include that directory to the beginning of the path. This may also be used in case you wish to duplicate the published assets and customize your own.
When upgrading to new version of voyager the assets located in the /vendor/tcg/voyager/assets
directory may need to be overwritten, so if you wish to customize any styles you will want to duplicate that directory and specify the new location of your asset_path.
By default Voyager is going to use the public
local storage. You can additionally use any driver inside of your config/filesystems.php
. This means you can use S3, Google Cloud Storage, or any other file storage system you would like.
You may wish to hide some database tables in the Voyager database section. In the database config you can choose which tables would like to hide.
You can specify whether or not you want to enable mutliple languages. You can then specify your default language and all the support languages (locales)
Read more about multilanguage here.
In the dashboard config you can add navbar_items, make the data_tables responsive, and manage your dashboard widgets.
navbar_items Include a new route in the main user navbar dropdown by including a 'route', 'icon_class', and 'target_blank'.
data_tables If you set 'responsive' to true the datatables will be responsive.
widgets Here you can manage the widgets that live on your dashboard. You can take a look at an example widget class by viewing the current widgets inside of tcg/voyager/src/Widgets
.
The default primary color for the Voyager admin dashboard is a light blue color. You can change that primary color by changing the value of this config.
In the Voyager admin there are developer tips or notifications that will show you how to reference certain values from Voyager. You can choose to hide these notifications by setting this configuration value to false.
You can add your own custom stylesheets that will be included in the Voyager admin dashboard. This means you could technically create a whole new theme for Voyager by adding your own custom stylesheet.
Read more here.
The path will be passed to Laravels asset function.
The same goes for this configuration. You can add your own javascript that will be executed in the Voyager admin dashboard. Add as many javascript files as needed.
Read more here.
There is a new data type called coordinates that allow you to add a google map as a datatype. The user can then drag and drop a pin in the Google Maps to save a longitude and latitude value in the database.
In this config you can set the default Google Maps Keys and center location. This can also be added to your .env file.
Before installing Voyager it is very important to take a quick moment to learn what it is & what it isn't.
An admin interface for your Laravel app
An easy way to add/edit/delete data for your app
A menu builder (build menus in Voyager for your app)
A media manager for your files
CRUD/BREAD generator (learn more about BREAD here)
Voyager is simply an admin for your Laravel app. Whatever you want your app to do on the front-end is completely up to you. You are in control of your application and you can use Voyager to make your life easier by adding data, editing users, creating menus, and many other administrative tasks.
A content management system (CMS)
A blogging platform
Wordpress (Bleh! 😜)
Voyager is not a CMS or a blogging platform. But it can be used to create a CMS or a blogging platform, but out of the box it is neither of those. As stated in the previous section you have full control on what your application will do and how it will function.
With Laravel & Voyager you can create any kind of application your heart desires. Laravel & Voyager are simply tools to make it easier to build.
To update to the latest version inside of your composer.json file make sure to update the version of voyager inside the require declaration inside of your composer.json to:
"tcg/voyager": "1.1.*"
And then run composer update
You will now need to run the following migrations to include new tables or rows that have been added to the latest version. you can find each of these migrations below:
You can do this by adding each of those migrations to your database/migrations
folder and then run php artisan migrate
The voyager.php
configuration file has had a few changes. The prefix
key has been removed in favor of the user.redirect
key. Please note that the user.redirect
key should be prefixed with a slash (/
), unlike the original prefix
key.
Multi-roles is a new feature come by in v1.1 that allows you to have multiple roles and one primary role. You can fetch the user's primary role like normally using this:
But now you can also use the new belongsToMany roles relationship to fetch all extra roles:
Besides that there is a helper to get all the roles, both the primary and the extra roles:
Please note, that you do not have to use the multi-roles and you can continue to use the primary role without any changes.
Also, make sure that you add the new data row into the database for the users
data type. Insert a new row of data in the data_rows
table. Make sure that it's data_type_id
is the ID for the users
data type, normally this would be ID 3
, but better make sure it is correct.
Then make sure the other fields are like below:
The BREAD and Database section in Voyager has been separated into two sections. So in order to get access to the BREAD section using the menu, make sure to add the following menu item:
However, you might still not be able to see it, because it requires permission, so go ahead and create a new row in the permissions
table with the key
being browse_bread
, leave the table_name
to be null
.
You should now be able to access the BREAD section.
If you have not translated any of the Voyager language strings, you may skip this step.
Voyager have changed its translations strings from being like __('voyager.generic.close')
to be prefixed with the voyager::
group.
Meaning that you would have to update your translated strings inside resources/lang/LOCALE.json
to use the new prefix.
Next, you may want to be sure that you have all the latest published assets. To re-publish the voyager assets you can run the following command:
Then you may wish to clear your view cache by running the following command:
Be sure to ask us on our slack channel if you are experiencing any issues and we will try and assist. Thanks.
Voyager has a full-fledged Media Manager which allows you to upload files, re-name files, and delete files. You can also add new folders and move files/folders. Basically anything that you would be able to do in any type of Media Manager you can do so in the Voyager Media Manager.
You may also drag and drop files onto the 'upload' button to upload multiple files.
Notice on File Upload Size
If you are getting an error when trying to upload large files, this may be a setting that needs to be changed in your PHP. Be sure to check max_file_upload
and file_upload_size
Welcome to the Voyager documentation for version 1.1. This documentation will teach you how to install, configure, and use Voyager so that way you can create some kick ass stuff!
Hm Hm (cough)… I mean… Arrgg! Ye young scallywag! What say we learn how to steer this ship!
Before installing Voyager you may want to take a quick moment to learn what is is and what it isn't, we'll do that in the next section.
When adding or editing the current BREAD for a database table you will first see the BREAD info which allows you to set the Display Names, slug, icon, Model
and Controller Namespace, Policy Name. You can also choose if you would like to Generate permissions for that BREAD type.
When you scroll down you will see each of the rows that are associated with that table where you can select where in your views you want to see each of those fields:
BROWSE (field will show up when you browse the current data)
READ (field will show when you click to view the current data)
EDIT (field will be visible and allow you to edit the data)
ADD (field will be visible when you choose to create a new data type)
DELETE (doesn't pertain to delete so this can be checked or unchecked)
You may also choose to specify what form type you want to use for each field. This can be a TextBox, TextArea, Checkbox, Image, and many other types of form elements.
Each field also has additional details or options that can be included. These types are checkbox, dropdown, radio button, and image.
When Editing Your Browse, Read, Edit, Add, and Delete Rows you have a select box that allows you to include additional details or options for your datatype. This textarea accepts JSON and it applies to the following types of inputs:
Text (Text Box, Text Area, Rich Textbox and Hidden)
Check Box
Drop Down
Radio Button
Image
Date
Find out how to use these additional details below:
Text Box, Text Area, Rich Textbox and Hidden are all kind of texts inputs. In the JSON above you can specify the default
value of the input.
In Voyager a Check Box is converted into a toggle switch, and as you can see above the on
key will contain the value when the toggle switch is on, and the off
will contain the value that is set when the switch is off. If checked
is set to true the checkbox will be toggle on; otherwise by default it will be off.
When specifying that an input type should be a dropdown you will need to specify the values of that dropdown. In the JSON above you can specify the default
value of the dropdown if it does not have a value. Additionally, in the options
object you will specify the value of the option on the left and the text to be displayed on the right.
The Radio button is exactly the same as the dropdown. You can specify a default
if one has not been set and in the options
object you will specify the value of the option on the left and the text to be displayed on the right.
The image input has many options. By default if you do not specify any options no problem... Your image will still be uploaded. But, if you want to resize an image, set the quality of the image, or specify thumbnails for the uploaded image you will need to specify those details.
resize If you want to specify a size you will need to include that in the resize
object. If you set either height or width to null it will keep the aspect ratio based on the width or height that is set. So, for the example above the width
is set to 1000
pixels and since the height
is set to null
it will resize the image width to 1000 pixels and resize the height based on the current aspect ratio.
quality If you wish to compress the image with a percentage quality you can specify that percentage in the quality
key. Typically between 70 and 100% there is little notice of image quality, but the image size may be dramatically lower.
upsize This is only valid if you have set your image to be resized. If you specify your image to resized to 1000 pixels and the image is smaller than 1000 pixels by default it will not upsize that image to the 1000 pixels; however, if you set upsize
to true. It will upsize all images to your specified resize values.
thumbnails Thumbnails takes an array of objects. Each object is a new thumbnail that is created. Each object contains 2 values, the name
and scale
percentage. The name
will be attached to your thumbnail image (as an example say the image you uploaded was ABC.jpg a thumbnail with the name
of medium
would now be created at ABC-medium.jpg). The scale
is the percentage amount you want that thumbnail to scale. This value will be a percentage of the resize width and height if specified.
The date & timestamp input field is where you can input a date. In the JSON above you can specify the format
value of the output of the date. It allows you to display a formatted date
in browse and read views, using Carbon's formatLocalized()
method
All types can include a description in order to help your future self or other users using your Voyager admin panel to understand exactly what a specific BREAD input field is for, this can be defined in the Optional Details
JSON input field:
Inside of the Optional Details section for each row in your BREAD you can also specify validation rules with some simple JSON. Here is an example of how to add a validation rule or required and max length of 12
Additionally, you may wish to add some custom error messages which can be accomplished like so:
Since v0.10.13
you can do the required
and max:12
rule the following way:
Using the bread builder you may wish to automatically generate slugs of a certain input. Lets say you have some posts, which have a title and a slug. If you want to automatically generate the slug from the title attribute, you may include the following Optional Details:
This will automatically generate the slug from the input of the title
field. If a slug does already exists, it will only be updated if forceUpdate
is set enabled, by default this is disabled.
Using the BREAD builder you can easily create Relationships between tables. At the bottom of the page you will see a new button that says 'Create Relationship'
Notice If you have not yet created the BREAD for the table yet, it will need to be created first and then you can come back after creating the BREAD to add the relationship. Otherwise you'll end up with a notification which looks like the following.
So, after the BREAD has already been created you will then be able to create a new relationship. After you click on the 'Create a Relationship' button. You will see a new Modal window that looks like the following:
You will first specify which type of relationship this is going to be, then you will select the table you are referencing and which Namespace that belongs to that table. You will then select which row combines those tables.
You can also specify which columns you would like to see in the dropdown or the multi-select.
Now, you can easily create belongsTo
, belongsToMany
, hasOne
, and hasMany
relationships directly in Voyager.
Tagging gives you the possibility to add new items to a Belongs-To-Many relationship directly when editing or adding a BREAD.
To activate this function, you simply have to enable Tagging
in the relationship details
After that you can enter a free-text into the select and hit enter to save a new relationship.
Be aware:
This only stores the display-column
so you have to make sure that all other fields are either nullable or have a default value.
You might want to save an input field into the database as a null
value instead of an empty string.
Simply enough, inside the BREAD you can include the following Optional Details for the field:
This will turn an empty string into a null
value. However you might want to be able to add both an empty string and a null
value to the database for that field. However you have to choose a replacement for the null
value, but it can be anything you wish. For example, if you want a field to change a string (ex. Nothing
) into a null
value you could include the following Optional Details for that field:
Now entering Nothing
into the field will end up as a null
value in the database.
There are also a few options that you can include to change the way your BREAD is displayed. You can add a display
key to your json object and change the width of the particular field and even specify a custom ID.
The width is displayed on a 12-grid system. Setting it with a width of 3 will span 25% of the width.
The id will let you specify a custom id wrapper around your element. example:
You can define the default order for browsing BREADs and order your BREAD items with drag-and-drop. For this you need to change the settings for your BREAD first:
Order column is the field in your table where the order is stored as an integer. Order display column is the field which is shown in the drag-drop list. Order direction the direction in which the field is ordered.
After this you can go to your BREAD-browse page and you will see a button Order. Clicking this button will bring you to the page where you can re-arrange your items:
Voyager comes with Roles and Permissions out of the box. Each User has a Role which has a set of Permissions.
Inside of the dashboard you can choose to Add, Edit, or delete the current Roles. Additionally when you click to edit a particular role you can specify the BREAD permissions.
New in version 1.0, we've changed Voyager's authorization system to be ! This means that you can check for permissions in the following ways:
You may also choose to use the Voyager facade and pass the permission as a string:
The value of each check will return a boolean whether or not the user has that certain permission. However you might wish to throw a forbidden exception if the user does not have a certain permission. This can be done using the canOrFail
method:
Out of the box there are some permissions you can use by default:
browse_admin
: Whether or not the user may browse the Voyager admin panel.
browse_database
: Whether or not the user may browse the Voyager database menu section.
browse_bread
: Whether or not the user may browse the Voyager BREAD menu section.
browse_media
: Whether or not the user may browse the Voyager media section.
browse_menu
: Whether or not the user may browse the Voyager menu section.
browse_settings
: Whether or not the user may browse the Voyager settings section.
read_settings
: Whether or not the user can view or see a particular setting.
edit_settings
: Whether or not the user can edit a particular setting.
add_settings
: Whether or not the user can add a new setting.
delete_settings
: Whether or not the user can delete a particular setting.
Additionally you can Generate permissions
for every BREAD type you create. This will create the browse
, read
, edit
, add
and delete
permission.
As an example, perhaps we are creating a new BREAD type from a products
table. If we choose to Generate permissions
for our products
table. Our permission keys will be browse_products
, read_products
, edit_products
, add_products
and delete_products
.
Notice
If a menu item is associated with any kind of BREAD, then it will check for the browse
permission, for example for the Posts
BREAD menu item, it will check for the browse_posts
permission. If the user does not have the required permission, that menu item will be hidden.
You can also check for permissions using blade syntax. Let's say for instance that you want to check if a user can browse_posts
, simple enough we can use the following syntax:
Or perhaps you need to run an else condition for a permission. That's simple enough:
Couldn't be easier, right ;)
The Settings section allows you to add any site wide settings you would like. You can add an image upload setting for your site logo or a text box for the main headline on your homepage.
In this new version you have the ability to add different groups for different settings. So, if you created a new setting inside of the site
group and it had a key of title
you would then be able to reference that setting any where on your site by doing the following:
Or inside of any blade template like:
So, now you can add all kinds of settings in Voyager and reference them in your application.
With Voyager you can easily create menus for your application. In fact the Voyager admin is using the menu builder for the navigation you use on the left hand side.
You can view your current Menus by clicking on the Tools->Menu Builder button. You can add, edit, or delete any current menu. This means that you can create a new menu for the header, sidebar, or footer of your site. Create as many menus as you would like.
When you are ready to add menu items to your menu you can click on the builder button of the corresponding menu:
This will take you to the Menu Builder where you can add, edit, and delete menu items.
After creating and configuring your menu, you can easily implement that menu in your application. Say that we have a menu called main
. Inside of any view file we could now output the menu by using the following code:
This will output your menu in an unstyled unordered list. If you do use bootstrap to stylize your web app you can pass a second argument to the menu display method telling it that you want to stylize the menu with bootstrap styles like so:
Taking it one more step further you can even specify your own view and stylize your menu however you would like. Say for instance that we had a file located at resources/views/my_menu.blade.php
, which contained the following code:
Then anywhere you wanted to display your menu you can now call:
And your custom menu will now be output.
If you dont want to render your menu but get an array instead, you can pass _json
as the second parameter. For example:
This will give you a collection of menu-items.
Voyager has some awesome database tools which allow you to Add/Edit/Delete or view current database tables. The other cool part of Voyager is that you can add BREAD or (Browse, Read, Edit, Add, & Delete) functionality to any of your tables.
Inside of your admin panel you can visit Tools->Database and you'll be able to view all your current tables in your database. You may also click on 'Create a New Table' to create a new table in your database. All newly created tables will use the charset defined in your .
If you click the table name you can view the current schema. Additionally you can click on the View, Edit, or Delete buttons to perform that action for that table.
You may also choose to Add BREAD (Browse, Read, Edit, Add, & Delete) for any of your database tables. Once a table already has BREAD you may choose to edit the current BREAD or Delete the BREAD for that table.
Read on further about the BREAD builder in the next section.
The Compass section is a quick place for you to go for some link references, font references, run some commands or view some logs.
In the first tab you will see a few link resources and you will see all the fonts that you can use inside of Voyager.
In the Command section you can actually run some artisan commands directly from Voyager.
And Lastly, under the Logs tab you will be able to view all your application logs.
You can find a list of all available validation rules in the .
field
user_belongstomany_role_relationship
type
relationship
display_name
Roles
required
0
browse
1
read
1
edit
1
add
1
delete
0
details
{"model":"TCG\\Voyager\\Models\\Role","table":"roles","type":"belongsToMany","column":"id","key":"id","label":"name","pivot_table":"user_roles","pivot":"1"}
order
11
You can override any Voyager routes by writing the routes you want to overwrite below Voyager::routes()
. For example if you want to override your post LoginController:
As of the latest version you can now add additional CSS and JS files to the voyager master blade without having to copy or modify the blade file itself removing potential manual migration headaches later on. The CSS and JS files are added after any Voyager assets so you can override styles and functionality comfortably.
This is all handled via the voyager.php
config file:
The path will be passed to Laravels asset function.
This is only to assist with enabling soft-deletion for your models within Voyager. Please refer to the Laravel documentation for specifics.
When creating a table using the Database Manager you've selected the 'Add Soft Deletes' button and then when adding the BREAD functionality to that table you've added a Model Name, you only have to edit your Model file to fully enable Soft-Delete on that table.
A default model will look like this:
Just turn it into:
And from now on, every time you delete a record from that table, it won't actually be deleted, only the deleted_at
column will be written with the current timestamp.
Voyager has several helper functions that are ready to use. Here you can find the list of available function that may speed up your development.
Voyager will generate thumbnails for Image field type when you specify the additional field options.
After you have your thumbnails generated, you may want to display the thumbnails in your view or get the thumbnail URL. In order to do that you need to add Resizable
traits to your model.
Or you can specify the optional image field name (attribute), default to image
Voyager supports multiple languages for your models.To get started, you need to configure some things first.
First you need to define some locales
in your config/voyager.php
file and enable
multilanguage:
After that you need to include the Translatable
Trait in your model and define the translatable attributes:
Now you will see a language-selection in your Pages BREAD.
If you do not define locale, the current application locale will be used. You can pass in your own locale as a string. If you do not define fallbackLocale, the current application fallback locale will be used. You can pass your own locale as a string. If you want to turn the fallback locale off, pass false. If no values are found for the model for a specific attribute, either for the locale or the fallback, it will set that attribute to null.
If you do not define locale, the current application locale will be used. You can pass in your own locale as a string. If you do not define fallbackLocale, the current application fallback locale will be used. You can pass in your own locale as a string. If you want to turn the fallback locale off, pass false. If no values are found for the model for a specific attribute, either for the locale or the fallback, it will set that attribute to null.
This will update or create the translation for title of the post with the locale da. Please note that if a modified attribute is not translatable, then it will make the changes directly to the model itself. Meaning that it will overwrite the attribute in the language set as default.
You can override any of the BREAD views for a single BREAD by creating a new folder in resources/views/vendor/voyager/slug-name
where slug-name is the slug that you have assigned for that table. There are 4 files that you can override:
browse.blade.php
edit-add.blade.php
read.blade.php
order.blade.php
Alternatively you can override the views for all BREADs by creating any of the above files under resources/views/vendor/voyager/bread
You can override the controller for a single BREAD by creating a controller which extends Voyagers controller, for example:
After that go to the BREAD-settings and fill in the Controller Name with your fully-qualified class-name:
You can now override all methods from the VoyagerBaseController
If you want to override any of Voyagers core controllers you first have to change your config file config/voyager.php
:
Then run php artisan voyager:controllers
, Voyager will now use the child controllers which will be created at App/Http/Controllers/Voyager
You are also able to override Voyagers models if you need to. To do so, you need to add the following to your AppServiceProviders register method:
Where name is the class-name of the model and object the fully-qualified name of your custom model. For example:
The next step is to create your model and make it extend the original model. In case of DataRow
:
With Voyager 1.1 you are able to define additional attributes which you can show in a relationship.
For example a Post
has an Author
and you want to display the Users
full-name. To do so, we first need to
After that we need to tell Voyager that there is an accessor we want to use:
Thats it! You can now select full_name
in your Relationship.
If you want to customize TinyMCE within Voyager, you can do so by adding a to your config.
In this file you have to define a function like
Now you can control the TinyMCE instance(s) on the page. For all possible variables and functions, please refer to the .
Symptom: You get an error page saying
Cause: There are two possible causes:
1. You dont have a primary-key for your table
2. You have a primary-key but it's not called id
Solution: As there are two causes, there are also two solutions: 1. Simply create a field id
for the table
2. Tell your model about your primary-key: protected $primaryKey = 'your_primary_key';
Please consider following
You can easily add a new Formfield to Voyager. In the example below we will add a number form field (which is already included by default in Voyager).
First we create a new class in our project (it doesn't matter where it is placed) called NumberFormField
The codename
variable is used in the dropdown you see in the BREAD builder. In the createContent
method we are returning the view that is used to display our form field.
Next, we will create the view specified above.
In the view we can add whatever logic we want.
When we are done with our view, we will tell Voyager that we have a new form field. We will do this in a service provider (in the example below we use the AppServiceProvider
.
Symptom: When visiting your site with HTTPS, images within Voyager fail to load.
Cause: Images urls are generated by Voyager using
If voyager.storage.disk is set to public, and the public disk is the default from Laravel, then the url property in the disk configuration is set to
which uses the non-HTTPS APP_URL value to build an absolute url to the image.
Solution: If you remove env('APP_URL'). from the public disk configuration, then it will render a domain-relative url, which will always use the current domain and protocol.
As an aside, if you need a fully-qualified URL, you could wrap the call to Voyager::image('...')
with asset()
, so it would be
This will return the current protocol, domain, and correct path to that image.
With Voyager you are able to store coordinates and select them from a map.
To do so, you first need to make sure that the column in your table is either GEOMETRY
or POINT
.
After that you have to include the Spatial-Trait in your Model and define the column:
Now you can go to the tables BREAD-settings and set your field to be Coordinates
.
After that you will get a Map where you can select your Coordinates.
Make sure to set the Google Maps API-Key in your . This is also the place where you can define the default location of your map.
You can get the coordinates from your model by calling
This will return an array of coordinates with lat
as the latitude and lng
as the longitude.