DataTables not found - laravel

I am using KoolReport Laravel page to generate report.
Koolreport has DataTables class but when i use it i got the error :
Class 'DataTables' not found (View: C:\xampp\htdocs\invoice\resources\views\reports\report.blade.php)
My code :
<html>
<head>
<title>My Report</title>
</head>
<body>
<h1>It works</h1>
<?php
DataTables::create([
"dataSource"=>$this->dataStore("users"),
"options"=>array(
"paging"=>true
)
]);
?>
</body>
</html>

Please include Datatable declaration as below in your Controller file.
<?php
use \koolreport\datagrid\DataTables;
?>
Or as an alternative, you can directly specify full path in blade file.
\koolreport\datagrid\DataTables::create([
"dataSource"=>$this->dataStore("users"),
"options"=>array(
"paging"=>true
)
]);
Reference links :
KoolReport datatables
KoolReport Blade

Try to use '\'
#php
\DataTables::create([
"dataSource"=>$this->dataStore("users"),
"options"=>array(
"paging"=>true
)
]);
#endphp

Related

Laravel: Pages not loading properly

This might look useless question, but I'm unable to understand the problem here.
The problems are:
1. When I load the page, first this loads:
And then, after uploading the file:
this page loads:
2. yield('content') is not working. Although #include is working fine.
3. I made master.blade.php, to load the first page of the website. Before it, I was working on the welcome page.But, then changed the work of welcome with the master blade, but when the page gets loaded, it doesn't show anything.
Routes:
Route::get('/',function() {
return view('welcome');
});
Route::group(['middleware' => ['web']], function(){
Route::get('upload',function(){
return view('pages.upload');
});
Route::post('/upload','UploadController#upload');
});
views/pages/upload:
#extends('welcome')
#section('content')
<h2>Upload Files Here</h2>
{!! Form::open(array('url' => '/upload','files'=>true))!!}
{!! Form::file('file') !!}
{!! Form::token() !!}
{!! Form::submit('Upload') !!}
{!! Form::close() !!}
#endsection
views/welcome:
<!DOCTYPE html>
<html lang="en">
<head>
#include('partials._head')
</head>
<body>
#include('partials._nav')
<div class="container">
#include('partials._messages')
#yield('content')
#include('partials._footer')
</div>
#include('partials._javascript')
UploadController/Controllers:
if($request->hasFile('file')){
$file = $request ->file('file');
$fileName = $file->getClientOriginalName();
$destinationPath = config('app.fileDesinationPath').'/'.$fileName;
$uploads = Storage::put($destinationPath,file_get_contents($file- >getRealPath()));
}
return redirect()->to('/upload');
When it's working fine when I used include, to include the upload page in welcome, but the result is like shown in the pictures.Also, When I tried to use the master blade, and exclude the use of the welcome page, by erasing the content of the welcome page, the blank page gets loaded.
What changes do I have to make to make use of master instead of the welcome page? Why are two pages getting loaded? also, why isn't yield('content') not working?
Also, the file which I'm uploading is not getting saved in the public/uploads folder.
Please can anyone help?

view extension in laravel

Can you please tell why page in not getting inherited
File Structure:
Views> backEnd>masterPage.blade.php
<body>
<header class="main-header">
</header>
#yield('content')
<footer class="main-footer">
</footer>
File Structure:
Views> backEnd>usercontrol>home.blade.php
#extends('backEnd.masterPage')
#section('content')
<div class="content-wrapper">
</div>
#stop
at current i am not using Controller,just using routes.php
Route::get('home', function () {
return view('backEnd.masterPage');
});
Firstly, replace #endsection with #stop. The endsection tag depreciated in Laravel 4.
Then in your routes.php
Route::get('home', function () { return view('backEnd.usercontrol.home'); })
There is no need to access through controller there are some debugging tips that might help you
1 clear you cache by this php artisan cache:clear
2 dump-auto load your file by composer dump-autoload --optimize
as such there is no mistake found in your code it should work after optimizing
noted:
please change your route to child view
Route::get('home', function () {
return view('backEnd.usercontrol.home');
});

Codeigniter summernote fail result

I am using the codeigniter framework with the summernote editor.
If I use a single page in php post without the framework, the result is just like this:
<span style="font-weight: bold;">asdasdasd</span>
But if I use post in codeigniter the result is different, like this:
<span bold;">asdasdasd</span>
style='font-weight: ' is missing..
Why did it happen, and what is the solution?
Thank you for helping.
I got the answer...
in codeigniter don't use :
$_POST['content'] OR $_GET['content']
but use :
$_REQUEST['content']
PROBLEM SOLVED!
I think that is a xss filter problem, try to disable or get the value to false.
$content = $this->input->post('content', FALSE);
I've edited with original summernote example:
<div class="span12">
<h2>POST DATA</h2>
<pre>
<?php print_r($this->input->post(NULL, FALSE)); ?>
</pre>
<pre>
<?php echo htmlspecialchars($this->input->post('content', FALSE)); ?>
</pre>
</div>

ajaxLink and multiple instances of jQuery

I am working in Zend-Framework. I have a layout something like this:
<html>
<head>
<script>
function myBeforeSendCallbackJsFunc() {$('#content-loading').show();}
function myCompleteCallbackJsFunc() {$('#content-loading').hide();}
</script>
</head>
<body>
<div id="menu">
<?php
echo $this->ajaxLink("<li>MENU 1</li>", '/controllertest/actionindex', array('update' => '#content', 'beforeSend' => 'myBeforeSendCallbackJsFunc();', 'complete' => 'myCompleteCallbackJsFunc()'), array('format' => 'ajax'));
?>
</div>
<div id="content">
</div>
<?php echo $this->jQuery()->enable()->uiEnable(); ?>
</body>
</html>
In this case the ajaxLink function works perfectly.
I fire the MENU 1 and '#content' gets the '/controllertest/actionindex' content.
But if exists ajaxLink functions inside the'/controllertest/actionindex' it only works if I include again:
<?php echo $this->jQuery()->enable()->uiEnable(); ?>
Why?
When calling the AjaxLink helper repeatedly in some inclusions via ajax I was generating multiple instances of the ajax function created by this helper.
When called asynchronously, the AjaxLink creates confusion.
The solution: don't use AjaxLink, and create a global and unique ajax function.

Codeigniter Image and Source URL

I have a problem with Codeigniter URL. I have a controller "welcome.php" :
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
function __construct()
{
parent::__construct();
}
public function index()
{
$data['tiung'] = 'index';
$this->load->view('welcome_message',$data);
}
public function dor($bus)
{
$data['tiung'] = $bus;
$this->load->view('welcome_message',$data);
}
}
and a view "welcome_message.php" :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to CodeIgniter</title>
</head>
<body>
sesuatu <?php echo $tiung?>
<img src="fragor.jpg" width="720" height="246" alt=""/>
ladalah
</body>
</html>
If I want to access the controller function 'dor' with a parameter I used this :
localhost/hostname/index.php/welcome/dor/something
and it works, but the problem is the image isn't loaded. I tried to put the image file in the webroot folder, 'application' folder, and even in the 'views' folder. But the image still can't load. Where should I put the image file?
The best practice for this is to create an /images/ directory in your webroot (the folder with index.php) and use the base_url() function to get the link to the image, I.E.
<img src="<?php echo base_url('images/fragor.jpg'); ?>" width="720" height="246" alt=""/>
Don't forget to load the url helper either with the autoloader or manually before using site_url() or base_url().
Also if you're using CodeIgniter's rewrite rules to remove the index.php from the URL (which it doesn't look like you're doing), don't forget to exclude the /images/ directory from the rewrite.
In CodeIgniter there is a specific way to indicate an image...like
echo img('images/gautam.gif');
put this in your view file and you need to create "images" folder at your root
Though you have to add CI helper 'html' in autoload config, but this goes easy after.
<?php
$image_properties = array(
'src' => 'images/picture.jpg',
'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time',
'class' => 'post_images',
'width' => '200',
'height'=> '200',
'title' => 'That was quite a night',
'rel' => 'lightbox'
);
img($image_properties);
?>
/* <img src="site.com/index.php/images/picture.jpg" alt="Me, demonstrating how to eat 4 slices of pizza at one time" class="post_images" width="200" height="200" title="That was quite a nigh`enter code here`t" rel="lightbox" />*/
OR JUST simple:
<?php
echo img('images/picture.jpg'); ?>
// gives <img src="site.com/images/picture.jpg" />

Resources