2017 © Pedro Peláez
 

library laravel-flywheel

a laravel wrapper for the flywheel package

image

allenjd3/laravel-flywheel

a laravel wrapper for the flywheel package

  • Saturday, August 12, 2017
  • by jdallen5
  • Repository
  • 1 Watchers
  • 1 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Laravel Flywheel

This is a wrapper class for the Jamesmoss/flywheel package., (*1)

A laravel facade for flat file documents

This is a facade that can be used beside the default laravel database structure. Since this doesn't override Laravel's core database functionality you can use both at the same time., (*2)

installation

composer require allenjd3\laravel-flywheel

Then add to your config/app file under application providers, (*3)

'providers' => [
    ...
        /*
        * Package Service Providers...
        */
        Allenjd3\Flywheel\FlywheelServiceProvider::class,
    ...
]

If you want to use the Facade then add this to your aliases array, (*4)

'aliases' => [
    ... 
    'Flywheel' => Allenjd3\Flywheel\facades\Flywheel::class,
    ...

]

Methods

Config

This method is optional if you want to change either the table name or storage path, (*5)

Example- (optional), (*6)

$flywheel = Flywheel::config($name, $path);
$flywheel->findAll();

Create

This method creates a new Document and saves it to your path. You can use laravel validation on the request before running this., (*7)

$id = Flywheel::create($array)

Update / findById

This method updates a post. You must find the post by id before updating it., (*8)

$doc = Flywheel::findById($id);
$doc->param = "new value";
Flywheel::update($doc);

findAll

This method finds all documents within the given configuration path, (*9)

$docs = Flywheel::findAll();

Delete

This method deletes a post that matches a given id., (*10)

Flywheel::delete($id)

Where / get

This method returns a query object that can be chained, (*11)

$docs = Flywheel::where('title', '==', 'Shiver Me Timbers')->get();

Get ends the queries and executes the result., (*12)

limit, orderBy, andWhere

$docs = Flywheel::limit($count, $offset)->get();
$docs = Flywheel::orderBy('fieldname ASC|DESC')->get();

andWhere is a wrapper for additional where queries., (*13)

All types of queries, (where, limit, orderby, andWhere) can be chained before calling get. Example-, (*14)

$docs = Flywheel::where('title','==','Most Excellent')
                ->limit(5,2)
                ->orderBy('title ASC')
                ->get();

First

If you only want to return a single document you can run first instead of get, (*15)

$doc = Flywheel::where('title', '==', 'Most Excellent')->first();

All returned values can be returned and will return a json string., (*16)

return $docs;

If you want to return a laravel response object with application/json headers then you can run, (*17)

return $docs->toJson();

or, (*18)

return $docs->toArray();

of course you can always pass the variable into a Blade template, (*19)

return view('template.name', compact('docs'));

Find an error or want a feature?

Send a pull request!, (*20)

The Versions

12/08 2017

dev-master

9999999-dev

a laravel wrapper for the flywheel package

  Sources   Download

MIT

The Requires

 

by James Allen

12/08 2017

v0.0.3

0.0.3.0

a laravel wrapper for the flywheel package

  Sources   Download

MIT

The Requires

 

by James Allen

12/08 2017

v0.0.2

0.0.2.0

a laravel wrapper for the flywheel package

  Sources   Download

The Requires

 

by James Allen

12/08 2017

v0.0.1

0.0.1.0

a laravel wrapper for the flywheel package

  Sources   Download

The Requires

 

by James Allen