Skip to content

Commit

Permalink
Merge branch 'release/v0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
jstoone committed Nov 15, 2016
2 parents d8b2242 + e0bfe44 commit aacbbee
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 56 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
},
"autoload": {
"psr-4": {
"Dixie\\LaravelModelFuture\\": "src/"
"Dixie\\EloquentModelFuture\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Dixie\\LaravelModelFuture\\Tests\\": "tests/"
"Dixie\\EloquentModelFuture\\Tests\\": "tests/"
}
},
"minimum-stability": "stable"
Expand Down
4 changes: 2 additions & 2 deletions src/Collections/FutureCollection.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Dixie\LaravelModelFuture\Collections;
namespace Dixie\EloquentModelFuture\Collections;

use Illuminate\Database\Eloquent\Collection as EloquentCollection;

Expand All @@ -21,7 +21,7 @@ public function original()
/**
* Gets the model back with all the future data filled.
*
* @return Dixie\LaravelModelFuture\Contracts\ModelFuture
* @return Dixie\EloquentModelFuture\Contracts\ModelFuture
*/
public function result()
{
Expand Down
33 changes: 31 additions & 2 deletions src/Commands/CommitToFutureCommand.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Dixie\LaravelModelFuture\Commands;
namespace Dixie\EloquentModelFuture\Commands;

use Illuminate\Console\Command;
use Dixie\LaravelModelFuture\Models\Future;
use Dixie\EloquentModelFuture\Models\Future;
use Carbon\Carbon;

class CommitToFutureCommand extends Command
Expand Down Expand Up @@ -46,12 +46,41 @@ public function handle()
->uncommitted()
->get();


if($futures->isEmpty()) {
$this->outputMessage('No future plans for today.');
return;
}

$futures->each(function(Future $future) use ($today) {
$modelWithFuture = $future->futureable;

$modelWithFuture->future()
->see($today)
->commit();
});

$this->outputMessage("{$futures->count()} futures updated.");
}


/**
* Write a line to the commandline
*
* @return void
*/
private function outputMessage($message)
{
$laravel = $this->laravel ?: false;

if( ! $laravel) {
return;
}

if( ! $laravel->runningInConsole()) {
return;
}

$this->info($message);
}
}
2 changes: 1 addition & 1 deletion src/Contracts/ModelFuture.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Dixie\LaravelModelFuture\Contracts;
namespace Dixie\EloquentModelFuture\Contracts;

interface ModelFuture
{
Expand Down
22 changes: 11 additions & 11 deletions src/FuturePlanner.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?php

namespace Dixie\LaravelModelFuture;
namespace Dixie\EloquentModelFuture;

use Illuminate\Database\Eloquent\Model;
use Dixie\LaravelModelFuture\Models\Future;
use Dixie\LaravelModelFuture\Contracts\ModelFuture;
use Dixie\EloquentModelFuture\Models\Future;
use Dixie\EloquentModelFuture\Contracts\ModelFuture;
use Carbon\Carbon;

class FuturePlanner
{
/**
* The model under action.
*
* @var Dixie\LaravelModelFuture\Contracts\ModelFuture
* @var Dixie\EloquentModelFuture\Contracts\ModelFuture
*/
protected $model;

/**
* A new future instance that is about to get planned.
*
* @var Dixie\LaravelModelFuture\Models\Future
* @var Dixie\EloquentModelFuture\Models\Future
*/
protected $newFuture;

Expand Down Expand Up @@ -47,7 +47,7 @@ public function __construct(ModelFuture $model)
*
* @param array $attributes
*
* @return Dixie\LaravelModelFuture\FuturePlanner
* @return Dixie\EloquentModelFuture\FuturePlanner
*/
public function plan(array $attributes)
{
Expand All @@ -61,7 +61,7 @@ public function plan(array $attributes)
*
* @param Carbon $futureDate
*
* @return Dixie\LaravelModelFuture\Models\Future
* @return Dixie\EloquentModelFuture\Models\Future
*/
public function for(Carbon $futureDate)
{
Expand All @@ -82,7 +82,7 @@ public function for(Carbon $futureDate)
*
* @param Carbon $futureDate
*
* @return Dixie\LaravelModelFuture\Contracts\ModelFuture
* @return Dixie\EloquentModelFuture\Contracts\ModelFuture
*/
public function see(Carbon $futureDate)
{
Expand All @@ -92,7 +92,7 @@ public function see(Carbon $futureDate)
/**
* Get all future plans for a model.
*
* @return Dixie\LaravelModelFuture\Collections\FutureCollection
* @return Dixie\EloquentModelFuture\Collections\FutureCollection
*/
public function getPlans()
{
Expand All @@ -104,7 +104,7 @@ public function getPlans()
*
* @param Carbon $futureDate
*
* @return Dixie\LaravelModelFuture\Collections\FutureCollection
* @return Dixie\EloquentModelFuture\Collections\FutureCollection
*/
public function getPlansFor(Carbon $futureDate)
{
Expand All @@ -116,7 +116,7 @@ public function getPlansFor(Carbon $futureDate)
*
* @param Carbon $futureDate
*
* @return Dixie\LaravelModelFuture\Collections\FutureCollection
* @return Dixie\EloquentModelFuture\Collections\FutureCollection
*/
public function getPlansUntil(Carbon $futureDate)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Future.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Dixie\LaravelModelFuture\Models;
namespace Dixie\EloquentModelFuture\Models;

use Illuminate\Database\Eloquent\Model;
use Dixie\LaravelModelFuture\Collections\FutureCollection;
use Dixie\EloquentModelFuture\Collections\FutureCollection;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Builder;
use Carbon\Carbon;
Expand Down Expand Up @@ -46,7 +46,7 @@ class Future extends Model
/**
* Override the original Eloquent collection.
*
* @param Dixie\LaravelModelFuture\Collections\FutureCollection
* @param Dixie\EloquentModelFuture\Collections\FutureCollection
*/
public function newCollection(array $models = [])
{
Expand Down
8 changes: 5 additions & 3 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Dixie\LaravelModelFuture;
namespace Dixie\EloquentModelFuture;

use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use Dixie\LaravelModelFuture\Commands\CommitToFutureCommand;
use Dixie\EloquentModelFuture\Commands\CommitToFutureCommand;


class ServiceProvider extends BaseServiceProvider
Expand All @@ -18,7 +18,9 @@ public function boot()
{
$this->loadMigrationsFrom(__DIR__.'/../migrations');

$this->commands(CommitToFutureCommand::class);
if($this-app->runningInConsole()) {
$this->commands(CommitToFutureCommand::class);
}
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Traits/HasFuture.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Dixie\LaravelModelFuture\Traits;
namespace Dixie\EloquentModelFuture\Traits;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Dixie\LaravelModelFuture\Models\Future;
use Dixie\LaravelModelFuture\FuturePlanner;
use Dixie\EloquentModelFuture\Models\Future;
use Dixie\EloquentModelFuture\FuturePlanner;

trait HasFuture
{
Expand Down Expand Up @@ -35,7 +35,7 @@ public function uncommittedFutures()
/**
* Start planning the future of a model
*
* @return Dixie\LaravelModelFuture\FuturePlanner
* @return Dixie\EloquentModelFuture\FuturePlanner
*/
public function future()
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Collections/FutureCollectionTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Dixie\LaravelModelFuture\Tests\Collections;
namespace Dixie\EloquentModelFuture\Tests\Collections;

use Dixie\LaravelModelFuture\Tests\TestCase;
use Dixie\EloquentModelFuture\Tests\TestCase;
use Carbon\Carbon;
use Dixie\LaravelModelFuture\Collections\FutureCollection;
use Dixie\LaravelModelFuture\Tests\User;
use Dixie\EloquentModelFuture\Collections\FutureCollection;
use Dixie\EloquentModelFuture\Tests\User;

class FutureCollectionTest extends TestCase
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Commands/CommitToFutureCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Dixie\LaravelModelFuture\Tests\Commands;
namespace Dixie\EloquentModelFuture\Tests\Commands;

use Dixie\LaravelModelFuture\Tests\TestCase;
use Dixie\LaravelModelFuture\Commands\CommitToFutureCommand;
use Dixie\EloquentModelFuture\Tests\TestCase;
use Dixie\EloquentModelFuture\Commands\CommitToFutureCommand;
use Carbon\Carbon;
use Dixie\LaravelModelFuture\Models\Future;
use Dixie\EloquentModelFuture\Models\Future;

class CommitToFutureCommandTest extends TestCase
{
Expand Down
16 changes: 8 additions & 8 deletions tests/FuturePlannerTest.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace Dixie\LaravelModelFuture\Tests;
namespace Dixie\EloquentModelFuture\Tests;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Dixie\LaravelModelFuture\Contracts\ModelFuture;
use Dixie\LaravelModelFuture\Models\Future;
use Dixie\LaravelModelFuture\Tests\TestCase;
use Dixie\LaravelModelFuture\FuturePlan;
use Dixie\LaravelModelFuture\Tests\User; use Dixie\LaravelModelFuture\Collections\FutureCollection;
use Dixie\EloquentModelFuture\Contracts\ModelFuture;
use Dixie\EloquentModelFuture\Models\Future;
use Dixie\EloquentModelFuture\Tests\TestCase;
use Dixie\EloquentModelFuture\FuturePlan;
use Dixie\EloquentModelFuture\Tests\User; use Dixie\EloquentModelFuture\Collections\FutureCollection;
use Illuminate\Support\Facades\Auth;

class FuturePlannerTest extends TestCase
Expand Down Expand Up @@ -231,9 +231,9 @@ public function testItCanSeeWhatTheModelLooksLikeInTheFuture()
}
}

namespace Dixie\LaravelModelFuture;
namespace Dixie\EloquentModelFuture;

use Dixie\LaravelModelFuture\Tests\User;
use Dixie\EloquentModelFuture\Tests\User;

function auth()
{
Expand Down
12 changes: 6 additions & 6 deletions tests/Models/FutureTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Dixie\LaravelModelFuture\Tests\Models;
namespace Dixie\EloquentModelFuture\Tests\Models;

use Dixie\LaravelModelFuture\Tests\TestCase;
use Dixie\EloquentModelFuture\Tests\TestCase;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Dixie\LaravelModelFuture\Collections\FutureCollection;
use Dixie\LaravelModelFuture\Models\Future;
use Dixie\EloquentModelFuture\Collections\FutureCollection;
use Dixie\EloquentModelFuture\Models\Future;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class FutureTest extends TestCase
Expand Down Expand Up @@ -91,9 +91,9 @@ public function testItHasACommittedScope()
}
}

namespace Dixie\LaravelModelFuture\Models;
namespace Dixie\EloquentModelFuture\Models;

use Dixie\LaravelModelFuture\Tests\User;
use Dixie\EloquentModelFuture\Tests\User;

function config($args)
{
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Dixie\LaravelModelFuture\Tests;
namespace Dixie\EloquentModelFuture\Tests;

use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Eloquent\Model as Eloquent;
use PHPUnit_Framework_TestCase;
use Dixie\LaravelModelFuture\Contracts\ModelFuture;
use Dixie\EloquentModelFuture\Contracts\ModelFuture;
use Carbon\Carbon;
use Mockery;
use Illuminate\Support\Facades\Config;
Expand Down Expand Up @@ -95,6 +95,6 @@ protected function createUser(array $data = [], $shouldOverride = false)

class User extends Eloquent implements ModelFuture
{
use \Dixie\LaravelModelFuture\Traits\HasFuture;
use \Dixie\EloquentModelFuture\Traits\HasFuture;
}

6 changes: 3 additions & 3 deletions tests/Traits/HasFutureTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Dixie\LaravelModelFuture\Tests\Traits;
namespace Dixie\EloquentModelFuture\Tests\Traits;

use Dixie\LaravelModelFuture\Tests\TestCase;
use Dixie\EloquentModelFuture\Tests\TestCase;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Dixie\LaravelModelFuture\FuturePlanner;
use Dixie\EloquentModelFuture\FuturePlanner;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Relations\HasMany;

Expand Down

0 comments on commit aacbbee

Please sign in to comment.