feralheart

feralheart

Member Since 2 Years Ago

Experience Points 3,270
Experience Level 1

1,730 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

30 Aug
9 months ago

feralheart started a new conversation Imagick Background

I converting a pdf to a png and it sets the background to transparent even if I add -background attribute to the command. But I want white background.

My command:

convert myPdf.pdf[0] -alpha Background -background '#FFFFFF' -fill '#FFFFFF' -trim myImage.png

How to modify this command for white background?

feralheart started a new conversation Emptying A Dir From Controller?

In my app some of the images needed for only 24hours. What's the best method to empty from controller the projectfolder/public/img/temp dir?

12 Aug
10 months ago

feralheart started a new conversation Create Image From Data Placed In Table (PHP)

I want to create an image from the data I placed in a table.

My code so far:


$out = "<table><tr><td>There will be data</td></tr></table>";
header('Content-type: image/png');
$png_image = imagecreate(50, 500);
$tcol = imagecolorallocate($png_image, 255, 255, 0);
imagestring($png_image, 4, 30, 25, $out, $tcol);
//echo $out;
imagepng($png_image);
imagedestroy($png_image);

But I got this as output:

�PNG IHDR2�E7��PLTE�����E pHYs���+IDA

What did I do wrong?

feralheart left a reply on Localisation: Whole File Is On The Screen

Thank you, that was the problem :)

feralheart started a new conversation Localisation: Whole File Is On The Screen

I want to localize my Laravel app.

I call it on blade like this: @lang('bot.bots')

But my view I got this: [[https://i.stack.imgur.com/mDyg8.png]]

My bot.php is:


<?

return [

    'bots' => 'Bot|Bots',
    'addBot' => 'Add bot',
    'editBot' => 'Edit bot',
    'deleteBot' => 'Delete bot',
    'compose' => 'Compose',
    'addGroup' => 'Add group',
    'editGroup' => 'Edit group',
    'deleteGroup' => 'Delete group',
    'confirmDeleteGroup' => 'Are you sure you want to delete the group?',
    'textRecognition' => 'Text recognition',
    'newRule' => 'Add rule',
    'deleteRule' => 'Delete rule',
    'confirmDeleteRule' => 'Are you sure you want to delete the rule?',
    'editBot' => 'Bot szerkesztése',
    'input' => 'Input',
    'output' => 'Output',
    'addInput' => 'Add input',
    'addOutput' => 'Add output',
    'blocks' => 'Block|Blocks',
    'groups' => 'Group|Groups',
    'text' => 'Text',
    'broadcast' => 'Broadcast',
    'analytics' => 'Analytics',
    'chatPartners' => 'Chat Partners',
];

What can be the problem? I did everything like what's in the documentation

06 Aug
10 months ago

feralheart started a new conversation Universal Deletion Route

Is it wise to create an universal deletion route, for example

/delete/{type}/{id}

and give it to an Universal Controller, where in a switchcase call the appropriate functions?

04 Aug
10 months ago

feralheart left a reply on Guzzle Post Error

@lostdreamer_nl still the same output :/

feralheart started a new conversation Guzzle Post Error

I have this code:

$url = 'https://graph.facebook.com/v3.0/me/messenger_profile?access_token='.$channelToken['data'];

$options['body'] = array('get_started' => [
                        'payload' => 'GET_STARTED',
                    ]);

$res = $client->post($url, $options);

But I got this as a result:

array (
  'type' => 'array',
  'output' => 
  stdClass::__set_state(array(
     'error' => 
    stdClass::__set_state(array(
       'message' => '(#100) Requires one of the params: get_started,persistent_menu,target_audience,whitelisted_domains,greeting,account_linking_url,payment_settings,home_url',
       'type' => 'OAuthException',
       'code' => 100,
       'fbtrace_id' => 'DVaKnjX9/PS',
    )),
  )),
)

What I did wrong?

23 Jul
10 months ago

feralheart started a new conversation Composer Is Out Of Memory On AWS

I trying AWS free tier (after it's good I will migrate to it). When I wanted to install Laravel I got this error upon composer install:

PHP Fatal error: Out of memory (allocated 722477056) (tried to allocate 4096 bytes) in >/usr/share/php/Composer/DependencyResolver/RuleWatchGraph.php on line 52

I already increased the memory limit to 2GB in php.ini but it still drops this error

22 Jul
10 months ago

feralheart started a new conversation How To Initialize An Eloquent Search To Use It Later?

I have the function where I build up the search terms within the function. How to initialize the search at the start to build up?

I mean like:

        $search = MyModel::where();

        $terms = explode(" ", $phrase);
        foreach($terms as $term){
            if(is_numeric($term)){
                $search->orWhere(['id', $term]);
            }
        }

        $result = $search->get();
13 Jul
11 months ago

feralheart left a reply on Error After Git Clone (vol. 2)

Interesting, Google didn't shoved me this issue :)

12 Jul
11 months ago

feralheart left a reply on Error After Git Clone (vol. 2)

@bobbybouwmann apache php version is 7.0 and restarted fpm, but still not working :/

feralheart started a new conversation Error After Git Clone (vol. 2)

The previous error was solved, but I got an another error now:

SQLSTATE[HY000]: General error: PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); the classname must be a string specifying an existing class (SQL: select * fromlanguage_lineswheregroup= *)

What's wrong?

feralheart left a reply on Error After Git Clone

@Cronix Thank you :)

feralheart left a reply on Error After Git Clone

@Cronix @tykus still not working :/

10 Jul
11 months ago

feralheart left a reply on Error After Git Clone

@Cronix @tykus

cli php version is 7.2,

apache php version is 7.0.3 (I have to use php 7.0 with this project)

I couldn't check php info with the test what you both wrote becouse I got the same error. I changed the /var/www/html/index.phpto get the phpinfo()

09 Jul
11 months ago

feralheart started a new conversation Error After Git Clone

I got this error after cloning the git repository:

Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) at /var/www/botond/vendor/symfony/translation/Translator.php:79)

I use php7.0 with this project. My composer.json is:

        "php": ">=7.0",
        "barryvdh/laravel-debugbar": "^3.1",
        "benjamincrozat/laravel-dropbox-driver": "^2.0",
        "botman/botman": "~2.0",
        "botman/driver-facebook": "^1.6",
        "botman/driver-telegram": "^1.4",
        "botman/driver-web": "~1.0",
        "botman/studio-addons": "~1.0",
        "botman/tinker": "~1.0",
        "clue/stdio-react": "^1.0",
        "doctrine/dbal": "^2.5",
        "fideloper/proxy": "~3.3",
        "guzzlehttp/guzzle": "~6.0",
        "guzzlehttp/psr7": "^1.4",
        "khill/lavacharts": "3.*",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0",
        "laravelcollective/html": "~5.0",
        "league/commonmark": "^0.17.1",
        "league/html-to-markdown": "^4.6",
        "mpociot/slack-client": "^0.3.0",
        "predis/predis": "^1.1",
        "rap2hpoutre/laravel-log-viewer": "^0.16.0",
        "serps/core": "*",
        "serps/http-client-curl": "*",
        "serps/search-engine-google": "*",
        "spatie/laravel-backup": "5.5.*",
        "spatie/laravel-translation-loader": "^2.1",
        "szymach/c-pchart": "3.*"
04 Jul
11 months ago

feralheart left a reply on ? After Function Name

@brightstormhq It's not my code. This is a package what was made by Spatie and what lot's of other people using without any error.

@Cronix Also in the Server-Monitor package:

    protected function determineNotification($event): ?BaseNotification
    {
        $eventName = class_basename($event);
        $notificationClass = collect($this->config->get('server-monitor.notifications.notifications'))
            ->filter(function (array $notificationChannels) {
                return count($notificationChannels);
            })
            ->keys()
            ->first(function ($notificationClass) use ($eventName) {
                $notificationName = class_basename($notificationClass);
                return $notificationName === $eventName;
            });
        if ($notificationClass) {
            return app($notificationClass)->setEvent($event);
        }
        return null;
    }

feralheart left a reply on ? After Function Name

@Cronix : https://github.com/spatie/laravel-backup/blob/master/src/Notifications/BaseNotification.php For example here the last function is :


    public function backupDestination(): ?BackupDestination
    {
        if (isset($this->event->backupDestination)) {
            return $this->event->backupDestination;
        }
        if (isset($this->event->backupDestinationStatus)) {
            return $this->event->backupDestinationStatus->backupDestination();
        }
        return null;
    }


And I got an error that the question mark is unexpected

feralheart started a new conversation ? After Function Name

I found that Spatie loves to use this type of function and somewhy my application isn't compatible with it.


public function myFunction() ?myFunction
{
//
}

How to make it compatible?

feralheart left a reply on Save To Cloud Vs Use Git

@lostdreamer_nl Thank you :) And should I use dropbox for this purpose? :)

feralheart started a new conversation Save To Cloud Vs Use Git

I made a site in Laravel where the users can upload some files (for example images). I configuring the backup right now and I'm thinking about how to backup these files?

Should I put these in a cloud filesystem or use git? The files are all in the public folder

25 Jun
11 months ago

feralheart started a new conversation Why To Use Laravel "HTML Objects" Instead Of Normal HTML Tags?

For example why to use {{ HTML::image($url, $alt, $attributes) }} instead of <i src="{$url}" alt="{$alt}" />?

07 May
1 year ago

feralheart started a new conversation Additional Table Vs JSONized Data?

In my DB structure there are some tables what are sliced into two. In the first table there are the main data and in the other is the additional data. For example:


channel_head
| id |     name    |       driver    | created_at | updated_at | deleted_at|
| 1   | Channel 1 | Facebook |       today      |     today          |      NULL     |
| 2  | Channel2  | Telegram |       today      |     today          |      NULL      |

channel_data
| id | channel_id |           data_type                        | data                                    |
| 1   |             1          |     FACEBOOK_TOKEN           | lysjknvlsjnf...                   |
| 2  |             1          | FACEBOOK_RECIPIENT_ID | 0123456789                    |
| 3  |            2          |        TELEGRAM_SLUG             | channel2                         |
| 4  |           2           |       TELEGRAM_API_KEY       | kefsmsékmfsekfm.... |

My question: what would be wiser? Place a column next to the driver in channel_head and save a JSONized array in it with the data or leave it as is?

04 May
1 year ago

feralheart started a new conversation Which One Is Better For Connection? Pivot Table Or JSON?

For example if we use for user_has_permission:

With pivot table we would need one more table and a query what gets all of the permissions. With JSON, there would be an additional column at the user table data and there would be a permission array.

Which method is better and why?

06 Apr
1 year ago

feralheart started a new conversation Search In A Multidimensional Array

Hi all. I have this array:


$data = array(
  0 = array(
    'data_type' => 'TIME'
    'data' => '07:00'
  ),
1 = array(
    'data_type' => 'USER_ID'
    'data' => '2'
  ),
2 = array(
    'data_type' => 'FOO'
    'data' => 'BAR'
  )
);

Is there any function where if I input for example USER_ID, than I get 2 as an output or if TIME than the output will be 07:00?

28 Mar
1 year ago
20 Mar
1 year ago

feralheart started a new conversation Markdown Into View

I have a CHANGELOG.md in my project's root. How to read it into my controller and than place it into a view?

18 Mar
1 year ago

feralheart started a new conversation Operation In Eloquent ORM

I have a Model: Message. I want to list the items what is created_at the last 5 minutes. How to do that? I thinked about:


$now = new Carbon;
$messages = Message::where([strtotime(now) - strtotime('created_at'), 300, '>'])->get();

feralheart left a reply on Localization String In Sub Array

Yes, I searched for this. Thank you :)

feralheart started a new conversation Localization String In Sub Array

Hi all! I found some localization in a sub array, for example:


'before_or_equal'      => 'The :attribute must be a date before or equal to :date.',
'between'              => [
        'numeric' => 'The :attribute must be between :min and :max.',
        'file'    => 'The :attribute must be between :min and :max kilobytes.',
        'string'  => 'The :attribute must be between :min and :max characters.',
        'array'   => 'The :attribute must have between :min and :max items.',
    ],
    'boolean'              => 'The :attribute field must be true or false.',


How to access these sub array localization from the view?

10 Mar
1 year ago

feralheart started a new conversation Eval() Don't Have Value

I stored a [email protected] in the database, but when I try to run it it don't has value.

I know that eval is very dangerous. If there is an alternative what I can use in this situation I'm open for it.

My code where I wan't to run it:


    //$action = "ExchangeController::module_getAllValutaByBank";
    //$params = "K&H";
    $test =  eval('\App\Http\Controllers\ModuleControllers' . "\" . $action . "('" . $params . "');");
    Debugbar::info($test);

The code what I want to eval:

It's an API request to the local ForexChange site. @param bank's name @return stuctured string


    public static function module_getAllValutaByBank($bankName){
        $return = '';
        $data['bankName'] = $bankName;
        $response = self::getRequest($data);

        if(is_array($response)){
            $return .= $response[0]['bank'] . "\n";
            foreach($response as $key => $item){
                $return .= $item['valuta'] . " - " . round($item['buy'], 2) . " - " . round($item['sell'], 2) . "\n";
            }
        } else {
            $return = $response;
        }

        Debugbar::info($return);
    
        return $return;
    }

Output of Debugbar::info($return);

K&H Bank GBP - 338.51 - 363.07 AUD - 189.9 - 207.8 DKK - 39.75 - 43.93 JPY - 2.26 - 2.48 CAD - 188.73 - 206.51 NOK - 30.92 - 34.18 CHF - 256.89 - 275.53 SEK - 29.18 - 32.26 USD - 246.14 - 260.32 CZK - 11.51 - 12.97 PLN - 69.87 - 78.79 EUR - 302.92 - 320.38 HRK - 39.39 - 44.41

Output of Debugbar::info($test);

null

Where it went wrong?

21 Nov
1 year ago

feralheart started a new conversation Migration: Migrate If Connection

My project is a multi-database project. Some migration files I have to run on all databases and some on one or two database. My question about: How to investigate the connection name?

So if my migration file is like

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;

class MigrationFile extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up(){

        if($database == 'myseconddatabase' || $database == 'mythirddatabase') {

          //code

        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down(){
        Schema::dropIfExists('users');
    }
}

and I give the command php artisan migrate --database=myfirstdatabase

How to give the value 'myfirstdatabase' to the $database variable?

20 Nov
1 year ago

feralheart started a new conversation Wildcard Subdomain On Localhost

I have a Laravel project where I want to use subdomains. I creating the testing enviroment at local right now and the .conf file looks like this:

<VirtualHost *:80>
        DocumentRoot /var/www/myproject/public
        ServerName *.myproject
        <Directory "/var/www/myproject/public/">
                AllowOverride All
                Options FollowSymLinks
        </Directory>
</VirtualHost>

I also added the 127.0.0.1 *.myproject to the hosts file.

But after sudo a2ensite myproject and sudo service apache2 restart I got the following error message:

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details

After disabling myproject.conf it restarts without error.

What did I missed? Can you give me some advice?

09 Nov
1 year ago

feralheart left a reply on Blade Syntax Error With Empty String Variable

@saurabh @tisuchi I deleted the value="..."-s in the form to show the var_dump($data),, and now it shows the same error on the end of the file (when it renders the blade templates).

I now thinking about that it's a composer update error what I ran a few hours ago. I checked in git that the updated packages was these:

package name
version from
version to

"name": "laravel/framework", 
"version": "v5.5.19", 
"version": "v5.5.20", 

"name": "nikic/php-parser", 
"version": "v3.1.1", 
"version": "v3.1.2",

"name": "psy/psysh", 
"version": "v0.8.13", 
"version": "v0.8.14", 

"name": "doctrine/instantiator", 
"version": "1.0.5", 
"version": "1.1.0", 

"name": "phpunit/php-code-coverage", 
"version": "5.2.2", 
"version": "5.2.3",

"name": "phpunit/phpunit", 
"version": "6.4.3", 
"version": "6.4.4", 

"name": "sebastian/comparator", 
"version": "2.0.2", 
"version": "2.1.0", 

feralheart left a reply on Blade Syntax Error With Empty String Variable

@saurabh I tried it but it's the same

@tisuchi I use Laravel 5.5 and it shows this row as the error. My action looks like this:

public function newTag($id = 0){

        $tag = array();
        $tagTrans = array();

        if ($id > 0){
            $tag = Tags::where(['id' => $id])
                            -> first()
                            -> toArray();

            $tagTransRaw = TagTrans::where(
                                    ['tag_id' => $id ])
                                ->get()
                                ->toArray();

            foreach ($tagTransRaw as $key => $tagTransFE) {
                $tagTrans[$tagTransFE['lang']] = $tagTransFE['text'];
            }  
        }

        $data = array(
                'id' => $id,
                'tag' => $tag,
                'tagTrans' => $tagTrans,
            );

        return view('back/news/newTag', $data);
    }

feralheart started a new conversation Blade Syntax Error With Empty String Variable

Hi all! I have this input:

<input class="form-control" type="text" id="nameEng" name="nameEng" value="{{$tagTrans['en']}}" />

And if the variable is empty I got this message:

Parse error: syntax error, unexpected ''); ?>">' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ')'

If it isn't empty everything is perfect. Why?

07 Nov
1 year ago

feralheart started a new conversation Automatic Translate

I want a "recent news" module to my Laravel webapp. I made this webapp on my mother language and than translated it with the buit-in translation strings to english. Is there any auto translation method? Or I have to define two other columns in the "news post" table? (title_eng, text_eng)

02 Nov
1 year ago

feralheart started a new conversation Change The Div With Ajax And Multiple [email protected]

I want to change the div's content with ajax (I don't want to reload all of the page when I click on the links), i found some documentations, but I only saw "static" solutions (they "hard coded" that "if you click on this bring this", but I don't want to use a 3000 row switch-case on the bottom of my project).

Someone can show me a "dynamic" solution where I only have to give the controller, action and the parameters to the on-click and the jquery router makes the routing without tinkering?

My example code:

<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
    <head>
        @include('includes.head')
    </head>
    <body>
        <div id="header">
         <nav id="navbar" class="navbar navbar-default">
           <ul class="nav nav-tabs navbar-right">
                <li>
                    <a action="[email protected]" params="[a => 24, b => 52]">
                        <button type="button" class="btn btn-link">First Example</button>
                    </a>
                </li>
                <li>
                    <a action="[email protected]" params="[id => 1, newValue => 42]">
                        <button type="button" class="btn btn-link">Second Example</button>
                    </a>
                </li>
         </nav>
        </div
        <div id="app">
            <!-- This will be changed by the router -->
        </div>
        <footer class="container navbar">
            @include('includes.footer')
        </footer>

        <!-- Scripts -->
        <script src="{{ asset('js/app.js') }}"></script>
    </body>
</html>

Controller Actions

class FirstExampleController extends Controller{

    public function firstExample(Request $request){
        $a = $request -> a;
        $b = $request -> b;

        $c = $a + $b;

        return $c;
    }
}
class SecondExampleController extends Controller{

    public function secondExample(Request $request){
        $id = $request -> id;
        $newValue = $request -> newValue;

        //database operation where the id's object's new value will be $newValue

        return $this->showItems;
    }
}
23 Oct
1 year ago

feralheart started a new conversation Migration Question

Hi all! My new project is a multi database project where the codebase is the same and every client has his/her own database.

My questions:

  1. If I have a new client and I create a database for him/her, how to run all of the migrations for only that database?
  2. If I make some changes (for example a new table) how to run it on all of the databases?
14 Oct
1 year ago

feralheart started a new conversation Laravel Bootstrap-material Messes Up The Site

Hi all! I wanted to implement [Daemonite's Bootstrap Material] (https://daemonite.github.io/material) to my site, but when I do everything accordingly what is in the documentation, I end up with a mess (for example it kills the bootstrap's grid system). What did I missed?

10 Oct
1 year ago

feralheart started a new conversation Show Loading Animation On Pageload

Hi all!

I want to show loading animation on pageload. I read somewehere that I have to load the frame and then change the div's content with ajax, but how can I achieve it under Laravel? Someone can show me an example?

28 Aug
1 year ago

feralheart started a new conversation Trying To Get Property Of New Object

How to convert

Trying to get property of a non-object

error int

404 error?

24 Aug
1 year ago

feralheart started a new conversation Professional Routing

I route like this myapp/newPartner or myapp/showPartner/{$partnerId}.

Is there any "routing standard", that looks better?

16 Aug
1 year ago

feralheart started a new conversation VPS Vs Cloud Hosting

Hi all!

If you have the chance to rent VPS and/or a Cloud Hosting (with only FTP connection to it, but it has a prebuilt email server and a gratis domain) which one would you choose?

13 Aug
1 year ago

feralheart started a new conversation Laravel - Configure Modellog

As we know, the model has 2/3 timestamps where it logs the 'created_at', 'updated_at' and 'deleted_at'. I want to add a 'who' method for this three timestanp where the model will log, that who created/updated/deleted that row.

Where I can add this method?

12 Aug
1 year ago

feralheart started a new conversation Database - More "log Collumn"

I want to add some other columns next to the created_at and updated_at columns, for example:

  • deleted_at
  • creator
  • updater
  • deleter

The last three should be contain user.id.

What is the better method?

  • A. place it in the migration
  • B. Edit the Blueprint class?