예제 #1
0
 /**
  * Get a status by id.
  * @param $id
  * @return null
  */
 public static function getStatusById($id)
 {
     try {
         $status = Status::where('id', $id)->firstOrFail();
         return $status;
     } catch (Exception $e) {
         return null;
     }
 }
예제 #2
0
 private static function seed()
 {
     $statuses = ['draft', 'published', 'hidden'];
     foreach ($statuses as $status) {
         if (!Status::exists($status)) {
             Status::create(['name' => $status]);
         }
     }
     return true;
 }
예제 #3
0
파일: Post.php 프로젝트: taskforcedev/blog
 /**
  * Get posts with a status of 'published'
  * @param $query
  * @return mixed
  */
 public function scopePublished($query)
 {
     $status = Status::getStatusByName('published');
     return $query->where('status_id', $status->id);
 }