2017 © Pedro Peláez
 

library springbok

A PHP package mainly developed for Laravel to manage specific accessors and mutators for Json and Date(Carbon).

image

sukohi/springbok

A PHP package mainly developed for Laravel to manage specific accessors and mutators for Json and Date(Carbon).

  • Saturday, September 12, 2015
  • by Sukohi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Springbok

A PHP package mainly developed for Laravel to manage specific accessors and mutators for Json and Date(Carbon).
(This is for Laravel 5+. For Laravel 4.2)
(So you can skip to add accessors and mutators for date and json.), (*1)

Installation

Add this package name in composer.json, (*2)

"require": {
  "sukohi/springbok": "2.*"
}

Execute composer command., (*3)

composer update

Usage

Simple Way, (*4)

In your model, set Springbok instead of Eloquent and add a member variable named "convert_attributes". (Springbok extends Eloquent.), (*5)

<?php

use \Sukohi\Springbok\Springbok;
class Appointment extends Springbok {

    protected $convert_attributes = [
        'started_at' => 'date',
        'member_ids' => 'json'
    ];

}

Now you also can get/set DB values simply like the below., (*6)

// Get

$appointment = \Appointment::first();
print_r($appointment->started_at);

/* Output

    Carbon\Carbon Object
    (
        [date] => 2015-06-22 00:00:00.000000
        [timezone_type] => 3
        [timezone] => Asia/Tokyo
    )

*/

print_r($appointment->member_ids);

/* Output

    Array
    (
        [0] => 1
        [1] => 2
        [2] => 3
    )

*/


// Set

$appointment->started_at = '2015-06-25';    // You also can set Carbon instance.
$appointment->member_ids = [2, 3, 5];       // You can directly set array values.
$appointment->save();

License

This package is licensed under the MIT License., (*7)

Copyright 2015 Sukohi Kuhoh, (*8)

The Versions

12/09 2015

2.0.x-dev

2.0.9999999.9999999-dev

A PHP package mainly developed for Laravel to manage specific accessors and mutators for Json and Date(Carbon).

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

12/09 2015

dev-master

9999999-dev

A PHP package mainly developed for Laravel to manage specific accessors and mutators for Json and Date(Carbon).

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

12/09 2015

2.0.0

2.0.0.0

A PHP package mainly developed for Laravel to manage specific accessors and mutators for Json and Date(Carbon).

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

12/09 2015

1.0.x-dev

1.0.9999999.9999999-dev

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

12/09 2015

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi