I am trying to follow a tutorial found here :
http://wern-ancheta.com/blog/2014/08/10/using-datatables-with-laravel/ to incorporate datatables into my laravel but have encountered the following error
Undefined variable: table (View: C:\xampp\htdocs\laravel\awsconfig\app\views\search.blade.php
here is my controller :
<?php
class HomeController extends BaseController {
protected $layout = 'search';
public function users(){
$table = Datatable::table()
->addColumn('instanceId',
'imageId',
'privateDnsName',
'publicDnsName',
'keyName',
'instanceType',
'launchTime',
'kernelId',
'subnetId',
'vpcId',
'privateIpAddress',
'publicIpAddress',
'architecture',
'rootDeviceType',
'rootDeviceName',
'virtualizationType',
'sourceDestCheck')
->setUrl(route('instance.search'))
->noScript();
$this ->layout->content = View::make('search', array('table' => $table));
}
}
and my view :
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AWS Config Search</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/css/jquery.dataTables.min.css">
<style>
#import url(//fonts.googleapis.com/css?family=Raleway:700);
body {
margin:0;
font-family:'Raleway', sans-serif;
text-align:center;
color: #3a3a3d;
}
.welcome {
width: 300px;
height: 200px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -150px;
margin-top: -100px;
}
a, a:visited {
text-decoration:none;
}
h1 {
font-size: 32px;
margin: 16px 0 0 0;
}
</style>
</head>
<body>
<div class="row">
<div class="col-md-12">
<h3>AWS Configuration</h3>
{{ $table->render() }}
{{ $table->script() }}
</div>
</div>
#stop
</body>
</html>
any help would be greatly appreciated
try using
View::make('search')->with('table', $table);
Related
I'm discovering Laravel and VueJs
I just intalled it using laravel installer
I think blade is not working because when i do npm run dev, the welcome.blade.php looks like that:
As you can see, the blade directives appear...
I didn't change the code give but it looks like this:
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: 'Nunito', sans-serif;
font-weight: 200;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links > a {
color: #636b6f;
padding: 0 25px;
font-size: 13px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
#if (Route::has('login'))
<div class="top-right links">
#auth
Home
#else
Login
#if (Route::has('register'))
Register
#endif
#endauth
</div>
#endif
<div class="content">
<div class="title m-b-md">
Laravel
</div>
<div class="links">
Docs
Laracasts
News
Blog
Nova
Forge
Vapor
GitHub
</div>
</div>
</div>
</body>
</html>
If someone have an idea to fix that ;)
Good day. I recently learn about laravel. Then, i'm trying to fetch data from database (I'm using Sqlsrv) But i face an error
htmlspecialchars() expects parameter 1 to be string, object given
(View: D:\xampp\htdocs\boby\resources\views\welcome.blade.php)
Here is my script
routes/web.php
Route::get('/', function () {
$datauser = DB::table('users')->get();
return view('welcome',compact('datauser'));
});
and my view is like this (like welcome.blade.php)
<!doctype html>
<html lang="{{ config('app.locale') }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: 'Raleway', sans-serif;
font-weight: 100;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links > a {
color: #636b6f;
padding: 0 25px;
font-size: 12px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
</style>
</head>
<body>
<ul>
#foreach ($datauser as $user)
<li> {{ $user }} </li>>
#endforeach
</ul>
</body>
</html>
how can handle this error ? thanks in advance
You can't display an object like that. You need to fetch the properties when displaying.
<li> {{ $user->id }} </li>>
<li> {{ $user->name }} </li>>
<li> {{ $user->email }} </li>>
You can use the {{}} to display object.
in the foreach , $user is an object ,
if you want to show user's email, use it {{ $user->email }}
<DOCTYPE! html>
<head>
<link rel="stylesheet" type="text/ccs" href="css/indexcss.css">
</head>
<body>
<div id="wrapper">
<div id="header">
<?php
include("utilbar.php");
include("navbar.php");
?>
</div>
<?php
if (isset($_GET["type"])) {
$page = $_GET["type"];
}
else {
$page = "home";
}
//echo "<body onload=\"changeContent('".$page."')\">";
?>
<!--script>
function contentOnload() {
window.location.href('content.php');
}
</script-->
<script>
function navClick(contentName)
{
window.location.href = "index.php?type=" + contentName;
}
</script>
<div class="container">
<?php include($page.".php"); ?>
</div>
<div class="footer">
<?php include("footer.html"); ?>
</div>
</div>
</body>
</html>
CSS here:
html, body {
height: 100%;
margin: 0;
padding: 0;
}
.container {
width: 100%;
margin: auto;
margin-top: 0;
padding: 0;
}
.footer {
bottom: 0;
position: absolute;
}
So I'm trying to get a footer to stick under the content of all my includes, but sometimes it jumps above the content of the included file. I've looked up most possible sticky footer guides and tried to apply them, but none seem to work like they should. I've been trying to fix this for a while now.
Here's the footer HTML CSS:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/footercss.css">
<title>Footer</title>
</head>
<body>
<div id="containerf">
<div id="logos"></div>
<div id="foottext">
<img src="images/youtube.png" height="25" width="25">
<img src="images/twitter.png" height="25" width="25">
<img src="images/fbtrp.png" height="25" width="25">
<b>| Schaafstraat 137 | © 2016 Kopala | All rights reserved.</b>
</div>
</div>
</body>
</html>
#containerf {
width: 100%;
height: 180px;
background-color: #006666;
position: absolute;
bottom: 0;
margin-bottom: 500px;
}
#foottext {
line-height: 180px;
text-align: center;
color: #d9d9d9;
}
#foottext img {
padding-right: 5px;
}
In which file did you set the .footer to bottom:0; ? It seems that you declared it in a regular style.css but in the fotter.htm you include footercss.css
You should paste the bottom:0; to the footercss.css
Similar questions have been asked before but unfortunately I am still not able to find a solution of my problem.
I want to render a view with its layout and store its response into a variable.
I have an action called pdf as shown below.
public function pdfAction(){
$ids = $this->getParam('id');
$entity = $this->getParam('entity');
$referer = $this->getRequest()->getServer('HTTP_REFERER');
if(empty($ids) || empty($entity)){
$this->_helper->redirector->gotoUrlAndExit($referer);
}
$grid = $this->_exportModel->getExportGrid($ids, $entity);
if(empty($grid->data[0])){
$this->_helper->messenger->error('No user was found for the given id. Please pass the correct parameters and try again.');
$this->_helper->redirector->gotoUrlAndExit($referer);
}
/* I would like to render the view here and get its response below. */
$html = '';
$pdf = new Om_PDF();
$pdf->writeHtmlToPDF($html);
}
This is the pdf view for the above action.
<?php echo $this->render('templates/grid/print-grid.phtml'); ?>
And here's the pdf layout
<?php echo $this->doctype(); ?>
<html moznomarginboxes mozdisallowselectionprint>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" media="all"/>
<style type="text/css">
.container {
margin: 0 auto;
max-width: 1000px;
text-align: center;
margin-top: 30px;
}
#media print {
#page {
size: auto;
margin: 15mm 10mm 15mm 10mm;
}
body {
margin: 0px;
}
.page-break {
display: block;
page-break-before: always;
}
.print-view-table {
float: left;
width: 45% !important;
margin-right: 5%;
}
.print-view-table tr th, .print-view-table tr td {
width: 30%;
}
.print-view-table tr th {
background-color: #e0e0e0 !important;
border: 1px solid #ddd;
-webkit-print-color-adjust: exact;
}
}
</style>
<head>
<?php ?>
</head>
<body>
<div class="container">
<div class="row">
<?php echo $this->layout()->content; ?>
</div>
</div>
</body>
</html>
So far I have tried using render() and partial() methods but none of them worked.
Is there a way using which I can get the out put of the pdf view along with its layout inside the pdfAction() method?
You need to use :
$this->_helper->layout->setLayout('/path/to/your/pdf_layout_script');
in your pdfAction() and after that you can use render() or partial() methods, the corrects layout should be out put
I am following this tutorial :
http://creative-punch.net/2013/12/implementing-laravel-4-full-text-search
I have followed it through adapting to my own project my question is how do I display the results that I have queried thanks
code as follows : view
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Laravel PHP Framework</title>
<style>
#import url(//fonts.googleapis.com/css?family=Lato:700);
body {
margin:0;
font-family:'Lato', sans-serif;
text-align:center;
color: #999;
}
.welcome {
width: 300px;
height: 200px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -150px;
margin-top: -100px;
}
a, a:visited {
text-decoration:none;
}
h1 {
font-size: 32px;
margin: 16px 0 0 0;
}
</style>
</head>
<body>
<div class="search">
{{ Form::model(null, array('route' => array('ec2_instance.search'))) }}
{{ Form::text('query', null, array( 'placeholder' => 'Search query...' )) }}
{{ Form::submit('Search') }}
{{ Form::close() }}
</div>
</body>
</html>
my controller :
<?php
class PostsController extends BaseController {
public function postSearch(){
$q = Input::get('query');
$posts = ec2_instance::whereRaw("MATCH(instance_id,instance_type,availability_zone, status_checks,alarm_status, public_dns, key_name ) AGAINST(? IN BOOLEAN MODE)",
array($q))->get();
return View::make('ec2_instance.search', compact('ec2_instance'));
}
}
?>
my routes :
Route::get('/', function()
{
return View::make('search');
});
Route::post(
'ec2_instance/search',
array(
' as' => 'ec2_instance.search',
'uses' => 'PostsController#postSearch'
)
);
?>
Ok I'll make some assumptions here so you may have to alter the code a bit to fit your needs...
First you certainly don't need to pass ec2_instance to the view but rather the result $posts
return View::make('ec2_instance.search', compact('posts'));
Now since your result will be a collection of posts you need to loop over it in your view:
ec2_instance.search
#foreach($posts as $post)
{{-- display properties here --}}
{{ $post->key_name }}
{{-- etc... --}}
#endforeach