lundi 20 novembre 2017

how to highlight string in a string in a laravel blade view

Somewhere in my template I have this:



Now in this text I want to highlight all words that are in the string



So I thought I create a new blade directive:



Blade::directive('highlightSearch', function($input, $searchString)...

error: missing argument 2

Found out that directives do not except 2 arguments. I tried every workaround that I could find but none worked. They always return the arguments as a plain string, not even passing the actual values.

I tried adding a helper function like explained here: http://ift.tt/2zXcYGl. Did not work:

error: unknown function "highlightSearch"

So how do I do this super easy task in laravel? I don't care about the highlighting function, that's almost a one-liner.



via Chebli Mohamed

samedi 18 novembre 2017

linux server Creates cache and laravel project gone down

I have stuck in a problem that my laravel project deployed in linux server and server is creating cache in var directory. I run 'yum clean all' command but again creates cache. I run command php artisan cache:clear, php artisan route:clear but no result. is there any way to manage server cache? I face, the error is...

ErrorException in Filesystem.php line 81:
file_put_contents(): Only 0 of 255 bytes written, possibly out of free disk space

my project size is 120 mb.



via Chebli Mohamed

vendredi 17 novembre 2017

Laravel Redis Queue - Reserved jobs not removed on failure

I'm using redis as the queue driver for Laravel 5.1. It seems that when a job fails due to a fatal error, such as an exceeded execution time, the reserved job is not removed from the queue. I can check in the redis-cli on the queues:default:reserved key that it's still there. And the job is reattempted over and over again instead of being deleted. I have two workers on the queue and retries are set to 1.

My artisan command is: artisan queue:listen --tries=1

The failed() method on the job is not called, nor is the Queue::failing() listener with the redis driver. These are not issues if I'm using the database driver.

Does anyone have any suggestions on what I should be looking for to solve this?



via Chebli Mohamed

jeudi 16 novembre 2017

Pass variable from custom Laravel Helpers to Blade file

I'm trying to create a helper to centralize a complicated Form::select.

My helper:

namespace App\Helpers;
use Log;
use App\Countries;

class Address {
    public static function country() {
        $countries = Countries::orderby('name_zh','asc');
        $form = "Form::select('countries', \$countries);";
        return $form;
    }
}

My View:

{!! Address::country() !!}

I would like to have this select form with $countries variable from this helper and show a Dropdown list on my view. How do I do it?



via Chebli Mohamed

mardi 14 novembre 2017

Error 500 when post data to database

I'm new in php and Laravel. I get error code 500 when I post my data.

this my form code in my blade :

    <form method="post" class="form-horizontal" id="form"
            action="">
            

and this is my method in my controller :

    public function store(Request $request)
{
    if($request->ajax()){
        $data = collect($request->all())
            ->except(['_token'])
            ->all();

        $akun = SetLinkAkunCoa::create($data);

        if($akun){
            $response = $this->returnSuccess('', trans('messages.success.update'));
            return response()->json($response);
        }else{
            $response = $this->returnData('', trans('messages.error.update'));
            return response()->json($response);
        }
    }
}

Please someone help me to solve this. thank's anyway



via Chebli Mohamed

dimanche 12 novembre 2017

FatalThrowableError in ServiceProvider.php line 49: Class 'Dompdf\Dompdf' not found

can i get some help to solve this problem, it works perfectly in my local, but in heroku i keep getting this error.

i tried:

heroku run php artisan cache:clear heroku run php artisan config:cache

But it did not work.

enter image description here

My providers, i am following the instructions to use Barryvdh\DomPDF:

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
    Illuminate\Auth\AuthServiceProvider::class,
    Illuminate\Broadcasting\BroadcastServiceProvider::class,
    Illuminate\Bus\BusServiceProvider::class,
    Illuminate\Cache\CacheServiceProvider::class,
    Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
    Illuminate\Routing\ControllerServiceProvider::class,
    Illuminate\Cookie\CookieServiceProvider::class,
    Illuminate\Database\DatabaseServiceProvider::class,
    Illuminate\Encryption\EncryptionServiceProvider::class,
    Illuminate\Filesystem\FilesystemServiceProvider::class,
    Illuminate\Foundation\Providers\FoundationServiceProvider::class,
    Illuminate\Hashing\HashServiceProvider::class,
    Illuminate\Mail\MailServiceProvider::class,
    Illuminate\Pagination\PaginationServiceProvider::class,
    Illuminate\Pipeline\PipelineServiceProvider::class,
    Illuminate\Queue\QueueServiceProvider::class,
    Illuminate\Redis\RedisServiceProvider::class,
    Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
    Illuminate\Session\SessionServiceProvider::class,
    Illuminate\Translation\TranslationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\View\ViewServiceProvider::class,
    //Para configurar laravel Collective
    Collective\Html\HtmlServiceProvider::class,
    //Generar pdfs en la aplicacion
    Barryvdh\DomPDF\ServiceProvider::class,

    /*
     * Application Service Providers...
     */
    noMasTattut\Providers\AppServiceProvider::class,
    noMasTattut\Providers\AuthServiceProvider::class,
    noMasTattut\Providers\EventServiceProvider::class,
    noMasTattut\Providers\RouteServiceProvider::class,

],

/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/

'aliases' => [

    'App'       => Illuminate\Support\Facades\App::class,
    'Artisan'   => Illuminate\Support\Facades\Artisan::class,
    'Auth'      => Illuminate\Support\Facades\Auth::class,
    'Blade'     => Illuminate\Support\Facades\Blade::class,
    'Bus'       => Illuminate\Support\Facades\Bus::class,
    'Cache'     => Illuminate\Support\Facades\Cache::class,
    'Config'    => Illuminate\Support\Facades\Config::class,
    'Cookie'    => Illuminate\Support\Facades\Cookie::class,
    'Crypt'     => Illuminate\Support\Facades\Crypt::class,
    'DB'        => Illuminate\Support\Facades\DB::class,
    'Eloquent'  => Illuminate\Database\Eloquent\Model::class,
    'Event'     => Illuminate\Support\Facades\Event::class,
    'File'      => Illuminate\Support\Facades\File::class,
    'Gate'      => Illuminate\Support\Facades\Gate::class,
    'Hash'      => Illuminate\Support\Facades\Hash::class,
    'Input'     => Illuminate\Support\Facades\Input::class,
    'Lang'      => Illuminate\Support\Facades\Lang::class,
    'Log'       => Illuminate\Support\Facades\Log::class,
    'Mail'      => Illuminate\Support\Facades\Mail::class,
    'Password'  => Illuminate\Support\Facades\Password::class,
    'Queue'     => Illuminate\Support\Facades\Queue::class,
    'Redirect'  => Illuminate\Support\Facades\Redirect::class,
    'Redis'     => Illuminate\Support\Facades\Redis::class,
    'Request'   => Illuminate\Support\Facades\Request::class,
    'Response'  => Illuminate\Support\Facades\Response::class,
    'Route'     => Illuminate\Support\Facades\Route::class,
    'Schema'    => Illuminate\Support\Facades\Schema::class,
    'Session'   => Illuminate\Support\Facades\Session::class,
    'Storage'   => Illuminate\Support\Facades\Storage::class,
    'URL'       => Illuminate\Support\Facades\URL::class,
    'Validator' => Illuminate\Support\Facades\Validator::class,
    'View'      => Illuminate\Support\Facades\View::class,
    //terminando configurar laravel collective
    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,
    //Facade para generar PDFs
    'PDF' => Barryvdh\DomPDF\Facade::class,

],

And my composer.json:

"require": {
    "php": "^7.0",
    "laravel/framework": "5.1.*",
    "laravelcollective/html": "5.1.*",
    "guzzlehttp/guzzle": "~5.3|~6.0",
    "barryvdh/laravel-dompdf": "^0.8.1",
    "doctrine/dbal": "^2.5"

},



via Chebli Mohamed

vendredi 10 novembre 2017

"A non-numeric value encountered" laravel5.1 php7.1 dompdf 0.8

I understood that this error was already solved but i don't manage to fix it, so sorry and thanks for your advises: I'm working on a Laravel 5.1 project (FusionInvoice) and use dompdf to create pdf files. My aim is to use php7.1 for this project.

After enable php7.1 I had the "A non-numeric value encountered" error so i did the easy installation procedure of dompdf, with composer method (http://ift.tt/13J3PJw) to fix it using the dompdf 0.8.1 release. My requierements seems ok.

Now i have this error:

FatalThrowableError in domPDF.php line 30: Class 'DOMPDF' not found

we are talking about this file "app/Support/PDF/Drivers/domPDF.php" and this function:

private function getPdf($html)
    {
        $pdf = new \DOMPDF();
        $pdf->set_paper($this->paperSize, $this->paperOrientation);
        $pdf->load_html($html);
        $pdf->render();

        return $pdf;
    }

I understood that the "new \DOMPDF();" is calling this file '/vendor/dompdf/dompdf/src/Dompdf.php' to build his object. so i tried this : "new \Dompdf\Dompdf();"

and i'm back to the first place:

ErrorException in Page.php line 499: A non-numeric value encountered

Does someone knows how i can solve this issue ? Thanks...



via Chebli Mohamed