Skip to content

Commit b75b54d

Browse files
Merge branch 'feature/adjust-docs-highlighting' into dev
2 parents 16af11a + da4c163 commit b75b54d

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

README.md

+33-31
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ composer require gearbox-solutions/eloquent-filemaker
4141
With the package installed you can now have access to all the features of this package. There are a few different areas to configure.
4242

4343
## Database configuration
44-
The first thing to do is to add a new data connection in your ```database.php``` config file. The connections you specify here will be used in your FMModel classes to configure which databases each model will connect to.
44+
The first thing to do is to add a new data connection in your `database.php` config file. The connections you specify here will be used in your FMModel classes to configure which databases each model will connect to.
4545

4646
You may use the following code block below as a template.
47-
48-
'filemaker' => [
49-
'driver' => 'filemaker',
50-
'host' => env('DB_HOST', 'fms.mycompany.com'),
51-
'database' => env('DB_DATABASE', 'MyFileName'),
52-
'username' => env('DB_USERNAME', 'myusername'),
53-
'password' => env('DB_PASSWORD', ''),
54-
'prefix' => env('DB_PREFIX', ''),
55-
'version' => env('DB_VERSION', 'vLatest'),
56-
'protocol' => env('DB_PROTOCOL', 'https'),
57-
]
58-
47+
```php
48+
'filemaker' => [
49+
'driver' => 'filemaker',
50+
'host' => env('DB_HOST', 'fms.mycompany.com'),
51+
'database' => env('DB_DATABASE', 'MyFileName'),
52+
'username' => env('DB_USERNAME', 'myusername'),
53+
'password' => env('DB_PASSWORD', ''),
54+
'prefix' => env('DB_PREFIX', ''),
55+
'version' => env('DB_VERSION', 'vLatest'),
56+
'protocol' => env('DB_PROTOCOL', 'https'),
57+
]
58+
```
5959
You should add one database connection configuration for each FileMaker database you will be connecting to. Each file can have completely different configurations, and can even be on different servers.
6060

6161
Sessions will be maintained on a per-connection basis and tokens will automatically be cached using whatever cache configuration you have set up for your Laravel app.
@@ -100,17 +100,17 @@ This package supports both reading and writing container field data. Container f
100100
#### Writing to container fields
101101
When setting a container field you should set the value to be an `Illuminate/HTTP/File` or `Illuminate/HTTP/UploadedFile` object. These attributes will be written back to your container fields along with any other model updates when the `save()` method is called on your model object.
102102
```php
103-
$file = new File(storage_path('app/public/gator.jpg'));
104-
$newPet->photo = $file;
105-
$newPet->save();
103+
$file = new File(storage_path('app/public/gator.jpg'));
104+
$newPet->photo = $file;
105+
$newPet->save();
106106
```
107107

108108
#### Custom filenames when inserting files into containers
109109
By default, files are inserted into containers using the filename of the file you are inserting. If you wish to set a new filename when the file is inserted into the container you can do so by passing the file and filename together in an array when setting your container.
110110
```php
111-
$file = new File(storage_path('app/public/gator.jpg'));
112-
$newPet->photo = [$file, 'fluffy.jpg'];
113-
$newPet->save();
111+
$file = new File(storage_path('app/public/gator.jpg'));
112+
$newPet->photo = [$file, 'fluffy.jpg'];
113+
$newPet->save();
114114
```
115115

116116
### Renaming and Mapping FileMaker Fields
@@ -125,7 +125,7 @@ protected $fieldMapping = [
125125
and then you can get/set the attributes via....
126126

127127
```php
128-
$myModel->a_much_better_name = 'my new value';
128+
$myModel->a_much_better_name = 'my new value';
129129
```
130130

131131
### Fields from related records
@@ -169,23 +169,25 @@ $person->person_pet_portal[1]['person_PET::type'] = 'cat';
169169
This package has special handling for casting FileMaker Timestamp and Date fields to Carbon instances for you. To take advantage of this, you must map the fields as you would with a native Laravel Model class. You can use the `$casts` property as you normally would for these attributes.
170170

171171
```php
172-
protected $casts = [
173-
'nextAppointment' => 'datetime',
174-
'birthday' => 'date',
175-
];
172+
protected $casts = [
173+
'nextAppointment' => 'datetime',
174+
'birthday' => 'date',
175+
];
176176
```
177177

178178
The format Date and Timestamp fields written to FileMaker can be changed via the `$dateFormat` property of your model. This value must be compatible with the format output from the FileMaker Data API for Timestamp values and will be the format written back into your database. One important requirement is that this must be a full timestamp format, not just a date format.
179179

180180
Here are some example formats:
181181
```php
182-
protected $dateFormat = 'n/j/Y g:i:s A'; // 7/1/1920 4:01:01 PM
183-
protected $dateFormat = 'n/j/Y G:i:s'; // 7/1/1920 16:01:01
182+
protected $dateFormat = 'n/j/Y g:i:s A'; // 7/1/1920 4:01:01 PM
183+
protected $dateFormat = 'n/j/Y G:i:s'; // 7/1/1920 16:01:01
184184
```
185185

186186

187187
## Example FMModel Class
188188
```php
189+
// Person.php
190+
189191
class Person extends FMModel
190192
{
191193

@@ -206,7 +208,6 @@ class Person extends FMModel
206208
}
207209

208210
}
209-
210211
```
211212

212213
# The Base Query Builder and the FM Facade
@@ -301,9 +302,9 @@ $result = FM::layout('MyLayoutName')->performScript('MyScriptName');
301302
Run a script with JSON data as a parameter
302303
```php
303304
$json = json_encode ([
304-
'name' => 'Joe Smith',
305-
'birthday' => '1/1/1970'
306-
'favorite_color' => 'blue'
305+
'name' => 'Joe Smith',
306+
'birthday' => '1/1/1970'
307+
'favorite_color' => 'blue'
307308
]);
308309

309310
$result = FM::layout('globals')->performScript('New Contact Request'; $json);
@@ -317,7 +318,6 @@ $result = FM::connection('MyOtherDatabaseConnectionName')->layout('MyLayoutName'
317318
Create a record with an array of field data and then perform a script after record creation, within the same request
318319
```php
319320
FM::layout('MyLayoutName')->script('ScriptName')->fieldData($data)->createRecord();
320-
321321
```
322322

323323
## Logging out, disconnecting, and ending your Data API session
@@ -347,6 +347,8 @@ Once they're set correctly, you can create relationships, such as a belongsTo, b
347347
Here is an example of setting a native Laravel User Model to belong to a FileMaker-based Company FMModel class.
348348

349349
```php
350+
// User.php
351+
350352
class User extends Model
351353
{
352354
public function company()

0 commit comments

Comments
 (0)