<?php

namespace Edulab\College\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class StudentResource extends JsonResource
{

    public function itemLink()
    {
        return guard_url('college/student') . '/' . $this->getRouteKey();
    }

    public function title()
    {
        if ($this->title != '') {
            return $this->title;
        }

        if ($this->name != '') {
            return $this->name;
        }

        return 'None';
    }

    public function toArray($request)
    {
        return [
            'id' => $this->getRouteKey(),
            'title' => $this->title(),
            'slug' => $this->slug,
            'college_id' => $this->college_id,
            'standard_id' => $this->standard_id,
            'name' => $this->name,
            'email' => $this->email,
            'password' => $this->password,
            'admission_no' => $this->admission_no,
            'roll_no' => $this->roll_no,
            'father' => $this->father,
            'mother' => $this->mother,
            'fathers_mobile' => $this->fathers_mobile,
            'mothers_mobile' => $this->mothers_mobile,
            'blood_group' => $this->blood_group,
            'location' => $this->location,
            'gender' => $this->gender,
            'dob' => $this->dob,
            'mobile' => $this->mobile,
            'phone' => $this->phone,
            'api_token' => $this->api_token,
            'remember_token' => $this->remember_token,
            'email_verified_at' => $this->email_verified_at,
            'user_id' => $this->user_id,
            'user_type' => $this->user_type,
            'address' => $this->address,
            'street' => $this->street,
            'city' => $this->city,
            'district' => $this->district,
            'state' => $this->state,
            'country' => $this->country,
            'photo' => $this->photo,
            'certificates' => $this->certificates,
            'status' => $this->status,
            'team_id' => $this->team_id,
            'created_at' => !is_null($this->created_at) ? $this->created_at->format('Y-m-d H:i:s') : null,
            'updated_at' => !is_null($this->updated_at) ? $this->updated_at->format('Y-m-d H:i:s') : null,
            'meta' => [
                'exists' => $this->exists(),
                'link' => $this->itemLink(),
                'upload_url' => $this->getUploadURL(''),
                'workflow' => $this->workflows(),
                'actions' => $this->actions(),
            ],
        ];
    }

    /**
     * Get additional data that should be returned with the resource array.
     *
     * @param     \Illuminate\Http\Request  $request
     * @return array
     */
    public function with($request)
    {
        return [
            'meta' => [
                'exists' => $this->exists(),
                'link' => $this->itemLink(),
                'upload_url' => $this->getUploadURL(''),
                'workflow' => $this->workflows(),
                'actions' => $this->actions(),
            ],
        ];
    }

    /**
     * Get the workflows for the resource.
     *
     * @return array
     */
    private function workflows()
    {
        $arr = [];
                return $arr;

    }
    
    /**
     * Get the actions for the resource.
     *
     * @return array
     */
    private function actions()
    {

        $arr = [];
        
        return $arr;
    }
}