/**
  * @param $petId
  * @return \Illuminate\Http\JsonResponse
  */
 public function index($petId)
 {
     /** @var Pet $pet */
     $pet = Pet::find($petId);
     $this->authorize('index', $pet);
     return $this->outputList($pet->photos());
 }
 /**
  * @param $petId
  * @return \Illuminate\Http\JsonResponse
  */
 public function show($petId)
 {
     /** @var Pet $pet */
     $pet = Pet::find($petId);
     if (!$pet) {
         return $this->notFound($petId, Pet::class);
     }
     $this->authorize('show', $pet);
     return $this->output($pet);
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pet::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('brood', true, "INNER JOIN");
     $query->andFilterWhere(['id' => $this->id, 'date_create' => $this->date_create, 'date_update' => $this->date_update, 'gender' => $this->gender, 'is_our_pet' => $this->is_our_pet, 'size' => $this->size, 'brood_id' => $this->brood_id, 'breed_id' => $this->breed_id, 'pet_status_id' => $this->pet_status_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     $query->andFilterWhere(['like', 'description', $this->description]);
     $query->andFilterWhere(['like', 'titles', $this->titles]);
     $query->andFilterWhere(['like', 'color', $this->color]);
     $query->andFilterWhere(['like', 'mother_name', $this->father_name]);
     $query->andFilterWhere(['like', 'mother_link', $this->father_link]);
     $query->andFilterWhere(['like', 'father_name', $this->father_name]);
     $query->andFilterWhere(['like', 'father_link', $this->father_link]);
     return $dataProvider;
 }
Пример #4
0
 /**
  * Get pet by ID
  *
  * @return json
  */
 public function getPetById($id)
 {
     return Pet::find($id);
 }