/** * Store a newly created timeline in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Timeline::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } Timeline::create($data); return Redirect::route('timelines.index'); }
public function discuss($content, User $user) { $info = compact('content', 'user'); $info['comment'] = $this; $d = Discuss::create($info); // generate activity $info = array('user' => $user, 'action' => 'discuss', 'object' => $this, 'link' => $d); $act = Activity::create($info); // inform all stack holders $info = array('activity' => $act, 'user' => $this->user); Timeline::create($info); }
public function comment($title, $content, User $user) { $c = parent::comment($title, $content, $user); // generate activity $info = array('user' => $user, 'action' => 'comment', 'object' => $this, 'link' => $c); $act = Activity::create($info); // inform all stack holders $users = Sdb::fetch('user', Comment::table(), array('teacher=?' => array($this->id))); $info = array('activity' => $act); foreach ($users as $u) { $info['user'] = $u; Timeline::create($info); } }
/** * @author ryan <*****@*****.**> */ function attitude($type) { if (!$GLOBALS['has_login']) { return; } $class = camel2under($type); $map = array('like' => 1, 'hate' => 0); $target = _req('target'); $action = _req('action'); $info = array($type => $target, 'user' => $GLOBALS['user'], '`like`' => $map[$action]); $at = Attitude::create($info); if ($at) { $info = array('user' => $GLOBALS['user'], 'action' => $action, 'object' => $target); $act = Activity::create($info); // inform author $comment = new $class($target); $info = array('user' => $comment->user, 'activity' => $act); Timeline::create($info); } $o = new $class($target); echo $o->{$action . 'Count'}(); }