PHP code example of thyyppa / laravel-filemaker-api

1. Go to this page and download the library: Download thyyppa/laravel-filemaker-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thyyppa / laravel-filemaker-api example snippets


'providers' => [
    // Other Service Providers

    Hyyppa\LaravelFluentFM\Providers\LaravelFluentFMServiceProvider::class,
],

'aliases' => [
    // Other Aliases

    Hyyppa\LaravelFluentFM\Facades\FluentFM::class,
]
  
  
  
use Hyyppa\LaravelFluentFM\Facades\FluentFM;
  
// get a single record as array
$record = FluentFM::record('layout', 'id')->get();

// get multiple records as array
$records = FluentFM::records('layout')->limit(10)->get();  

$bobs = FluentFM::find('customers')->where('first','Bob')->get();

$recordId = FluentFM::create('customers', [
    'id'    => 13
    'first' => 'Robert',
    'last'  => 'Paulson',
    'phone' => '406-555-0112',
]);

// if multiple records are matched each will be updated
FluentFM::update('customers', [ 'phone' => '406-555-0199' ])
        ->where('id',13)
        ->limit(1)
        ->exec();

// hard delete removes record
FluentFM::delete('customers')
        ->where('id',13)
        ->limit(1)
        ->exec();

// soft delete sets record's deleted_at field
FluentFM::softDelete('customers')
        ->where('id',13)
        ->limit(1)
        ->exec();

// undeletes soft deleted records
FluentFM::undelete('customers')
        ->where('id',13)
        ->limit(1)
        ->exec();

// returns matching records that have not been soft deleted
$active = FluentFM::find('customers')
                  ->where('first','Bob')
                  ->withoutDeleted()
                  ->get();

// returns matching records even if soft deleted (default behavior)
$all = FluentFM::find('customers')
               ->where('first','Bob')
               ->withDeleted()
               ->get();

// if query matches multiple, file will be added to each
FluentFM::upload('customers', 'photo', './path/to/photo.jpg')
        ->where('id', 13)
        ->limit(1)
        ->exec();

// if query matches multiple, all files will be downloaded to path
FluentFM::download('customers', 'photo', './save/to/path/')
        ->where('id', 13)
        ->limit(1)
        ->exec();

FluentFM::find('customers')
        ->where('id',13)
        ->script('scriptname', 'parameter')
        ->presort('presort_scriptname', 'presort_scriptparam')
        ->prerequest('prerequest_scriptname', 'prerequest_scriptparam')
        ->get()

...

FluentFM::find( <layout> )
FluentFM::update( <layout>, [fields], [recordId] )
FluentFM::delete( <layout>, [recordId] )
FluentFM::softDelete( <layout>, [recordId] )
FluentFM::undelete( <layout>, [recordId] )
FluentFM::upload( <layout>, <field>, <filename>, [recordId] )
FluentFM::download( <layout>, <field>, [output_dir], [recordId] )

...

->record( <layout>, <id> )
->records( <layout>, [id] )
->limit( <limit> )
->offset( <offset> )
->sort( <field>, [ascending] )
->sortAsc( <field> )
->sortDesc( <field> )
->withPortals()
->withoutPortals()
->where( <field>, <params> ) // multiple calls act as "and"
->orWhere( <field>, <params> )
->whereEmpty( <field> )
->has( <field> )
->whereNotEmpty( <field> )
->withDeleted()
->withoutDeleted()
->script( <script>, [param], [type] )
->prerequest( <script>, [param] )
->presort( <script>, [param] )

...

->get()
->exec()
->create( <layout>, [fields] )
->latest( <layout>, [field] )       # table must have created_at field if [field] undefined 
->oldest( <layout>, [field] )       # table must have created_at field if [field] undefined 
->lastUpdate( <layout>, [field] )   # table must have updated_at field if [field] undefined 
->first()
->last()

...

// set global fields on table
FluentFM::globals( [table], [ key => value ] )

// clear query parameters
FluentFM::clearQuery()

// clear query parameters and reset to default options
FluentFM::reset()
bash
php ./artisan vendor:publish --provider="Hyyppa\\LaravelFluentFM\\Providers\\LaravelFluentFMServiceProvider"