示例#1
0
 public static function customCreate(CreateConversationRequest $request)
 {
     $conv = new Conversation();
     $conv->Title = $request->Title;
     // if nothing specified in the request
     if (!$request->has('user_id')) {
         // if we are not even logged ( happen while seeding base)
         if (!\Auth::check()) {
             $conv->user_id = User::first()->id;
         } else {
             $conv->user_id = \Auth::id();
         }
     }
     // if Pending status is specified we take it, if not default value will be applied (false)
     if (!$request->has('Pending')) {
         $conv->Pending = $request->Pending;
     }
     $conv->created_at = Carbon::now();
     $conv->save();
     // When conversation is settled the Thread can be created
     $thread = new Thread();
     $thread->user_id = $conv->user_id;
     $thread->Content = $request->Content;
     $thread->conversation_id = $conv->id;
     $thread->created_at = Carbon::now();
     $thread->Pending = $conv->Pending;
     $thread->save();
     return true;
 }
示例#2
0
 public function userReadDiscussion()
 {
     if (\Auth::check()) {
         return $this->hasMany('App\\UserReadDiscussion')->where('user_id', '=', \Auth::user()->id);
     } else {
         abort(500, 'Need to be logged in to access this userReadDiscussion relation');
     }
 }
示例#3
0
文件: Art.php 项目: jonasvr/auction
 public function myWatchlist()
 {
     if (Auth::check() && Watchlist::where('user_id', Auth::user()->id)->where('art_id', $this->id)->exists()) {
         return true;
     } else {
         return false;
     }
 }
示例#4
0
 public static function tipoUserLogado()
 {
     if (!\Auth::check()) {
         return "*";
     }
     $user = User::whereRaw('name=?', [\Auth::user()->name]);
     if ($user->count() == 1) {
         return $user->first()->tipo;
     }
     return "";
 }
示例#5
0
 /**
  * @return string
  */
 public static function getQotd()
 {
     if (Cache::has('qotd')) {
         $quote = Cache::get('qotd');
         if (is_null($quote->speaker)) {
             return "<span class='text-lg'>&#8220;</span> {$quote->text} <span class='text-lg'>&#8221;</span>";
         } else {
             return "<span class='text-lg'>&#8220;</span> {$quote->text} <span class='text-lg'>&#8221;</span><br> - {$quote->speaker}";
         }
     } else {
         if (\Auth::check() && \Auth::user()->isAdmin()) {
             return "<span class='text-danger'><i>No Quote set as Quote of the Day and so a random quote will be shown to public.</i></span>";
         }
         $quote = self::random();
         if (is_null($quote->speaker)) {
             return "<span class='text-lg'>&#8220;</span> {$quote->text} <span class='text-lg'>&#8221;</span>";
         } else {
             return "<span class='text-lg'>&#8220;</span> {$quote->text} <span class='text-lg'>&#8221;</span><br> - {$quote->speaker}";
         }
     }
 }
示例#6
0
文件: User.php 项目: ant-vel/Web
 public static function cantUpdate($id)
 {
     return \Auth::check() && (\Auth::id() == $id || \Auth::user() && in_array(\Auth::user()->role, ['admin', 'root']));
 }
示例#7
0
 /**
  * @param Builder|\Illuminate\Database\Eloquent\Builder|Profile $query
  * @return mixed
  */
 public function scopeVisible($query)
 {
     return $query->where(function ($query) {
         $query = $query->approved();
         if (\Auth::check()) {
             $query = $query->orWhere('user_id', \Auth::id());
         }
         return $query;
     });
 }