Working on Laravel Project, I have two layouts.
app.blade.php see on my git repo
old_app.blade.php see on my git repo
When I use #extends('layouts.old_app') in my blade file, its working fine like this:
old_app.blade.php
But when I use #extends('layouts.app') in my blade file, the checkbox is gone:
app.blade.php
This is my Controller:
public function create()
{
$permission = Permission::get();
return view('roles.create', compact('permission'));
}
This is my View
<div class="form-group">
#foreach($permission as $value)
<label>{{$value->name}}
<input type="checkbox" class="name" value="{{$value->id}}" name="permission[]">
</label>
#endforeach
</div>
Sorry for my bad english, I would to say thanks for anyone who can help me.
I could think in 2 obvious things.
Permission::get(); does not return any record (maybe you forgot to seed the database, to little info to speculate)
You got a problem with the html + css, either the template have a error or you are forgetting something like a div.row before the checkbox, try pasting a working set of checkbox inside the view, if you can't see it, try putting it before the #yield('content')
Related
I am trying to use Laravel 8 Livewire Modal Popup for data entry with going on another page. But I get undefine the variable _instance and not able to understand it.
#entangle($attributes->wire('model'))
This line creates this error when I remove this from views/vendor/jetstream/components/modal.blade.php. the error will go.
Line no 34.
<div id="<?php echo e($id); ?>" x-data="{ show: <?php if ((object) ($attributes->wire('model')) instanceof \Livewire\WireDirective) : ?>window.Livewire.find('<?php echo e($_instance->id); ?>').entangle('<?php echo e($attributes->wire('model')->value(
x-show="show"
x-on:close.stop="show = false"
x-on:keydown.escape.window="show = false"
class="fixed top-0 inset-x-0 px-4 pt-6 sm:px-0 sm:flex sm:items-top sm:justify-center"
style="display: none;">
This was causing me much angst too but I think I found the solution: as #georgy-malanichev says, you can only call Livewire methods from inside a Livewire component (and not from inside a Blade component or any other custom components).
Given you are trying to use the component inside resources/views/dashboard.blade.php, the solution is to:
create a livewire component using artisan make:livewire MyDashboard
Cut everything between <x-app-layout> and </x-app-layout> in dashboard.blade.php and paste it into views/livewire/my-dashboard.blade.php
Add #livewire('my-dashboard') inside the x-app-layout tags and Bob's your uncle (it should start working)
To help you understand what's going on, if you look at the source code for the modal component, you'll see a line like: show: #entangle($attributes->wire('model')),. I'm not sure how to describe exactly what this does, but, essentially, #entangle() is expecting an instance of the "model" Livewire object and it's not finding one.
It's not finding it because it's getting called from a non-livewire component. Once you put it inside a Livewire component, it starts working.
I hope the additional details makes things clearer.
I was getting the same error but in my case it was the fact that I had x-data="{ open: #entangle('showDropdown') }" outside of the LiveWire component. Once I moved it inside the component template, where it should be, the issue went away.
I started a laravel + vuejs project (fontend and backend in the same project).
It is basically a migration from a pure php-html project. I am wondering if it would be possible to migrate only a part of it, and to integrate the rest of it.
After your answers (thanks :) ), here is myview.blade.php:
#extends('template')
#section('contenu')
<div id="app">
#php
$path = public_path('myview/oldfile.php');
include($path);
#endphp
</div>
#endsection
Now I have an issue:
** Issue 1 **
I have this kind of code in the old php files:
<script type="text/javascript" src="./js/jquery-1.7.2.min.js">
but I also have scripts in my template (which contains the navbar and footer). Then of course I get this error
[Vue warn]: Error compiling template:
Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <style>, as they will not be parsed.
** Issue 2 **
$.post("./myview.php", "mode=activateForm&id1=<?=$id1?>&id2=<?=$_GET["id2"]?>", function() {
MethodNotAllowedHttpException
The POST method is not supported for this route. Supported methods: GET, HEAD.
The new issue is this, and I don't get why...
Any suggestions?
When you use #include in blade template it will look for the file inside of resource/views directory.
so use it like #include('posts/index').
where it will look for index.php inside of views/posts/ directory.
Do not use .php inside #include.
#extends('template')
#section('contenu')
<div id="app">
#include("yourDirectory/oldfile");
</div>
#endsection
Use the public path helper.
Put the files in your public folder and use public_path('filename.php'); in your include statement.
I recently started to build a Laravel/blade web application and I want to switch between what my layout view is showing. I want to replace 'content' with some other blade.php view when I press a button in the layout file. For example in ReactJS you can just determine the rendered content with an IF statement and some vars.
<div class="container">
#yield ('content')
</div>
I googled a bit but couldn't find a straight forward solution so I wondered if this is common in Laravel or do you just have to make a lot of different layout files with other #yield('...')? A lot of code would be duplicated right?
You can use conditional blade directives
#if(Session::get(user_type') == 'Admin')
#extends('layouts.admin')
#else
#extends('layouts.normal')
#endif
#section('title')
#endsection
#section('content')
etc ....
I have tried all in this link :
php laravel blade template not rendering
My codes are here.
my views/layouts/master.blade.php file contains
<html>
<body>
#section('sidebar')
This is the master sidebar.
#show
<div class="container">
#yield('content')
</div>
</body>
</html>
my views/child.blade.php file contains
#extends('layouts.master')
#section('content')
<p>This is my body content.</p>
#endsection
my route.php contains
Route::get('blade', function () {
return view('child');
});
from my browser I typed in :
http://localhost/larablog/public/blade
The output is a blank page.
I tried with non blade pages and it worked, I also passed normal variable to non blade pages which also worked. When I try with blade templating, the page seems to be blank always.
Please let me know where I went wrong.
Thanks.
As in the following link
Proper laravel storage permissions
I had a permission issue at
storage/framework/views folder.
I changed the folder permission to 777 and it all solved the issue.
May be Problem is with the routing
Route::get('/blade', function () {
return view:('child');
});
If you're running on apache make sure the web server has write permission to the storage directory.
I deploying my PHP project on CentOS and i using Zend Framework.
I have problem:
When i call an action from another action's view and it displayed is good on Windows Server but not good on CentOS Server. It's not load info in head tag when view source html.
Example:
In file: index.phtml (for index action in Product controller)
<div class="left">
<?php echo $this->action('left', $this->controller,'product',array('currentModule'=>$this->module)); ?>
</div>
<div class='right'>
<?php echo $this->action('list', $this->controller, 'product',array('currentModule'=>$this->module,'back'=> $this->back,'page'=> $this->page)); ?>
</div>
So, we can see. In index.phtml, i called 2 another action (left action and list action in Product controller). Windows is OK but on CentOS, this code is not work.
Please help me for it run on CentOS.
When i was try remove 2 this action:
<div class="left">
//code
</div>
<div class='right'>
//code
</div>
So, it's woking on CentOS :)
Thanks!
Windows migrations to unix based systems usually run into problems like this when you have case sensitivity issues - windows doesn't require case to be correct but unix does. Make sure your folders and php file names have the correct case and try it again - if not give us some of the errors your encountering and we could help more!
By the way, a little off topic here but the action view helper is not efficient, I would suggest looking into custom view helpers and the render view helper instead.