Exemplo n.º 1
0
 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct(Status $status, User $user)
 {
     $this->status = $status;
     $this->user = $user;
     $this->notifiable = $status;
     $user->decrement('status_count');
 }
Exemplo n.º 2
0
 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct(Topic $topic, User $user)
 {
     $this->topic = $topic;
     $this->user = $user;
     $this->weight = 0;
     $this->karma = $topic->vote_count;
     $this->notifiable = $topic;
     $user->decrement('topic_count');
 }
Exemplo n.º 3
0
 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct(Topic $topic, User $user)
 {
     $this->topic = $topic;
     $this->user = $user;
     $this->notifiable = $topic;
     //patikrinam ar tema yra naujiena.
     if ($topic->node_id == 15) {
         event(new NewsWasPosted($topic));
     }
     $user->increment('topic_count');
 }
Exemplo n.º 4
0
 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct(Reply $reply, Topic $topic, User $user)
 {
     $this->reply = $reply;
     $this->topic = $topic;
     $this->user = $user;
     $this->weight = Config::get('app.reply_gain_weight');
     $this->karma = 0;
     $this->notifiable = $reply;
     $user->increment('reply_count');
     $topic->increment('reply_count');
 }
Exemplo n.º 5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     foreach (User::all() as $user) {
         $user->follower_count = $user->followers()->count();
         $user->save();
     }
 }
Exemplo n.º 6
0
 public static function users()
 {
     $value = Cache::remember('statistics_users', 5, function () {
         return User::count();
     });
     return $value;
 }
Exemplo n.º 7
0
 public function postRegister(CreateUser $request)
 {
     $user = User::create(['username' => $request->input('username'), 'email' => $request->input('email'), 'password' => Hash::make($request->input('password'))]);
     $user->attachRole(Role::where('name', '=', 'Narys')->get()->first());
     event(new UserWasCreated($user));
     flash()->success('Tu sėkmingai užsiregistravai! Dabar gali prisijungti!');
     return redirect('/');
 }
Exemplo n.º 8
0
 public function parse($body)
 {
     $this->body_original = $body;
     $this->usernames = $this->getMentionedUsername();
     count($this->usernames) > 0 && ($this->users = User::whereIn('username', $this->usernames)->get());
     $this->replace();
     return $this->body_parsed;
 }
Exemplo n.º 9
0
 public function __construct()
 {
     User::created(function ($user) {
         Cache::forget('users');
     });
     User::updated(function ($user) {
         Cache::forget('users');
     });
 }
Exemplo n.º 10
0
 /**
  * Handle the event.
  *
  * @param  NewsWasPosted  $event
  * @return void
  */
 public function handle(NewsWasPosted $event)
 {
     $topic = $event->topic;
     $users = User::where('email_news', 1)->chunk(200, function ($users) use($topic) {
         $data = ['title' => $topic->title, 'body' => $topic->body];
         foreach ($users as $user) {
             Mail::queue('emails.news', $data, function ($message) use($user, $topic) {
                 $message->to($user->email)->subject('Maze Naujienos: ' . utf8_urldecode($topic->title));
             });
         }
     });
 }
Exemplo n.º 11
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $topic = Topic::findOrFail($this->argument('topic_id'));
     $users = User::where('email_news', 1)->chunk(200, function ($users) use($topic) {
         $data = ['title' => $topic->title, 'body' => $topic->body];
         foreach ($users as $user) {
             Mail::queue('emails.news', $data, function ($message) use($user, $topic) {
                 $message->to($user->email)->subject('Maze Naujienos: ' . utf8_urldecode($topic->title));
             });
         }
     });
 }
Exemplo n.º 12
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $path = 'public/images/avatars/';
     $dirs = scandir($path);
     foreach ($dirs as $dir) {
         if ($dir != '.' && $dir != '..') {
             $user = User::where('username', $dir)->first();
             if ($user) {
                 rename($path . $dir, $path . $user->id);
             } else {
                 $this->rrmdir($path . $dir);
             }
         }
     }
 }
Exemplo n.º 13
0
 public function results(Request $request)
 {
     $type = $request->input('type');
     $query = $request->input('query');
     if ($type == 'user') {
         $results = User::where('username', 'LIKE', '%' . $query . '%')->paginate(20);
     } elseif ($type == 'reply') {
         $results = Reply::where('body_original', 'LIKE', '%' . $query . '%')->paginate(20);
     } elseif ($type == 'topic') {
         $results = Topic::where('body_original', 'LIKE', '%' . $query . '%')->paginate(20);
     } elseif ($type == 'status') {
         $results = Status::where('body_original', 'LIKE', '%' . $query . '%')->paginate(20);
     }
     return view('search.results', compact('type', 'query', 'results'));
 }
Exemplo n.º 14
0
 public function store(CreateConversation $request)
 {
     $user = Auth::user();
     $receiver = User::where('username', $request->input('username'))->first();
     if (!$receiver || $receiver->id == $user->id) {
         flash()->error('Gavėjas nerastas!');
         return redirect()->back()->withInput();
     } else {
         $conversation = $user->jointConversations($receiver)->first();
         if (!$conversation) {
             $conversation = Conversation::create(['secret' => str_random(70)]);
             $user->conversations()->attach($conversation->id);
             $receiver->conversations()->attach($conversation->id);
         }
         $message = Messenger::send($user, $conversation, $request->input('body'));
         return redirect()->route('conversation.show', $conversation->id);
     }
 }
Exemplo n.º 15
0
 public function disableVote($id)
 {
     $user = Auth::user();
     if ($user->can('manage_topics')) {
         $user = User::findOrFail($id);
         if ($user->can_vote) {
             $user->can_vote = 0;
             $user->save();
             flash()->success('Balsai išjungti.');
         } else {
             $user->can_vote = 1;
             $user->save();
             flash()->success('Balsai įjungti.');
         }
     }
     return redirect()->back();
 }
Exemplo n.º 16
0
 public function getSlugAttribute($value)
 {
     if (!$value) {
         $value = S::slugify($this->username);
         $nodes = User::where('slug', $value);
         if ($nodes->count() > 0) {
             $value = $this->id . '-' . $value;
             $this->slug = $value;
             $this->save();
             return $value;
         } else {
             $this->slug = $value;
             $this->save();
             return $value;
         }
     } else {
         $slugs = User::where('slug', $value)->count();
         $slug = $value;
         if ($slugs > 0) {
             $slug = S::slugify($this->username) . $this->id;
             $this->slug = $slug;
             $this->save();
         }
         return $slug;
     }
 }