-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
364 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# CHANGELOG | ||
|
||
### v1.9.5 | ||
- 增加join可嵌套使用 | ||
- repo增加方法newQuery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Model; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Role extends Model | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Model; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class UserHasOne extends Model | ||
{ | ||
protected $table = "user_has_one"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\Repositories\Modules\Role; | ||
|
||
use luffyzhao\laravelTools\Repositories\Facades\RepositoriesAbstract; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Eloquent extends RepositoriesAbstract implements Interfaces | ||
{ | ||
public function __construct(Model $model) | ||
{ | ||
$this->model = $model; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Repositories\Modules\Role; | ||
|
||
use luffyzhao\laravelTools\Repositories\Facades\RepositoryInterface; | ||
|
||
interface Interfaces extends RepositoryInterface | ||
{ | ||
// code... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Repositories\Modules\Role; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Foundation\Application; | ||
use Config; | ||
use luffyzhao\laravelTools\Repositories\Cache\LaravelCache; | ||
use App\Model\Role; | ||
|
||
class Provider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap any application services. | ||
*/ | ||
public function boot() | ||
{ | ||
} | ||
|
||
/** | ||
* Register any application services. | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->bind(Interfaces::class, function (Application $app) { | ||
$repository = new Eloquent(new Role()); | ||
if (!Config::get('app.cache')) { | ||
return $repository; | ||
} | ||
|
||
$cache = new LaravelCache($app['cache'], 'Role', 3600); | ||
|
||
return new Cache($repository, $cache); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\Repositories\Modules\UserHasOne; | ||
|
||
use luffyzhao\laravelTools\Repositories\Facades\RepositoriesAbstract; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Eloquent extends RepositoriesAbstract implements Interfaces | ||
{ | ||
public function __construct(Model $model) | ||
{ | ||
$this->model = $model; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
examples/app/Repositories/Modules/UserHasOne/Interfaces.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Repositories\Modules\UserHasOne; | ||
|
||
use luffyzhao\laravelTools\Repositories\Facades\RepositoryInterface; | ||
|
||
interface Interfaces extends RepositoryInterface | ||
{ | ||
// code... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Repositories\Modules\UserHasOne; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Foundation\Application; | ||
use Config; | ||
use luffyzhao\laravelTools\Repositories\Cache\LaravelCache; | ||
use App\Model\UserHasOne; | ||
|
||
class Provider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap any application services. | ||
*/ | ||
public function boot() | ||
{ | ||
} | ||
|
||
/** | ||
* Register any application services. | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->bind(Interfaces::class, function (Application $app) { | ||
$repository = new Eloquent(new UserHasOne()); | ||
if (!Config::get('app.cache')) { | ||
return $repository; | ||
} | ||
|
||
$cache = new LaravelCache($app['cache'], 'UserHasOne', 3600); | ||
|
||
return new Cache($repository, $cache); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
examples/database/migrations/2018_08_09_032501_create_roles_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateRolesTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('roles', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('name'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('roles'); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
examples/database/migrations/2018_08_09_032513_create_user_has_one_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateUserHasOneTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('user_has_one', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->unsignedInteger('user_id'); | ||
$table->string('has'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('user_has_one'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* luffy-laravel-tools | ||
* RepoException.php. | ||
* @author luffyzhao@vip.126.com | ||
*/ | ||
|
||
namespace luffyzhao\laravelTools\Repositories\Exceptions; | ||
|
||
|
||
use Exception; | ||
|
||
class RepoException extends Exception | ||
{ | ||
|
||
} |
Oops, something went wrong.