Ejemplo n.º 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;
     }
 }
Ejemplo n.º 2
0
 private static function seed()
 {
     $statuses = ['draft', 'published', 'hidden'];
     foreach ($statuses as $status) {
         if (!Status::exists($status)) {
             Status::create(['name' => $status]);
         }
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }