12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- /**
- * Created by PhpStorm.
- * User: edz
- * Date: 2019-06-10
- * Time: 17:53
- */
- namespace App\Repositories;
- use App\Models\Behavior;
- use Illuminate\Support\Facades\Log;
- class FeedRepositories
- {
- public function __construct()
- {
- }
- public function getFeedType($action)
- {
- $type = [
- 'like' => 1,
- 'forward' => 2,
- 'collect' => 3,
- 'comment' => 4,
- 'focus' => 5,
- 'publish' => 6
- ];
- return isset($type[$action]) ? $type[$action] : 0;
- }
- public function feedCreate($request)
- {
- $fans = $request['fans'];
- $behaviorFlag = $request['behavior_flag'];
- $feedType = $this->feedCreate($behaviorFlag);
- if($feedType){
- $data = [];
- foreach ($fans as $fan) {
- $data['uid'] = $fan;
- $data['follow_uid'] = $request['target_id'];
- $data['follow_username'] = $request['target_username'];
- $data['follow_avatar'] = $request['target_avatar'];
- $data['type'] = $feedType;
- $data['relate_id'] = $request['post_id'];
- $data['content'] = $request['post_desc'];
- }
- }
- }
- }
|