CKEditor issue with Laravel 5 - laravel

I have a problem with CKEditor, it return me this result : <p style="text-align:center"><span style="font-family:Lucida Sans Unicode,Lucida Grande,sans-serif"><span style="font-size:14px">News content blah blah blah</p> instead of the text itself. I did successfully loaded the editor to form. Here is the form code :
{!! Form::textarea('abstrak', null, ['class' => 'form-control ckeditor']) !!}
the view that supposed to show the result :
<h5>{{ $jurnal->abstrak }}</h5>
and I load the js file from master template :
<script src="{{ asset('ckeditor/ckeditor.js') }}"></script>
is there something I missed here ? thankyou

Instruct Laravel Blade to not escape HTML characters by replacing your code with
<h5>{!! $jurnal->abstrak !!}</h5>

Related

Vue warn: Property is not defined. Form input binding + conditional rendering

I have some trouble with input binding and conditional rendering: e.g. if I select grade = 1, I want to show the date field. When I load the page, I get:
[Vue warn]: Property or method "grade" is not defined on the instance but referenced during render.
My form:
<form id="school">
<div class="form-group">
{!! Form::label('grade', 'Grade') !!}
{!! Form::select('grade', $grades, null, ['v-model' => 'grade']) !!}
</div>
<div class="form-group" v-show="grade == 1">
{!! Form::label('date', 'Date') !!}
{!! Form::date('date', null,) !!}
</div>
</form>
Vue instance:
<script src="/js/app.js"></script>
<script>
new Vue({
el: '#school',
data: {
grade: 1
}
});
</script>
What am I missing here? I am new to Vue and really want to learn more!
Edit:
When I look to the source code of my browser, I see that the v-model attribute has disappeared. E.g.: when I write <input type="text" name="test" v-model="test">, I see <input type="text" name="test">
Found the answer here
So Laravel comes with a Vue instance..

How to convert a blade file to HTML and save it?

For example, there is a file \resources\views\test.blade.php:
#extends('layouts.app')
#section('content')
<div class="container">
{{ $article->content }}
</div>
#endsection
I want to save it as \resources\views\html\test.html. What should I do?
I would try something like this, although I haven't test it my self:
File::put('test.html',
view('resources.views.test')
->with(["article" => $article])
->render()
);

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?

Laravel white page loading route

I had a login.blade.php with some code, and I decided to replace with a new one.
I renamed it to old_login.blade.php and create a new file, in the same path, with the name login.blade.php.
After a while, I decided to rollback to my old login page.
I delete login.blade.php, and renamed the old_login.blad.php with the original name to return back.
No code was edited, only views.
The problem is that the page returned a blanck white page with many comments (the comment's tag is not closed).
I try to make a copy of the view, called test.blade.php, and change the route to that view. It diplay them correctly. But If I change another time route to myapp.login to display login.blade.php view, it won't work.
I try anything but nothing is changed. I'm using laravel 5.1.
The code insiede my routes.php is
Route::get('/', function () {
return view('myapp.login');
});
the code inside the login.blade.php (same ad test.blade.php) is:
#extends("app")
#section("content")
{!! Form::open(["url" => "home"]) !!}
<div class="form-group">
{!!Form::label("username", "Username:") !!}
{!!Form::text("usr_username", "Luca", ["class" => "form-control"]) !!}
</div>
<div class="form-group">
{!!Form::label("password", "Password:") !!}
{!!Form::input("password", "usr_password", "mypass", ["class" => "form-control"]) !!}
</div>
<div class="form-group">
{!!Form::submit("Login", ["class" => "btn-primary form-control"]) !!}
</div>
{!! Form::close() !!}
#include("errors.list")
#stop
So a nonsense answer to resolve my problem: I cutted the code inside login.blade.php, save file, pasted it, and saved another time. Now it display correctly.

How to add javascript in views in Laravel 4 Starter Site

i have a question related to Laravel 4 Starter Site
The following is one of the view page.
#extends('site.layouts.default')
{{-- Web site Title --}}
#section('title')
{{{ Lang::get('site.contact_us') }}} ::
#stop
{{-- Content --}}
#section('content')
{{{ Lang::get('site.contact_us') }}}
#stop
In the site.layouts.default template, Jquery is included. How could i include other javascript like
{{ HTML::script('http://cdn.datatables.net/1.10.0/js/jquery.dataTables.js') }}
into the view file? It should included after the jquery library.
Thanks in advance!
You may use:
#section('scripts')
{{ HTML::script('...') }}
#stop
Anywhere in your view after #extends('...'). Because there is #yield('scripts') in the bottom of the layout, right after the scripts (jQuery and BootStrap).
This is another example:
{{-- Scripts --}}
#section('scripts')
<script type="text/javascript">
$(document).ready(function() {
//...
});
</script>
#stop

Resources