M working on a solution where by i need to pass data from controller to view, Based on the id.
I've tested each variable one by one for see if there is actual data contained in those variables.
one-by-one produces all the values required and as soon as i comment out the var_dumps(). Throws an Undefined index error.
Please See code below:
View
<td>
<a href="view-campaign/" class="btn btn-success mb-2"
data-toggle="tooltip" title="view campaign">
<i class="fa fa-eye"></i>
</a>
</td>
Controller
public function viewCampaign($id){
//return var_dump($id);
$img = null;
//firebase configs and send to firebase
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/serviceKey.json');
$firebase = (new Factory)
->withServiceAccount($serviceAccount)
->withDatabaseUri('https://projectName.firebaseio.com/')
->create();
$database = $firebase->getDatabase();
$ref = $database->getReference('CampaignCollection')->getValue();
foreach($ref as $key){
$item = $key['id'];
//return var_dump($item);
$poster = $key['Poster'];
//return var_dump($poster);
if($item = $id){
//return '1';
$img = $poster;
//return var_dump($poster);
}else{
return '0';
}
}
return view('view-campaign')->with('img',$img);
}
Route
Route::get('view-campaign/{id}','CampaignController@viewCampaign');
View::Results
@extends('layouts.layout')
@section('content')
<div class="col-md-12">
<div class="col-md-12 panel">
<div class="col-md-12 panel-heading">
<h4>View Campaign:</h4>
</div>
<div id="imgContainer" class="col-md-12 panel-body">
<a href="/listCampaign" class="btn btn-danger mb-2" style="margin-bottom: 15px"><i class="fa fa-arrow-circle-left"></i></a>
@if(isset($img))
<div align="center">
<img src="" />
</div>
@else
no data
@endif
</div>
</div>
</div>
@endsection
Goal is to get the base64 code to pass to the view.
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2UZI8KW
via IFTTT
Aucun commentaire:
Enregistrer un commentaire