Package Data | |
---|---|
Maintainer Username: | lukaskorl |
Maintainer Contact: | hello@lukaskorl.com (Lukas Korl) |
Package Create Date: | 2014-06-09 |
Package Last Update: | 2014-07-26 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-10-08 03:04:51 |
Package Statistics | |
---|---|
Total Downloads: | 2,005 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Uniquely uses UUIDv4 as primary key for Laravel 4 Eloquent models. It automatically generates the UUID when your model is saved. Uniquely overwrites the save()
method instead of attaching to Eloquent's creating
event in order to circumvent some problems in combination with unit testing.
To install Uniquely run
$ composer require lukaskorl/uniquely
You can specify 1.*
to include the most current version including possible future bugfixes.
Manual installation
If you choose to install Uniquely manually add the following line to your composer.json
:
"require": {
"lukaskorl/uniquely": "1.*"
}
and run
$ composer update
to install the package.
To use a Uniquely model simply extend your model class from Lukaskorl\Uniquely\Model
.
<?php
use Lukaskorl\Uniquely\Model;
class User extends Model {
}
The id
field of the corresponding database table for your model should be a 36-char string (i.e. VARCHAR(36)
). If you are using Laravel 4 migrations you will have to set your id
field like so:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateUsersTable extends Migration {
public function up()
{
Schema::create('users', function(Blueprint $table)
{
$table->string('id', 36);
// ... other columns ...
$table->timestamps();
});
Schema::table('users', function(Blueprint $table)
{
$table->primary('id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
Uniquely is open-sourced software licensed under the MIT license.