Skip to content

Commit

Permalink
添加示例
Browse files Browse the repository at this point in the history
  • Loading branch information
luffyzhao committed Aug 6, 2018
1 parent 664fae2 commit 0d14b51
Show file tree
Hide file tree
Showing 96 changed files with 3,464 additions and 0 deletions.
39 changes: 39 additions & 0 deletions examples/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
5 changes: 5 additions & 0 deletions examples/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
13 changes: 13 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vscode
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
42 changes: 42 additions & 0 deletions examples/app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
36 changes: 36 additions & 0 deletions examples/app/Events/Illuminate/Database/Events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\Events\Illuminate\Database;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class Events
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}

/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('channel-name');
}
}
47 changes: 47 additions & 0 deletions examples/app/Excels/Modules/Api/OrderExcel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Excels\Modules\Api;


use App\Searchs\Modules\Api\Order\RepoExcelSearch;
use luffyzhao\laravelTools\Excels\Facades\ExcelAbstract;

class OrderExcel extends ExcelAbstract
{

/**
* 获取where条件
* @method getAttributes
*
* @return RepoExcelSearch
*
* @author luffyzhao@vip.126.com
*/
protected function getAttributes()
{
return new RepoExcelSearch(
request()->all()
);
}

/**
* @return array
*/
public function headings(): array
{
return ['订单编号'];
}

/**
* @param mixed $row
*
* @return array
*/
public function map($row): array
{
return [
$row->order_no
];
}

}
42 changes: 42 additions & 0 deletions examples/app/Excels/Modules/Api/UserExcel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Excels\Modules\Api;


use luffyzhao\laravelTools\Excels\Facades\ExcelAbstract;

class UserExcel extends ExcelAbstract
{

/**
* 获取where条件
* @method getAttributes
*
* @return array
*
* @author luffyzhao@vip.126.com
*/
protected function getAttributes()
{
return [];
}

/**
* @return array
*/
public function headings(): array
{
return [];
}

/**
* @param mixed $row
*
* @return array
*/
public function map($row): array
{
return $row;
}

}
51 changes: 51 additions & 0 deletions examples/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
}
70 changes: 70 additions & 0 deletions examples/app/Http/Controllers/Api/OrderController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace App\Http\Controllers\Api;

use App\Excels\Modules\Api\OrderExcel;
use App\Searchs\Modules\Api\Order\RepoSearch;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Repositories\Modules\Order\Interfaces;

class OrderController extends Controller
{
protected $repo;

public function __construct(Interfaces $repo)
{
$this->repo = $repo;
}

/**
* 测试repo:get用法
* @method repo
* @return \Illuminate\Http\JsonResponse
* @author luffyzhao@vip.126.com
*/
public function repo()
{
return $this->respondWithSuccess(
$this->repo->with(['user'])->get(['*'])
);
}

/**
* 测试repo+search用法
* @method repo
* @param RepoSearch $search
* @return \Illuminate\Http\JsonResponse
* @author luffyzhao@vip.126.com
*/
public function repoSearch(RepoSearch $search)
{
return $this->respondWithSuccess(
$this->repo->with(['user'])->getWhere(
$search,
['*']
)
);
}

/**
* 测试repo+join
* @method repoJoin
* @return \Illuminate\Http\JsonResponse
* @author luffyzhao@vip.126.com
*/
public function repoJoin(){
return $this->respondWithSuccess(
$this->repo->join(['user'])->get(['*'])
);
}

/**
* 测试repo+excel导出
* @method repoExcel
* @author luffyzhao@vip.126.com
*/
public function repoExcel(){
return (new OrderExcel($this->repo))->download('订单导出.xlsx');
}
}
Loading

0 comments on commit 0d14b51

Please sign in to comment.