123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- namespace App\Http\Controllers\Admin\AuditMedia;
- use App\Events\AuditMediaDeal;
- use App\Http\Controllers\Controller;
- use App\Models\Media\MediaSecure;
- use App\Models\Media\MediaSecureImage;
- use App\Models\Media\MediaSecureOther;
- use App\Models\Media\MediaSecureText;
- use App\Models\Media\MediaSecureVoice;
- use Illuminate\Http\Request;
- class AuditMediaController extends Controller
- {
- public function listImage(Request $request)
- {
- $pages = array(
- 'last_id' => $request->get('last_id', 1),
- 'limit' => $request->get('limit', 20),
- 'page' => $request->get('page', 1)
- );
- $field = $request->get('field');
- $build = MediaSecureImage::when($field, function ($query) use ($field) {
- return $query->ofField($field);
- })->when($request->filled('uid'), function ($query) use ($request) {
- return $query->where('uid', $request->uid);
- })->when($request->filled('result'), function ($query) use ($request) {
- return $query->where('result', $request->get('result'));
- })->when($request->filled('audit_suggestion'), function ($query) use ($request) {
- return $query->where('audit_suggestion', $request->get('audit_suggestion'));
- });
- $pages['total'] = $build->count();
- $list = $build->where('id', '>', $pages['last_id'])
- ->skip(($pages['page'] - 1) * $pages['limit'])
- ->take($pages['limit'])
- ->get();
- return array(
- 'page' => $pages,
- 'list' => $list
- );
- }
- public function listText(Request $request)
- {
- $pages = array(
- 'last_id' => $request->get('last_id', 1),
- 'limit' => $request->get('limit', 20),
- 'page' => $request->get('page', 1)
- );
- $field = $request->get('field');
- $build = MediaSecureText::when($field, function ($query) use ($field) {
- return $query->ofField($field);
- })->when($request->filled('uid'), function ($query) use ($request) {
- return $query->where('uid', $request->uid);
- })->when($request->filled('result'), function ($query) use ($request) {
- return $query->where('result', $request->get('result'));
- })->when($request->filled('audit_suggestion'), function ($query) use ($request) {
- return $query->where('audit_suggestion', $request->get('audit_suggestion'));
- });
- $pages['total'] = $build->count();
- $list = $build->where('id', '>', $pages['last_id'])
- ->skip(($pages['page'] - 1) * $pages['limit'])
- ->take($pages['limit'])
- ->get();
- return array(
- 'page' => $pages,
- 'list' => $list
- );
- }
- public function listVoice(Request $request)
- {
- $pages = array(
- 'last_id' => $request->get('last_id', 1),
- 'limit' => $request->get('limit', 20),
- 'page' => $request->get('page', 1)
- );
- $field = $request->get('field');
- $build = MediaSecureVoice::when($field, function ($query) use ($field) {
- return $query->ofField($field);
- })->when($request->filled('uid'), function ($query) use ($request) {
- return $query->where('uid', $request->uid);
- })->when($request->filled('result'), function ($query) use ($request) {
- return $query->where('result', $request->get('result'));
- })->when($request->filled('audit_suggestion'), function ($query) use ($request) {
- return $query->where('audit_suggestion', $request->get('audit_suggestion'));
- });
- $pages['total'] = $build->count();
- $list = $build->where('id', '>', $pages['last_id'])
- ->skip(($pages['page'] - 1) * $pages['limit'])
- ->take($pages['limit'])
- ->get();
- return array(
- 'page' => $pages,
- 'list' => $list
- );
- }
- public function audit(Request $request)
- {
- $type = $request->get('audit_type', 'text');
- $deals = $request->post();
- switch ($type) {
- case "text":
- $storage = new MediaSecureText();
- break;
- case "image":
- $storage = new MediaSecureImage();
- break;
- case "voice":
- $storage = new MediaSecureVoice();
- break;
- default:
- $storage = new MediaSecureOther();
- break;
- }
- foreach ($deals as $deal) {
- $media = $storage->find($deal['id']);
- $media->result = $deal['result'];
- $media->channel = MediaSecure::CHANNEL_MANUAL;
- $media->save();
- event(new AuditMediaDeal($media));
- }
- return array(
- 'code' => 200,
- 'message' => 'success'
- );
- }
- }
|