artyak

artyak

Member Since 6 Months Ago

Experience Points
780
Total
Experience

4,220 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 Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 1
780 XP
Jul
22
3 months ago
Activity icon

Replied to How To Use HTML Tags At Lang?

Is this correct use?

htmlspecialchars_decode(trans_choice('notify.craft_summ', $summa))

Because i now received only word coins, without   and without space

Activity icon

Started a new Conversation How To Use HTML Tags At Lang?

I have a simple translation:

'craft_summ' => ' &nbsp coin|coins ',

but at site i received &nbsp coins.

I use at my controller files localization. My trans function looks like:

'message' =>. $summa. trans_choice('notify.craft_summ', $summa).,

I need that trans_choice understood HTML tags, how can I do this?

Because here i can't use {!! !!} because it's not blade file

Jul
20
3 months ago
Activity icon

Replied to How To Use A Lot Of Translations In Laravel?

X it's static word, without translate, yes dot - it's my mistake.

But it's doesn't fix the problem :(

Activity icon

Replied to How To Use A Lot Of Translations In Laravel?

And now i have same question, why it's not work?

'message' => trans('notify.bust_withdraw') . $get->amount .  X =   . $cashout .  trans('notify.bust_nostart')  . $profit . ,

I received error:

Parse error: syntax error, unexpected ''. $get->amount . '' (T_CONSTANT_ENCAPSED_STRING), expecting ']'
Jul
19
3 months ago
Activity icon

Started a new Conversation How To Use A Lot Of Translations In Laravel?

I have a function in which I need to make 3 translations for the Russian and English versions. I have done it simply:

'message' => 'You have '.($i->sum * 2).' '.Lang::choice('coin|coins', ($i->sum * 2), [], 'en').' for #'.$this->id.'',

It works perfect, but now i make translation and has 3 translations, i need make something like this:

'message' => trans('notify.add_balance1') .($i->sum * 2).' trans('notify.add_balance2') trans('notify.add_balance3') '.$this->id.'',

But always i has errors, how i understand, I am missing a dot or a quotation mark somewhere when writing.

How can I write this correctly?

Jul
12
3 months ago
Activity icon

Started a new Conversation Problem With Currency Conversion

In my store I try to convert currencies, for English-speaking users to $, for Russian-speaking users in rubles. But there is a problem that the conversion does not work when changing the language.

At layout.blade i use:

const LANG = '{{ Config::get('languages')[App::getLocale()] }}';

too see what language user now use, and it show's en, okay, all good.

At item price i use:

@if(Lang::has('antaras8.kurs')) {{ round($item->price) }}  @else{{ \App\Http\Controllers\Controller::getActualCurs($item->price) }} @endif

At /resources/lang/ru and /en i has file antaras8.php with some translations. At ru lang i has antaras8.kurs and it use only {{ round($item->price) }}, but in en lang i has only file antaras8 without kurs and it need to use \App\Http\Controllers\Controller::getActualCurs($item->price) }} how i write, but it always show Russian currency without changes, but language set to english.

/lang/ru/antaras8.php:

<?php

return [
    'info1' => 'от',
    'info2' => 'до',
    'kurs' => 'руб'
];

/lang/en/antaras8.php:

<?php

return [
    'info1' => 'from',
    'info2' => 'to'
];

It's my antaras8.php file with translate. At RU version i has kurs at EN version i don't has this value.

If i make @if(Lang::has('antaras8.kurs')) Russian @else English @endif i always received Russian, but i switched to EN site version.

Why is it? How i can fix this problem?

Jul
11
3 months ago
Activity icon

Replied to Laravel 5.1 Swith Language

You mean make something like this: $usd = round($value[1]); ?

Activity icon

Replied to Laravel 5.1 Swith Language

maybe you can help me with another error? i also make actual money curs, for russian languange Rubles, for english version USD currency, i has this code:

public static function getActualCurs($rub) {
    $link = 'http://www.cbr.ru/scripts/XML_daily.asp';
    $str  = file_get_contents($link);

    preg_match('#<Valute ID="R01235">.*?.<Value>(.*?)</Value>.*?</Valute>#is', $str, $value);

    $usd = $value[1];

    $dollar = $rub/$usd;

    return round($dollar,3);
}

but i received error A non well formed numeric value encountered, how i understand it's problem with php version? i use php v.7.2.31

Activity icon

Replied to Laravel 5.1 Swith Language

it works, thank you

Activity icon

Started a new Conversation Laravel 5.1 Swith Language

I try to make language swith at Laravel 5.1.

At my config/languages.php i use:

<?php

return [
    'en' => 'en',
    'ru' => 'ru',
];

At my LanguageController i use:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Http\Requests;
use Config;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;

class LanguageController extends Controller {

    public function switchLang($lang)
        {
        if (array_key_exists($lang, Config::get('languages'))) {
            Session::set('applocale', $lang);
        }
        return Redirect::back();
        }
}

At the layout.blade i write:

const LANG = '{{ Config::get('languages')[App::getLocale()] }}';

At app/Http/Kernel i add at 22 line:

\App\Http\Middleware\Language::class,

And at the routes i use:

Route::get('lang/{lang}', ['as'=>'lang.switch', 'uses'=>'[email protected]']);

But when i try go to site.com/lang/en i received error:

ErrorException in LanguageController.php line 16:
array_key_exists() expects parameter 2 to be array, null given

Who can say me, where my mistake? If you need more details - please, ask

Jun
01
4 months ago
Activity icon

Started a new Conversation Carbon Differents

I have weekly discounts on the product on my site, when buying, the user is written how much the discount will still be valid. There is a problem in calculating the time between hours and minutes.

In order to calculate how many days there will be a discount, I do it like this:

$realTime = Carbon::now();
$diff = $realTime->diff($item->created_at);
$date = 7 - $diff;
    if ($diff->d <= 6) {
        Notify::create(
            [
            'user_id' => $this->user->id,
            'title' => 'Message',
            'message' => 'Discount will be available '.$date.' '.Lang::choice('day|days|', $date, [], 'ru'),'',
            'status' => '2',
        ]);
    }

This is returned to me by the inscription that the discount will be available for another 1, 2, 3 ... days.

And now, how i can calculate the remaining hours and minutes?

I try something like this:

$realTime = Carbon::now();
$diff_hours = $realTime->diff($item->created_at);
$date_hours = 24 - $diff->h;
$date_minutes = 60 - $diff->i;

    if ($diff->h == 7) {
        Notify::create(
            [
            'user_id' => $this->user->id,
            'title' => 'Message',
            'message' => 'Discount will be available '.$date_hours .' '.Lang::choice('hour|hours|', $date_hours , [], 'ru'),'',
            'status' => '2',
        ]);
    }

    if ($diff->i <= 59) {
        Notify::create(
            [
            'user_id' => $this->user->id,
            'title' => 'Message',
            'message' => 'Discount will be available '.$date_minutes .' '.Lang::choice('minutes|minutes|', $date_minutes , [], 'ru'),'',
            'status' => '2',
        ]);
    }

Subtracting 24 - $ diff-> h; I do because I have 24 hours in a day, and by the same principle I do 60 - $ diff-> i; because I have 60 minutes in an hour. It seems that everything is shown normally, but when 1 minute is left until the end of the discount, for example, and if you wait a few minutes and make a purchase again, it says that it is 59 minutes until the end of the discount, that is, because of the difference in minutes, it just updates.

How can I correctly display the remaining hours and minutes?

May
26
5 months ago
Activity icon

Started a new Conversation Laravel Does Not Make 1 Value When Parsing

I make online matches on the Dota 2 game on the site. I use a third-party service for parsing. Everything works as intended, only there is 1 problem. I have 2 Tournament and Tournament_teams models. Here's the problem: when parsing, the data in Tournament is duplicated 3-4 times, screenshot:

enter image description here

It shows that somewhere the data is duplicated 3 times, somewhere the data is duplicated 4 times, it is not clear for what reason.

And the problem is in Tournament_teams, now I did parsing and I got an answer that now 2 teams are playing with the names ViKin.gg and CR4ZY, which have match_id = 561715. The team ViKin.gg in the database has match_id 561715, but their opponents CR4ZY have empty values. If you do a search on CR4ZY, then I get 5 records with an empty match_id, ViKin.gg has 2 records with a filled match_id, the rest with empty values. This is the main problem and my headache. Here is screenshot from database:

enter image description here

Here is my code, which make parsing:

public function execute()
    {
        $postFields = ['token' => $this->key];
        $tournaments = $this->sendCurl($postFields, $this->url);
        $postFields_matches = ['token' => $this->key];
        $matches = $this->sendCurl($postFields_matches, $this->matches);
        $postFields_live_matches = ['token' => $this->key];
        $live_matches = $this->sendCurl($postFields_live_matches, $this->live_matches);
        $postFields_finish_matches = ['token' => $this->key];
        $finish_matches = $this->sendCurl($postFields_finish_matches, $this->finish_matches);
        foreach($tournaments as $tournament)
        {
            $teams = $tournament->teams;
            $league_name = $tournament->league->name;
            $serie_name = $tournament->serie->name;
            if ($serie_name === null) {
                $full_name = $league_name;
            } else {
                $full_name = $league_name.": $serie_name";
            }
            $filtered_matches = [];
            foreach ($matches as $match) {
                if ($match->tournament_id != $tournament->id) {
                    continue;
                }
                $filtered_matches[] = $match;
                foreach ($teams as &$team) {
                    if (false !== strpos($match->slug, $team->slug)) {
                        $team->match_id = $match->id;
                        $logo = $team->image_url;
                    }
                }
            }
            foreach ($live_matches as $live) {
                if ($live->tournament_id != $tournament->id) {
                    continue;
                }
                $filtered_matches[] = $live;
                foreach ($teams as &$team) {
                    if (false !== strpos($live->slug, $team->slug)) {
                        $team->match_id = $live->id;
                        $logo = $team->image_url;
                    }
                }
            }
            foreach ($finish_matches as $finish) {
                if ($finish->tournament_id != $tournament->id) {
                    continue;
                }
                $filtered_matches[] = $finish;
                foreach ($teams as &$team) {
                    if (false !== strpos($finish->slug, $team->slug)) {
                        $team->match_id = $finish->id;
                        $logo = $team->image_url;
                    }
                }
            }
            $this->tournamentRepository->saveUpdate($tournament->id, $teams, $full_name, $filtered_matches);
        }
    }

And here code, which make save to database:

public function saveUpdate(int $tournament_id, array $tournament_teams, string $full_name, array $matches)
{
    $tournament = Tournament::updateOrCreate(['tournament_id' => $tournament_id, 'league_name' => $full_name]);
    foreach ($matches as $match) {
        if($match->status == 'not_started') {
            $status = 0;
        }
        if($match->status == 'running') {
            $status = 1;
        }
        if($match->status == 'finished') {
            $status = 2;
        } 
        $team = Tournament_teams::where('team_id', $match->winner_id)->first();
        Tournament_matches::updateOrCreate([
            'name' => $match->name, 
            'started_at' => Carbon::parse("$match->begin_at,")->setTimezone('Europe/Berlin'), 
            'ended_at' => $match->end_at, 
            'winner_id' => $team->id ?? null, 
            'status' => $status,
            'match_id' => $match->id,
            'live' => $match->live_url
        ]);
        
    }
    foreach ($tournament_teams as $team) {
        $exist_team = Tournament_teams::where('external_tournament_id', $tournament_id)->where('team_id', $team->id)->first();
        $is_exist_team = Tournament_teams::where('external_tournament_id', $tournament_id)->where('team_id', $team->id)->count();
        if ($is_exist_team == 0) {
            Tournament_teams::updateOrCreate([
                'tournaments_id' => $tournament->id, 
                'team' => $team->name, 
                'slug' => $team->slug, 
                'logo' => $team->image_url,
                'team_id' => $team->id,
                'match_id' => $team->match_id ?? null,
                'external_tournament_id' => $tournament_id,
            ]);
        } else {
            $exist_team->match_id = $team->match_id ?? null;
            $exist_team->save();
        }
    }
}

For 4 days now I can’t understand why the data in Tournaments are duplicated 3 times, and the data in the match_id field are not received in the Tournaments_teams. In the model, this field is indicated, because 50% of the teams have this data, the rest do not.

I hope for your help. If you need any clarifications - ask, I will answer questions. I will be glad if there is a mistake and will be fixed

May
25
5 months ago
Activity icon

Replied to Laravel UpdateOrcreate Missing Value

maybe someone can help?

May
24
5 months ago
Activity icon

Replied to Laravel UpdateOrcreate Missing Value

I make by your example, but a lot of data is lost at Tournament_teams i mean, i received only with match_id, where match_id null i don't received teams, but now 2 live matches, and i don't receive at my table 😢

Activity icon

Replied to Laravel UpdateOrcreate Missing Value

At Tournament and Tournament_matches i received all data, and it's work, problem at Tournament_teams, here i use 2 parameters, am I transferring them correctly?

Activity icon

Started a new Conversation Laravel UpdateOrcreate Missing Value

I do parsing matches for DotA 2. Through a third-party API, I get current, future and past matches. But the problem how i understand, it's updateOrCreate function does not work. When parsing starts, it saves the values, but does not update the current ones. Here is an example of the answer that I get https://pastebin.com/KCcG6rJc, in this answer there is what teams are playing now, there are match_id of teams, if the teams are competing with each other, this value is the same. Using the example of this parsing result, I received the following record in the Database:

The maches table, the match_id value got there - 560004, that's right. But in the teams table, where these commands are indicated, match_id is null.

At my parser i has this code:

foreach ($live_matches as $live) {
   
    if ($live->tournament_id != $tournament->id) {
        continue;
    }
   
    $filtered_matches[] = $live;
   
    foreach ($teams as &$team) {
        if (false !== strpos($live->slug, $team->slug)) {
            $team->match_id = $live->id;
            $logo = $team->image_url;
            var_dump($team);
            exit;
        }
    }
}

var_dump($team); exit; say me:

object(stdClass)#1222 (8) {
  ["acronym"]=>
  string(8) "ThunderP"
  ["id"]=>
  int(2671)
  ["image_url"]=>
  string(93) "https://cdn.pandascore.co/images/team/image/2671/87033C79D6D1A70A66941BC8649EA5988D74582C.png"
  ["location"]=>
  string(2) "PE"
  ["modified_at"]=>
  string(20) "2020-04-30T01:51:51Z"
  ["name"]=>
  string(16) "Thunder Predator"
  ["slug"]=>
  string(16) "thunder-predator"
  ["match_id"]=>
  int(560004)
}

i.e. I get match_id, but at database it's not add.

And here is my full function, which update or create:

public function saveUpdate(int $tournament_id, array $tournament_teams, string $full_name, array $matches)
{
    $tournament = Tournament::updateOrCreate([
        'tournament_id' => $tournament_id,
        'league_name'   => $full_name
    ]);

    foreach ($matches as $match) {
        if ($match->status == 'not_started') {
            $status = 0;
        }
        if ($match->status == 'running') {
            $status = 1;
        }
        if ($match->status == 'finished') {
            $status = 2;
        }
        $team = Tournament_teams::where('team_id', $match->winner_id)->first();

        Tournament_matches::updateOrCreate([
            'name'       => $match->name,
            'started_at' => Carbon::parse("$match->begin_at,")->setTimezone('Europe/Berlin'),
            'ended_at'   => $match->end_at,
            'winner_id'  => $team->id ?? null,
            'status'     => $status,
            'match_id'   => $match->id,
            'live'       => $match->live_url,
        ]);
    }

    foreach ($tournament_teams as $team) {
        Tournament_teams::updateOrCreate([
            'tournaments_id' => $tournament->id,
            'team'           => $team->name,
            'slug'           => $team->slug,
            'logo'           => $team->image_url,
            'team_id'        => $team->id,
        ], [
            'match_id'       => $team->match_id ?? null,
        ]);
    }
}

For example, if I delete 1 column value from the teams table and start parsing, then the value in this column will not be created. That is, it creates data, but does not update.

And now teams with match_id 560334 are playing and the tournament_teams table doesn’t have such match_id, I searched for playing teams by name and found that there are 1 of the playing teams in the database 3 times in a row. That is, one record has match_id = null, the others of the same match_id commands have old ones. For some reason, the data on the current is not updated and empty values are received in the database, although 50% of the values are. Here is screenshot with highlighted commands for which for example data is not updated: Screenshot

Where could my mistake be? Why does var_dump pass me match_id, but this value does not get into the database? Where could my mistake be? I use Laravel 5.1. If you need to clarify any details - ask, thank you for your help.

May
18
5 months ago
Activity icon

Started a new Conversation Laravel Translate

In my blade file, as the declension of words, I use the following construction:

echo Lang::choice('apple|apples|', $count, [], 'ru');

Now I need to do a translation in my Controller, I'm trying to do this:

$realTime = Carbon::now();
$diff = $realTime->diffInDays($item->created_at);
$date = 7 - $diff;
'message' => 'To left: '.$date.' '.<?php echo Lang::choice('day|days|', $date, [], 'ru'); ?>.'',

But it's not work, how I can use this translation method in the controller correctly?

I use Laravel 5.1

May
07
5 months ago
Activity icon

Started a new Conversation Laravel Dropped Some Values When Parsing

///del

May
03
5 months ago
Activity icon

Started a new Conversation Laravel UpdateOrCreate Don't Update Value

///del