ModestasV

ModestasV

Member Since 4 Years Ago

Experience Points 19,645
Experience Level 4

355 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 76
Lessons
Completed
Best Reply Awards 17
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

21 Mar
5 months ago

ModestasV left a reply on How Can I Write This With Eloquant

@GRENADECX - Or it would look like this if you use eloquent fully:

$members = Members::with('courses', function ($q) {
            $q>where('courses.user_id', auth()->user()->id);
        })
    ->where('email', Input::get('search_keyword'))
    ->orWhere('name', Input::get('search_keyword'))
    ->get();

Don't forget - you can filter relationships too, no need for join

06 Dec
9 months ago

ModestasV left a reply on Can't Target A Single Post Using Laravel Notification

You need to have a construct parameter of your post, then assign it to the class and only then you might call it how you want.

Also, your code snippet is not very informant as you are missing the full notifcation class and a call example.

ModestasV left a reply on Laravel Send Sms Using Twilio

Yes. What is your specific question?

16 May
1 year ago

ModestasV left a reply on Steps To Follow To Upgrade 5.6 From 5.0

@komalbhatt All of them, every single link he gave - you must implement. One by one in the right order :)

This is a very long and hard process in which you will fail multiple times due to missed/overlooked stuff. (unless your app is 100% covered with tests)

26 Mar
1 year ago

ModestasV left a reply on [Macbook] Is The Macbook Pro 13" Good For Web Development

@Vineky Using exactly the same computer I've got. (except my layout is english).

In any case I had no issues with it at all. I'm running it with 2x 4k monitors over display port and it still runs smooth and fast. The only issue is that due to my specific workflow - the 16GB of ram gets eaten really fast. If this won't be an issue for you - it's the best choice. We have 3 of them in our office (of 4 people) and everyone is really happy with it :)

I've been on the 13" model (my fiance uses it) and it is not that comfortable to be used alone... I've always needed a monitor with it where with the 15" I don't need it at all (only reason i have them is just because I work on some front end stuff sometimes and it makes life easier)

01 Mar
1 year ago

ModestasV left a reply on Models Views Controllers

Short answer - No.

Longer answer:

Model is responsible for data gathering and returning of the data. View is responsible for displaying received data. Controller is responsible for the logic of: Asking model for the data and passing it to the displayed view.

20 Feb
1 year ago

ModestasV left a reply on Object Of Class StdClass Could Not Be Converted To String

To start with - you are trying to echo a Collection() class. The query builder returns collection/array (depending on version you use) and you can't use echo there. To test if the data is correct you can use one of these two: dd($attr); or dump($attr); - they will print out what was returned.

19 Feb
1 year ago

ModestasV left a reply on Issue Related With Pivot Tables

@rin4ik I'm sorry but I don't believe this. You are a member of this community for 9 months, you have answered few questions so no, this does not work.

In any case, whatever your excuse could be - this is a free community and in free community you don't tag people. NEVER. No matter what urgent bug you have or whatever else you have, you just don't tag people who are helping on their own will. This I'd say is a common sense, no? :)

ModestasV left a reply on Issue Related With Pivot Tables

@rin4ik I'd suggest you remove that bad habbit of spamming users. Every single user in this system is a volunteer. This means that hey don't have to answer your question by any means. If they have time - they will, if they don't - they won't. That's as simple as that.

In any way, I would say that users who callout others like this should get some kind of a warning/penalty for doing so....

07 Feb
1 year ago

ModestasV left a reply on Trying To Get Property 'name' Of Non-object

@Snapey Oh my, what a silly mistake... I've read the code wrong... My bad :)

Then it should be this: data_get($rooms, 'roomcat.name', '---')

And to be fair, that is up to the developer and it's used php version :) Both solutions are great

ModestasV left a reply on Trying To Get Property 'name' Of Non-object

Or even better for this kind of scenario use:

data_get($rooms, 'room_cats_id.name') - which will do all of the checks automatically.

06 Feb
1 year ago

ModestasV left a reply on How Can I Scan QR Code Instead Of Importing An Image

Well, this was just an option and yes, this will need to be tested on multiple devices/settings. Personally, I had some luck with this one but it still did not fit my needs so we went for another option and created an android app wrapper to do this function :)

05 Feb
1 year ago

ModestasV left a reply on CRUDBooster

Because your database configs are incorrect, please set them in .env file

ModestasV left a reply on How Can I Scan QR Code Instead Of Importing An Image

https://github.com/schmich/instascan - Or to be fair, any other that is on google if searching for javascript scan qr code - tested few of them, works just fine but sometimes requires tweaking.

ModestasV left a reply on DevTools In Vue.js

Looks like it's one of two cases:

You have a production version of styles - please run npm run dev or it's sibling to get DEV version.

You have specifically told the tool that you don't want to debug. For this case, visit bootstrap.js and check the config there.

Hope this helps you :)

ps. With any of those changes, you have to re-load the browser and then re-open the inspect tool.

01 Feb
1 year ago

ModestasV left a reply on Is There A Method Like ToSql() To See The Raw Sql Query With The Parameters Mapped Automatically.

For that I personally use the best tool there is: https://github.com/barryvdh/laravel-debugbar - This gives me everything I need for such cases and even more :)

31 Jan
1 year ago

ModestasV left a reply on Create New Record With 1)Create And Fillable/guarded Or 2) New Model Instance And Save()

Create is a mass assignment where you don't specify the data and you trust it from the array you got. For example data form request input. This classifies as unsafe data.

If you are using New and Save - you are MANUALLY assigning each of the properties for the model therefore the system assumes that you double-checked what you are entering and you trust the data.

And personally - I use Create with fillables. Gives a lot of control and safety.

22 Jan
1 year ago

ModestasV left a reply on I Don't Understand The Utility Of Vue-router In A Laravel App

True, that is it's description but in my mind - it's a bit confusing :) Oh well, whatever works I guess

ModestasV left a reply on Set Financial Year Laravel

I would start by hard-coding months that counts as a start month, then months that count as end month. Example:

$start = "10-01"; $end = "09-30"

Then, would add a helper function that would return start/end dates for year in such way:

Request $year = 2018

$from = Carbon::createFromFormat("Y-m-d", $year-1."-".$start); $to = Carbon::createFromFormat("Y-m-d", $year."-".$end);

This should give you end and start timestamps so you could select it with "whereBetween()"

Hope this will get you on the path :)

ps. I would suggest you looking into collections and it's method: "groupBy()" which could do the grouping by month - automatically for you.

ModestasV left a reply on I Don't Understand The Utility Of Vue-router In A Laravel App

@topvillas Maybe we understand what single page is differently :) As fas as it is concerned for me - single page app is an app that literally has only one page and nothing else. You can't have a different route or anything, just points in page such as contacts, map, etc.. If it requires you to change url more than adding a tab - i'd say it's not a single page app anymore :)

ModestasV left a reply on Login With Postman

Well, the error clearly says that the method you are using to access that url is not allowed. Please check the routes and your postman settings to see if method matches.

ModestasV left a reply on Laravel & Vue Data Sharing Structure

Let's put this in a 5 year old way:

1st way is good if you intend to use the data immediately. For example: your mom gives you broom and tells you to clean your room.

2nd way is good if you want to know the job first but only then get the tools. For example: your mom tells you to clean your room and only when you are in the room - she hands you over the broom.

Key difference is that if you have data passed from Laravel to VueJS - it will be an instant display of action without any delays BUT will make you carry the data into the HTML all the time. Just like you would carry a broom to your room when it was handed before you come in. Doing it from VueJS side will introduce a delay which can be good or bad. For example: if you request a broom from your mom but after entering the room you realise that you need a moppet - you can change the data (with delay of course). But if you don't need a moppet - you will still receive the broom and continue to work.

Working with 2nd case is my #1 choice due to flexibility. You don't have to pre-load the data in Laravel and then send it (which is great for static data that does not change) but as soon as you need list with pagination - it will only fork for first page as others will need to be requested from server. (as always, exceptions apply but then if you load 1000 posts - it will make your HTML page ultra-heavy and your users might need to download TENS or HUNDREDS of megabytes to see the page.

To sum up: 1st way - mostly for static data that does not change and you can get it but you will carry load even if the data will be mutated. 2nd way - gives you flexibility of what to get. You can always request for more/less depending on needs and will only be carried if needed.

Please forgive me for using moppet instead of a mop. My mistake.

ModestasV left a reply on I Don't Understand The Utility Of Vue-router In A Laravel App

@topvillas Why only single page apps? We have projects that are multi-page, deep logic and still uses vue-router as a routing engine.

@brian85 Imagine vue-router the same as laravel router system. They are meant for your pages to work, for example: authors list and adding new author. If you want to transition between these two pages - you use vue-router and it will work just as normal laravel routing would. The only difference is how you pass/get data. (even copy/pasting the url to another browser/tab will work as expected and open the correct page).

In our case we have used vue-router in site with about 30 different pages and had no issues with the routing itself.

26 Dec
1 year ago

ModestasV left a reply on Tag Create If Not Exists - Inside The Tag Model

Why not this:

 Tag::firstOrCreate([
    'slug' => str_slug($tag)
], [
    'name' => $tag
]);

The first array is to check for data (where), the second array is to fill missing elements from the where.

20 Dec
1 year ago

ModestasV left a reply on Why Do People Like Whoops?

However Whoops can disable the env file from printing everything by default. It should be disabled. People should open their ENV.

I disagree. Why on earth while developing an app I should open something else to see debugging information?

To talk about stupidity and debugging, well, you should never run "composer install" in production. You should always run "composer install --no-dev" but... People tend to do otherwise and even forge configures the composer install in incorrect way. So when going live - you have to double check. This is the life lesson that has to be learned the hard way for a junior.

Anyway, it seems like you have your opinion, I have mine. We won't ever agree on this as I think that on debugging process - the more I see without opening stuff up - the better. Your opinion is the opposite and you like to open new tabs/editors which for me wastes valuable time :)

ModestasV left a reply on Why Do People Like Whoops?

@warmwhisky Well, wanna hear a bit of a joke? People should never show their .env file, they should change permissions but! Please do a google search for .env file and you will see TONS OF WEBSITES that leak their .env file :)

The tool can't prevent people from being stupid. That's a fact.

19 Dec
1 year ago

ModestasV left a reply on Why Do People Like Whoops?

@warmwhisky Let me stop you right there and talk about serious things. Ok?

Laravel caches blade files as they are compiled. Of course you will not the the original file lines as they are COMPILED FOR SPEED and used in a compiled matter not the original. If it wouldn't be the case - your system would suffer. Your development time would take ages. Think about it.

On the other hand, I have never had an issue where it was hard to find file number, file names and etc. Seriously, you are developing the system, you know what is where. Even if you don't - you get a cached file name and it's line location. Go into that file and it's line - copy the text and do a global search for that line. It will show up. If it doesn't - check your permissions for indexing files and search options.

Just to mention: Working with blade files was pain in the ass for as long as it was used. Reasons were stated above and you won't change that.

FYI: Whoops shows everything really nicely if you are using php files as they can be back-traced normally and will not lead to cached version.

As for your rant about .env files in the whoops, let's draw a picture that happens way too often:

It points you directly to your .ENV files as for juniors / new project users it is the most common mistake that they have. For example - typo in database name and so on. This FORCES you to check if the error is not coming from .env file.

Now, to stop your rant and give a reason - you should never ever use Whoops or Dusk or whatever else you got there for debugging in production. Like seriously, you don't use xDebug in production, right? It would be stupid. On local - it's a different story. There are TOOLS for you to work with.

To sum up, sorry but your arguments were invalid as everything you said - fits in DEV env and should be there. If you use other env and get these details - well check your configuration. It is right in front of you :)

17 Dec
1 year ago

ModestasV left a reply on Is It Hurt To Give Every Page A Controller?

Every page? No, that's way too much.

Every resource? - yes, that's how it should be done in theory.

I'd suggest going thru: https://www.toptal.com/laravel/restful-laravel-api-tutorial - it nicely shows that Articles must have it's own controller but if you were to add ArticleComents - that's another controller to have. All of it's actions (list, create, store, edit, update, delete) - has to be in one place and not in multiple files

04 Oct
1 year ago

ModestasV left a reply on Relationships Vs Relationships() In Eloquent

I have always adressed this issue in this manner and so far - it worked great:

$model->relation - this is the 90% of the cases where I just simply need to get the relationship of the model. For example to get user posts, I would do this and it would work. (keep in mind, no filtering needed). DON'T FORGET TO EAGER LOAD WITH $model->load('relation')

$model->relation() - this is the last 10% where I need some kind of filtering. For example, only posts which has certain tags. Example: $model->relation()->where('tag', 'someTag')->get(). (due to the fact that this can become a query builder). Heads up, this method can be eager loaded too, visit laravel documentation on how to conditionally eager load

So all in all - both are working with an exception, that the second one even with eager loading (unless it's the conditional loading) - will produce a query for each record. So going thru users and printing their posts - will spam your database with queries :)

_ Sorry if something is not clear, was in a bit of a rush but i'll be able to discuss my answer a bit later if anyone has comments_

02 Oct
1 year ago

ModestasV left a reply on App Name Can Only Be Changed In The .env

Well, for starters - if you have .env file with APP_NAME=Laravel - it will take that value and use it. If you were to change it there (actually you should change all possible values in .env file) - then it would change in your site.

As for the newname - this is a default value if .env file does not contain variable APP_NAME. If you would delete it from .env - it would take the second value.

Feel free to check: https://laravel.com/docs/5.5/helpers#method-env

ModestasV left a reply on Please Help Crypt!!

@DeveloperOnCall as far as I remember - crypt() uses php internal settings, not the .env key but I could be wrong with this.

In any case, it's almost impossible to de-code it unless you brute-force the attack and give all of the possible strings... Of course, if you know the length of the original key - it could be easier but... wouldn't put many bets on it

ModestasV left a reply on Please Help Crypt!!

Well, if you would read the documentation on the crypt() (http://php.net/manual/en/function.crypt.php) you would see a statement: crypt — One-way string hashing which means that it can't be recovered. Once it is hashed - it's hashed forever.

ModestasV left a reply on Dd() Doesn't Have Line-breaks When Previewing In Chrome 61

Sometimes I have the same problem. Diagnosed it and found out that there is one of the following:

  1. You have way too much data and renderer crashes.
  2. You have dump() and dd() in the same tab
  3. There is data in the dump() or dd() that breaks the dump script pretifier
13 Sep
2 years ago

ModestasV left a reply on Sweet Alert Is Deleting Only The First Row

Once again, please read my post.

You have REPEATING element which has the same ID. This is against the code of good practices and the browser only sees the first one. I even provided you with a solution on how to do it.

ModestasV left a reply on Sweet Alert Is Deleting Only The First Row

Erm, didn't you knew that there can only be a ONE AND UNIQUE ID of html element on the page? Your script takes the first one. ALWAYS.

Pass element to your warnBeforeRedirect not just the linkUrl as you need to submit the correct form.

12 Sep
2 years ago

ModestasV left a reply on Asset() Behaving Strangely

Do you have a symlink created on your server?

08 Sep
2 years ago

ModestasV left a reply on Return Boolean From Collection?

Why don't you use collections filter method to only filter the appointments that matches your condition?

06 Sep
2 years ago

ModestasV left a reply on Auth::user() Return Null In Construct.

@vtxmg can you paste the code with my addition? As it should look like this:

class BaseController extends Controller
{
    public $user_info;
    public function __construct(){
    $this->middleware(function ($request, $next) {
            $this->user_info=Auth::user(); // returns user
        return $next($request);
        });
    }
}

ModestasV left a reply on Auth::user() Return Null In Construct.

Ech... There was quite a lot of discussions, you need to have your code like this:

 $this->middleware(function ($request, $next) {
            // Your auth here
            return $next($request);
        });

As from 5.3 laravel session is loaded after the contruct methods are called.

05 Sep
2 years ago

ModestasV left a reply on Laravel 5.5 Does Not Create .env File Anymore?

Are you sure, you can view hidden files? Most of the times the case is that user can't see any .* files at all.

By the way, created few projects with L5.5 and always got the .env file :)

04 Sep
2 years ago

ModestasV left a reply on How To Read Barcode Data From Barcode Scanner

@Kaustubh Most of the barcode/qr readers that you can get online reads the data into a field. For example, if you autofocus BARCODE field, it will automatically fill it after scanning. I've had multiple readers and all of them were just sending data like normal "keyboard" and it was your duty to put it in correct place. In my case - autofocused field.

29 Aug
2 years ago

ModestasV left a reply on Laravel Notifications Own Post Mark As Read Issue

When creating a notification, use https://laravel.com/docs/5.4/eloquent#observers - Created to be specific and save an entry to database that the current user saw the notifiation

28 Aug
2 years ago

ModestasV left a reply on How I Can Get Cookie Content In Laravel

Well, i'd suggest you reading more on cookies and how they work :)

ModestasV left a reply on How I Can Get Cookie Content In Laravel

@ali2535 well then, just save the cookie forever or at least a month from today. That is it, they will have their basket unless they clear out the cookies :)

ModestasV left a reply on Trying To Get Property Of Non-object (1/1) ErrorException

Well,

You are logging out the user first with Auth::logout(); and then getting his id: ->where('id', '=', \Auth::guard('admin')->user()->id) - This obviously won't work as user is already logged out.

Save the user state before the Auth::logout() and use it afterwards or better yet, move the Auth::logout() before the redirect line, to look like this:

Route::get('/logout',function(){
     \DB::table('admins')
    ->where('login_status','yes')
    ->where('id', '=', \Auth::guard('admin')->user()->id)
    ->update(['login_status' => 'no']);

    Auth::logout();
    Session::flush();

    return Redirect::to('/');
      
});

ModestasV left a reply on How I Can Get Cookie Content In Laravel

Could you give us more details?

As of what I can understand you are thinking about cookies wrong. The cookies can be changed no matter what. Maybe you should check in at the sessions?

27 Aug
2 years ago

ModestasV left a reply on Route Resource Conundrum

@topvillas No. You got something confused there :)

'prefix' => 'api' !== 'as' => 'api.'

The prefix is for browser URL.

The as is for the names of the routes.

Example:

protected function mapApiRoutes()
    {
        Route::group([
            'namespace' => $this->namespace,
            'prefix'    => 'api', // This will add prefix to the route URL
        ], function ($router) {
            require base_path('routes/api.php');
        });

        Route::group([
            'namespace' => $this->namespace,
            'prefix'    => 'api', // This will add prefix to the route URL
            'as'        => 'api.', // This will add prefix to the route names. Ex.: api.users.create
        ], function ($router) {
            require base_path('routes/api.php');
        });
    }

ModestasV left a reply on My Middleware Won't Work

Have you registered your middleware in: \App\Http\Kernel?

ModestasV left a reply on Route Resource Conundrum

Hey,

Well, first of all - you should prefix your api routes with a api. to separate them. The reason for this is to avoid the confusion and issues with naming/acessing wrong routes.

To do that, look at example:

Route::group(['prefix'=>'accounts','as'=>'account.'], function(){
    Route::get('/', ['as' => 'index', 'uses' => '[email protected]']);
    Route::get('connect', ['as' => 'connect', 'uses' = > '[email protected]']);
});

Where account. will be the prefix for next route names.