vendredi 28 juillet 2017

Application key error?

i have recently pull a project from git hub to understand it's working i am trying to generate the application key for this project but keep on getting the error. Any help would be really appreciated. Thanks in Advanceenter image description here



via Chebli Mohamed

Get Calculated Field from Eloquent only when it was declared

I'm working with Eloquent and Laravel 5, added a field at $appends attribute on model and a mutator to get it value. My issue is, how get this field only when it is called?

    public static $model = 'Model';
    protected $table = 'table';
    protected $primaryKey = 'idtable';   
    public $incrementing = false;
    public $timestamps = false;

    protected $appends = ['DescComposta'];

    //Mutators
    public function getDescCompostaAttribute()
    {
        return $this->attributes['desc_composta'] = 'yes';
    }

Thank you all!



via Chebli Mohamed

failed() never triggered in laravel 5.4

Hi guys I am just using queues with Laravel 5.4 for the first time and I am having issues.

I can't seem to have failed() be triggered. Do I need to call it manually if something goes wrong? what I am doing is throwing exceptions in handle() in my job if something doesnt go right, I have my failed() function reverting everything i did but nothing is executed, not even a simple echo. I have tried with

public function failed() // doesnt work
public function failed($exception) // doesnt work
public function failed(Exception $exception) // same as doc, doesnt work

It never gets triggered..

If someone can point me in the right direction that would be awesome.

(Running the queue with php artisan queue:work database -queue=publish

Thanks



via Chebli Mohamed

how to solve this exception in laravel ? Symfony\Component\Debug\Exception\FatalThrowableError

I run this command to create model.

php artisan make:model BaseModel

but issue this exception

[Symfony\Component\Debug\Exception\FatalThrowableError]                   
 Parse error: syntax error, unexpected '<<' (T_SL), expecting end of file 

may i know how to handle this issue.



via Chebli Mohamed

Loading Linecons and some JS in a fresh laravel project

I started a new laravel project (this is not a laravel issue) and the project is about a dashboard using same styles as this one : http://ift.tt/2rIq31V . I recopied every single style in assets folder, downloaded fonts .. everything is in the right place BUT : - Menus are not showing on click (dropdown) - Linecons not showing WHILE fontawesome are ! - Some scripts pictures (diagrams, sparklines ..) not showing while many others are (all are initialized from one file)

This is really weird .. here is my url : http://ift.tt/2v37dXS The thing is that when inspecting the page, the is nothing with 404 error or JS error !

Any help is welcome



via Chebli Mohamed

Laravel Form:select Multi select not working if array value is numeric

Form:select()

I want to select multiple options in select, but its only work if Array index key is string, If array index key is numeric its not working...

Any help please..

Working Example:

Form::select($field_data['name'], 
         array('L' => 'Large', 'M' => 'Medium', 'S' => 'Small'), //Options list
         array('S', 'M'), //Selected values
         array('multiple')); //Multiple True

Not working with Numeric Array Keys

Form::select($field_data['name'], 
         array('5' => 'Large', '2' => 'Medium', '10' => 'Small'),  //Options list
         array('10', '2'),  //Selected values
         array('multiple')); //Multiple True

// Just Form>select>options print, but no option selected

I want to select multiple option, and options keys are numeric ids..



via Chebli Mohamed

Javascript not working when rendering a view using ajax

My structure looks like this

head.blade.php

<html class="no-js">
<head>
    <title></title>
</head>

<body class="page">
@include('layouts.sidepanel')

sidepanel.blade.php

div class="sidebar">
<ul>
   <li>
      <a href="#" class="menu-item" onclick="getPages({method: 'page',httpMethod: 'GET',uri: 'page',});">Page</a>
   </li>
</ul>
</div>

foot.blade.php

<script type="text/javascript" src=></script>
<script type="text/javascript" src=></script>    
    </body>
</html>

base-layout.blade.php

@extends('layouts.head')


<main class="with-footer">

    <div class="row main-grid">
        @yield('content')
    </div>
</main>
@include('layouts.foot')

the controller

public function getSettings() {

        $settings = DB::table('settings')->get();

        $returnHTML = view('settings')->with('settings', $settings)->render();
        if($request->ajax()) {
            return response()->json(array('success' => true, 'data'=>$returnHTML));
        }
    }

settings.blade.php

@extends('layouts.base-layout')
@section('content')
<p>Test</p>
@endsection

and this javascript function

function getPages(params) {
    $.ajax({
        type: params.httpMethod,
        url: params.uri
    }).done(function (data) {
        switch (params.method) {
            default:
                if (data.success) {
                    if (data.data) {
                        $('.main-grid').html(data.data).fadeIn();
                    }
                }
                break;
        }
    })
}

Extending the base-layout inside settings.blade.php will duplicate the sidebar inside the main-grid class and the js is working but I don't want to another page inside settings exactly like the main, I just want the content and the js to work when rendering it.

I've also tried renderSection()['content'] but had the same results.



via Chebli Mohamed