| xqd
@@ -1,13 +1,16 @@
|
|
|
<?php
|
|
|
/**
|
|
|
* 通话纪录
|
|
|
- * @author system
|
|
|
- * @version 1.0
|
|
|
- * @date 2018-11-27 03:15:47
|
|
|
+ * @author system
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2018-11-27 03:15:47
|
|
|
*
|
|
|
*/
|
|
|
+
|
|
|
namespace App\Http\Controllers\Admin\Call;
|
|
|
+
|
|
|
use App\Http\Controllers\Admin\Controller;
|
|
|
+use App\Models\CallListModel;
|
|
|
use Illuminate\Http\Request;
|
|
|
use App\Repositories\Base\Criteria\OrderBy;
|
|
|
use App\Repositories\Call\Records\Criteria\MultiWhere;
|
| xqd
@@ -17,24 +20,26 @@ class RecordsController extends Controller
|
|
|
{
|
|
|
private $repository;
|
|
|
|
|
|
- public function __construct(RecordsRepository $repository) {
|
|
|
- if(!$this->repository) $this->repository = $repository;
|
|
|
+ public function __construct(RecordsRepository $repository)
|
|
|
+ {
|
|
|
+ if (!$this->repository) $this->repository = $repository;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 列表页
|
|
|
*/
|
|
|
- function index(Request $request) {
|
|
|
+ function index(Request $request)
|
|
|
+ {
|
|
|
$search['keyword'] = $request->input('keyword');
|
|
|
$query = $this->repository->pushCriteria(new MultiWhere($search));
|
|
|
|
|
|
- if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
|
|
|
- $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
|
|
|
- }else{
|
|
|
- $query = $query->pushCriteria(new OrderBy('updated_at','DESC'));
|
|
|
+ if (isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
|
|
|
+ $query = $query->pushCriteria(new OrderBy($request['sort_field'], $request['sort_field_by']));
|
|
|
+ } else {
|
|
|
+ $query = $query->pushCriteria(new OrderBy('updated_at', 'DESC'));
|
|
|
}
|
|
|
$list = $query->paginate(16);
|
|
|
- return view('admin.call.records.index',compact('list'));
|
|
|
+ return view('admin.call.records.index', compact('list'));
|
|
|
}
|
|
|
|
|
|
|
| xqd
@@ -43,7 +48,7 @@ class RecordsController extends Controller
|
|
|
*/
|
|
|
public function create(Request $request)
|
|
|
{
|
|
|
- if($request->method() == 'POST') {
|
|
|
+ if ($request->method() == 'POST') {
|
|
|
return $this->_createSave();
|
|
|
}
|
|
|
return view('admin.call.records.edit');
|
| xqd
@@ -52,61 +57,79 @@ class RecordsController extends Controller
|
|
|
/**
|
|
|
* 保存修改
|
|
|
*/
|
|
|
- private function _createSave(){
|
|
|
- $data = (array) request('data');
|
|
|
+ private function _createSave()
|
|
|
+ {
|
|
|
+ $data = (array)request('data');
|
|
|
$id = $this->repository->create($data);
|
|
|
- if($id) {
|
|
|
- $url[] = array('url'=>U( 'Call/Records/index'),'title'=>'返回列表');
|
|
|
- $url[] = array('url'=>U( 'Call/Records/create'),'title'=>'继续添加');
|
|
|
- $this->showMessage('添加成功',$url);
|
|
|
- }else{
|
|
|
- $url[] = array('url'=>U( 'Call/Records/index'),'title'=>'返回列表');
|
|
|
- return $this->showWarning('添加失败',$url);
|
|
|
+ if ($id) {
|
|
|
+ $url[] = array('url' => U('Call/Records/index'), 'title' => '返回列表');
|
|
|
+ $url[] = array('url' => U('Call/Records/create'), 'title' => '继续添加');
|
|
|
+ $this->showMessage('添加成功', $url);
|
|
|
+ } else {
|
|
|
+ $url[] = array('url' => U('Call/Records/index'), 'title' => '返回列表');
|
|
|
+ return $this->showWarning('添加失败', $url);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 修改
|
|
|
*/
|
|
|
- public function update(Request $request) {
|
|
|
- if($request->method() == 'POST') {
|
|
|
+ public function update(Request $request)
|
|
|
+ {
|
|
|
+ if ($request->method() == 'POST') {
|
|
|
return $this->_updateSave();
|
|
|
}
|
|
|
$data = $this->repository->find($request->get('id'));
|
|
|
- return view('admin.call.records.edit',compact('data'));
|
|
|
+ return view('admin.call.records.edit', compact('data'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存修改
|
|
|
*/
|
|
|
- private function _updateSave() {
|
|
|
- $data = (array) request('data');
|
|
|
- $ok = $this->repository->update(request('id'),$data);
|
|
|
- if($ok) {
|
|
|
- $url[] = array('url'=>U( 'Call/Records/index'),'title'=>'返回列表');
|
|
|
- return $this->showMessage('操作成功',urldecode(request('_referer')));
|
|
|
- }else{
|
|
|
- $url[] = array('url'=>U( 'Call/Records/index'),'title'=>'返回列表');
|
|
|
- return $this->showWarning('操作失败',$url);
|
|
|
+ private function _updateSave()
|
|
|
+ {
|
|
|
+ $data = (array)request('data');
|
|
|
+ $ok = $this->repository->update(request('id'), $data);
|
|
|
+ if ($ok) {
|
|
|
+ $url[] = array('url' => U('Call/Records/index'), 'title' => '返回列表');
|
|
|
+ return $this->showMessage('操作成功', urldecode(request('_referer')));
|
|
|
+ } else {
|
|
|
+ $url[] = array('url' => U('Call/Records/index'), 'title' => '返回列表');
|
|
|
+ return $this->showWarning('操作失败', $url);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function view(Request $request) {
|
|
|
+ public function view(Request $request)
|
|
|
+ {
|
|
|
$data = $this->repository->find(request('id'));
|
|
|
- return view('admin.call.records.view',compact('data'));
|
|
|
+ return view('admin.call.records.view', compact('data'));
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 删除
|
|
|
*/
|
|
|
- public function destroy(Request $request) {
|
|
|
+ public function destroy(Request $request)
|
|
|
+ {
|
|
|
$bool = $this->repository->destroy($request->get('id'));
|
|
|
- if($bool) {
|
|
|
- return $this->showMessage('操作成功');
|
|
|
- }else{
|
|
|
- return $this->showWarning("操作失败");
|
|
|
+ if ($bool) {
|
|
|
+ return $this->showMessage('操作成功');
|
|
|
+ } else {
|
|
|
+ return $this->showWarning("操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addCallList(Request $request)
|
|
|
+ {
|
|
|
+ $phones = $request->get('contact_phones');
|
|
|
+ foreach ($phones as $phone) {
|
|
|
+ $hasAdd = CallListModel::where('phone', $phone)->where('sync', 0)->count();
|
|
|
+ if (!$hasAdd) {
|
|
|
+ CallListModel::create(['phone' => $phone, 'sync' => 0]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+ return 200;
|
|
|
}
|
|
|
}
|