Skip to content

Instantly share code, notes, and snippets.

@zloadmin
Created February 14, 2017 17:55
Show Gist options
  • Save zloadmin/f1b14ceecb0bf6e88ff88f8fa6098064 to your computer and use it in GitHub Desktop.
Save zloadmin/f1b14ceecb0bf6e88ff88f8fa6098064 to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Support\Facades\Redis as Redis;
class SroMessagesController extends \BaseController {
public function getIndex()
{
$messages = new SroMessage();
if(Input::has('message_type')) {
$message_type = Input::get('message_type');
$messages = $messages->where('message_type', 'LIKE', $message_type);
}
$messages = $messages->where('is_parse', 1);
$messages = $messages->orderby('message_date', 'desc');
$messages = $messages->paginate(15);
$redis = Redis::connection();
$message_types_redis = $redis->lrange('values:message_types', 0, -1);
$message_types = [];
foreach ($message_types_redis as $v) $message_types[$v] = $v;
return View::make('sromessages.index', compact('messages', 'message_types'));
}
public function getMessage($id)
{
$message = SroMessage::find($id);
return View::make('sromessages.message', compact('message'));
}
public function getMessageMd($md5)
{
$message = SroMessage::where('message_md5', $md5)->first();
return View::make('sromessages.message', compact('message'));
}
public function getCompany($md5)
{
$company = SroCompany::where('company_md5', $md5)->first();
return View::make('sromessages.company', compact('company'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment