mercredi 28 septembre 2016

Enable features of Laravel project to update and delete json objects with firebase

I am using firebase and mysql as the backend. I can insert data to firebase using laravel project. But deleting and updating operations only valid for mysql. I want to make active those features for firebase also. I am using 'Mpociot\Firebase\SyncsWithFirebase' to sync data with firebase. It is perfectly working for insertion only. But there's already built in methods for all the database operations in the syncsWithFirebase php file. I need a solution for that guys.

 public function store(Requests\EventRequest $request){

    $request->all();

    $current=Carbon::now();
    $t=substr($current,11,-3);
    $d=substr($current,0,-9);
    $st=explode(":",$t);
    $currentTime=$st[0].$st[1];
    $postTime=$_POST['time'];
    $time=explode(":",$postTime);

    $insertTime=$time[0].$time[1];
    $date=$_POST['eventDate'];
    if(strcmp($d,$date)==0) {
       if ($currentTime > $insertTime) {


           Session::flash('errorTime', 'Time is passed.');
           return redirect()->back()->withInput();
       }
    }
    $events=EventCal::all();
    foreach($events as $ev){
        $ti=substr($ev->time,-8,5);

        if( (strcmp($ev->eventDate,$date)==0) && (strcmp($ev->venue,$_POST['venue'])==0) && (strcmp($ti,$postTime)==0) ){

            Session::flash('errorDate', 'There is already an event for this time,Venue and Starting Date');
            return redirect()->back()->withInput();
        }
    }



    $input=Request::all();

    if (Input::hasFile('photo')) {
        $file = Input::file('photo');
        // getting image extension
        $extension = $file->getClientOriginalExtension();
        // renameing image
        $fileName = rand(11111, 99999) . '.' . $extension;
        // uploading file to given path
        $file->move('images', $fileName);
        $input['photo'] = "images/$fileName";
    }


    EventCal::create($input);
    flash()->success('Successfully Added','Good Job');
    return redirect('/evntform');

}

Above is the code for inserting which works fine.

 public function index5($id){

    $evnt = EventCal::where('id', '=', $id)->delete();
    return redirect('/dcalendar');
}

And above code is to deleting which is not sync with firebase. I tried to find the answer for several time and even asking from my friends on stack. So if anyone can find a solution to my problem it will be a great worthy to me.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2dg3Gus
via IFTTT

Aucun commentaire:

Enregistrer un commentaire