finish memos cover

This commit is contained in:
2020-04-18 15:58:48 +02:00
parent e9b4fb573f
commit a12af09102
27 changed files with 661 additions and 32 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class Image extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'data' => [
'type' => 'images',
'image_id' => $this->id,
'attributes' => [
'path' => url('storage/'.$this->path),
'width' => $this->width,
'height' => $this->height,
'location' => $this->location,
]
],
'links' => [
'self' => url('/images/'.$this->id),
]
];
}
}

View File

@@ -2,6 +2,8 @@
namespace App\Http\Resources;
use App\Http\Resources\Image as ImageResource;
use App\Http\Resources\User as UserResource;
use Illuminate\Http\Resources\Json\JsonResource;
class Memo extends JsonResource
@@ -16,10 +18,15 @@ class Memo extends JsonResource
{
return [
'data' => [
'type' => 'memos',
'memo_id' => $this->id,
'name' => $this->name,
'memo' => $this->memo,
'last_updated' => $this->updated_at->diffForHumans(),
'attributes' => [
'posted_by' => new UserResource($this->user),
'cover_image' => new ImageResource($this->coverImage),
]
//'tags' => TagResource::collection($this->tags),
],
'links' => [

View File

@@ -2,6 +2,7 @@
namespace App\Http\Resources;
use App\Http\Resources\Image as ImageResource;
use Illuminate\Http\Resources\Json\JsonResource;
class User extends JsonResource
@@ -21,6 +22,8 @@ class User extends JsonResource
'attributes' => [
'name' => $this->name,
'email' => $this->email,
'profile_image' => new ImageResource($this->profileImage),
'cover_image' => new ImageResource($this->coverImage),
'last_login' => optional($this->login_at)->diffForHumans(),
'is_admin' => $this->isAdmin(),
],