How to solve update part error in Laravel 4.2 - laravel-4.2

I'm attending to editprofile details. Update Method in Registercontroller.php
public function updateprofile(){
$id=Input::get('id');
//validation part;
$users= Register::find($id);
$users->name=Input::get('username');
$users->age=Input::get('age');
$users->email=Input::get('email');
$users->save();
}
Form action attribute in editprofile.blade.php
<form action="updateprofile" method="post">
After change in some fields and update I got an error
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException13.
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
…\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php210

Related

fill datatable with vueJS

i´m trayin to fill my data table with vueJS and all my data from DB. I´m usign this library:
https://jamesdordoy.github.io/laravel-vue-datatable
It´s ok if i use this in my controller:
User::all()
return response()->json($query);
and in my component:
<div class="">
<data-table :data="data" :columns="columns" #on-table-props-changed="reloadTable"></data-table>
</div>
this library contain method to sortBy, orderBy, search by name, etc... with this:
use JamesDordoy\LaravelVueDatatable\Http\Resources\DataTableCollectionResource;
public function index(Request $request)
{
$length = $request->input('length');
$sortBy = $request->input('column');
$orderBy = $request->input('dir');
$searchValue = $request->input('search');
$query = User::eloquentQuery($sortBy, $orderBy, $searchValue);
$data = $query->paginate($length);
return new DataTableCollectionResource($data);
}
but if i use this in my controller in laravel 8 returned me:
Call to undefined method App\Models\User::eloquentQuery()
i don´t know if this it means to use get(), all().
Also, if i´m not use this and i to do all search manually, for example:
if(isset($sortBy)){
$query = User::all()->sortBy($sortBy);
$data = $query->paginate($length);
}
return response()->json($query);
returned me that:
Method Illuminate\Database\Eloquent\Collection::paginate does not exist
if i removed paginate and return $query, return all my data en my web browser console in network tab, but my table it´s empty...
for back-end i´m using laravel-8
in my web browser console return this message:
Invalid prop: type check failed for prop "data". Expected Object, got Array
if i change :data in my component for :items error in web browser console disappear
i don´t understand that i´m doing wrong for in one case i can fill my table and in other not...
Thanks for read and help me
i resolve my question with this:
$query = \DB::table('users')->orderBy($sortBy, $order)->paginate(10);
with model i can´t

how to add hooks to cms pages in prestashop 1.7

I am discovering PrestaShop 1.7 and am trying to add a module to a specific CMS page.
However, CMS pages don't let me run any smarty code which means I can't call any of my hooks.
What I would usually add to put a module somewhere:
{hook h='displayMyhook'}
I have seen solutions for 1.6 but they all revolve around editing "CMS.tpl" which doesn't seem to exist in 1.7.
Could anyone suggest a solution?
Hook Creation:
public function install()
{
return parent::install()
&& $this->registerHook('diplayAccessoryExtraProduct')
&& $this->registerHook('displayModalContent');
}
You can create a hook, with the name of your choice: displayMyNewHook
Show hook in (any) tpl file:
{block name='diplayAccessoryExtraProduct'}
{hook h='diplayAccessoryExtraProduct' id_product=$product.id_product mod="mymodule"}
{/block}
or (no value for function)
{block name='diplayAccessoryExtraProduct'}
{hook h='diplayAccessoryExtraProduct' mod="mymodule"}
{/block}
Function in the module:
public function hookDiplayAccessoryExtraProduct($params)
{
$accessories = $this->getAccessories((int)$params['id_product']);
$this->context->smarty->assign(array(
'accessories_custom' => $accessories,
)
);
return $this->display(__FILE__, 'views/templates/front/accessory.tpl');
}
public function getAccessories($id_product)
{
// Code
return $result;
}
This is a real example of a module I have developed.

Mvc 6 taghelper asp-action route not working

I'm using Areas in Mvc 6 and trying to route to each specific area.
For example I have this:
My controller looks is decorated with a Area and route attribute, like so:
[Authorize]
[Area("Test")]
[Route("[area]/[controller]")]
public class TestController : Controller
Then, I have two HTTPGET methods defined like below:
public IActionResult Index()
{
var model = new TestViewModel();
return View(model);
}
public IActionResult Create()
{
var model = new TestViewModel();
return View(model);
}
Finally my form looks like this:
<form asp-route-area="Test" asp-controller="Test" asp-action="Create" asp-antiforgery="false" method="get">
<input type="submit" value="Generate test"/>
</form>
When I try to post the form it throws the following:
AmbiguousActionException: Multiple actions matched. The following
actions matched route data and had all constraints satisfied:
Areas.Test.Controllers.TestController.Index
Areas.Test.Controllers.TestController.Create
You would think that it would bind to my Create method when I define it in the asp-action, but when I check the rendered markup of the form it looks like this:
<form method="get" action="/Test/Test">
<input type="submit" value="Generate test">
</form>
My method Create isn't handled, It only renders Test/Test (area/controller).
I've also tried to decorate my method with [Route("Create")] and [HttpGet("Create")] without results.
Am I missing out on something obvious here?
If you are using RC1 then you can't use areas in tag helpers.
Areas in tag helpers are supported in RC2 link to issue

ClientValidation In Form not showing When I Send Id Variable To Jquery in YII

I Need Help in Yii, i get problem in my form, the problem is if i put id in textfield then client validation not showing for that field but another field no problem. This is my code in form
<div class="row">
<?php echo $form->labelEx($model,'latar_belakang'); ?>
<?php echo $form->textField($model,'latar_belakang',array('id' => 'latarbelakang','class' => 'input-block-level')); ?>
<?php echo $form->error($model,'latar_belakang'); ?>
<?php echo $form->labelEx($model,'rumusan_masalah'); ?>
<?php echo $form->textField($model,'rumusan_masalah',array('id' => 'rumusanmasalah','class' => 'input-block-level')); ?>
<?php echo $form->error($model,'rumusan_masalah'); ?>
</div>
for your knows i use id in textfield for calculaten field with jquery which i put in form . this is my jquery code in form
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerScript('totalValues',"
function totalValues()
{
var lb = $('#latarbelakang').val() ;
var rm = $('#rumusanmasalah').val();
var tot = parseInt(lb) + parseInt(rm);
$('#nilaiakhir').val( tot );
}
", CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScript('changeTotals', "
$('#latarbelakang').change( function(){ totalValues(); } );
$('#rumusanmasalah').change( function(){ totalValues();} );
", CClientScript::POS_END);
What i must do ? for solving this problem ?.
Thanks B4..
By default Yii generates ids of fields dynamically using model name and field name.
For example for 'password' field of 'User' model the id would be 'User_password'
You can inspect a field(to which you have not given your custom id) with firebug and see the auto generated id. also yii maps error messages with those auto generated ids in response. that is why your error messages are not showing.
what you can do is to try to call that js function with yii generated id.

Yii CListView: how to disable all additional html

Im trying to generate RSS page with CListView but i got additional generated html in my results:
<div id="yw0" class="list-view">
<div class="items">
and
<div class="keys" style="display:none" title="/index.php/rss"><span>2383</span><span>4743</span><span>1421</span></div>
How can i remove it?
actually it is quite simple, only a few lines of code.
INSTEAD of using CListView, just use its guts:
$data = $dataProvider->getData();
foreach($data as $i => $item)
Yii::app()->controller->renderPartial('your_item_view',
array('index' => $i, 'data' => $item, 'widget' => $this));
that's it.
You can't do it without changing CListView class (yii v.1.1.8).
CListView extends CBaseListView
http://code.google.com/p/yii/source/browse/tags/1.1.8/framework/zii/widgets/CBaseListView.php
/**
* Renders the view.
* This is the main entry of the whole view rendering.
* Child classes should mainly override {#link renderContent} method.
*/
public function run()
{
$this->registerClientScript();
echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
$this->renderContent();
$this->renderKeys();
echo CHtml::closeTag($this->tagName);
}
/**
* Renders the key values of the data in a hidden tag.
*/
public function renderKeys()
{
echo CHtml::openTag('div',array(
'class'=>'keys',
'style'=>'display:none',
'title'=>Yii::app()->getRequest()->getUrl(),
));
foreach($this->dataProvider->getKeys() as $key)
echo "<span>".CHtml::encode($key)."</span>";
echo "</div>\n";
}
There's a very good wiki tutorial on Yii site about generating Feeds. CListView is intended to display an html list of items, not feed of any kind.