コード例 #1
0
ファイル: Work.php プロジェクト: postalu/postal
 public function toArray()
 {
     $data = parent::toArray();
     if ($this->work_category_id) {
         $data['category'] = $this->category->name;
     }
     return $data;
 }
コード例 #2
0
ファイル: User.php プロジェクト: postalu/postal
 /**
  * Methods
  */
 public function toArray()
 {
     $data = parent::toArray();
     $data['password'] = '';
     $data['fullname'] = $this->fullname;
     $data['permissions'] = null;
     if (count($this->permissions)) {
         $data['permissions'] = [];
     }
     foreach ($this->permissions as $permission) {
         $data['permissions'][$permission->resource] = [];
         foreach (Permission::$actions as $action => $name) {
             $data['permissions'][$permission->resource][$action] = $permission->{$action};
         }
     }
     return $data;
 }
コード例 #3
0
ファイル: Image.php プロジェクト: postalu/postal
 /**
  * Listen for events
  */
 protected static function boot()
 {
     parent::boot();
     static::saved(function ($image) {
         $image->processThumbnails(function ($image, $thumbnail, $method) {
             $thumbnailPath = $image->getImage($thumbnail);
             $imagePath = Input::file('file') ? Input::file('file') : $image->path;
             ImageLib::open($imagePath)->{$method}($thumbnail[0], $thumbnail[1])->save($thumbnailPath);
         });
     });
     static::deleted(function ($image) {
         $image->processThumbnails(function ($image, $thumbnail, $method) {
             $thumbnailPath = $image->getImage($thumbnail);
             if (file_exists($thumbnailPath)) {
                 unlink($thumbnailPath);
             }
         });
     });
 }