mercredi 3 octobre 2018

Create filter in laravel API controller

`<?php

namespace App\Http\Controllers;

use App\Event;
use App\Mosque;
use App\Activity;
use Illuminate\Http\Request;

class NotificationController extends Controller
{
    public function list()
    {
        $mosques = Mosque::get();

        $array = array();

        foreach ($mosques as $mosque) {
            array_push($array, [
                'mosque_name' => $mosque->name,
                'mosque_image'=> $mosque->image
            ]);
        }

        return $array;

        return response()->json(['result' => $mosques]);
    }

    public function show(Request $request)
    {
        $mosque =  Mosque::find($request->mosque_id);
        $mosque->activities;
        $mosque->events;

        return response()->json(['result' => $mosque]);
    }
}`

hi i want to create a filter to show mosque with event or activities only. any idea to display the mosque with activities or events only ?. this one from backend that later will be fetch using reac



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire