lorvent

lorvent

Hire Me

Member Since 4 Years Ago

Experience Points 14,235
Experience
Level
Lessons Completed 126
Lessons
Completed
Best Reply Awards 5
Best Answer
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.

11 Jan
10 months ago

lorvent left a reply on Simple Authntication

I used the above code and executed i am getting the error.

  1. Tests\Unit\LoginTest::testCorrectValues Expected status code 200 but received 302. Failed asserting that false is true.
10 Jan
10 months ago

lorvent started a new conversation Simple Authntication

I am Executing The unit test case for login page. I am getting The following Error. Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'http://localhost/index' +'http://localhost'

This is my Code public function testCorrectValues(){ $response = $this->post('/login',['email'=>'[email protected]','password'=>'123456','_token' => csrf_token()]); $response->assertRedirect('/index'); $response->assertStatus(200); $response->assertSeeText('Dashboard'); } I dont know What I Done mistake. Please Help me.

30 Aug
1 year ago

lorvent left a reply on Laravel 5.5 Syntax Error, Unexpected '?' In ..\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php On Line 233

if php7 is not running then it wont install at all as composer has that requirement.

30 Jul
1 year ago

lorvent left a reply on Session Data Into Repository __constrct Method

can anyone know solution for this?

22 Jun
1 year ago

lorvent left a reply on Is It Good To Use Sentinel For Authentication?

i use it in almost all of my laravel projects and its advanced than laravel auth (not sure about latest version)...i am using it from laravel 4.2 days

lorvent left a reply on Deploying A Laravel Project.

also did you chmod storage folder?

lorvent started a new conversation Repo Pattern Really Worths?

We worked on a big project with 50+ repos, controllers etc.

Looking at the code, i am wondering...does repo pattern really worths the extra work?

PS: i want to hear from people who used it extensively.

-- my only positvbe point for it is....when creating controllers for web and api....instead of duplicating code, you can fetch from repo pattern.

lorvent started a new conversation Session Data Into Repository __constrct Method

As of laravel 5.3....session data will not be passed to constructor as per https://laravel-news.com/controller-construct-session-changes-in-laravel-5-3

there is a workaround to this for controller.

But, how can i get a work around for it in Reposiroty?

my original problem: I am using sentinel so want to get current logged in user info inside construct method so that it can be used everywhere in RepositoryEloquent file.

is there any elegant way to get that done in laravel 5.4?

thanks

21 Jun
1 year ago
10 May
1 year ago

lorvent left a reply on Select Data With Escaped Output

Thanks for the reply @bunnypro can you please give some hint on it?

lorvent started a new conversation Select Data With Escaped Output

Hello, i have query like this

$data = Model::all();

the problem is, one row has code like <script>alert('boom')</script>

so instead of executing javascript code, i want to escape the data.

is there any such option available with eloquent?

Note: this data is being sent through ajax so i can't use blade escape feature.

09 Apr
1 year ago

lorvent left a reply on Bootstrap 4 Vs Bulma Vs Foundation With Laravel & Vue Js

i personally prefer bulma, eventhough we built more than 100 websites using bs3

another plug thing is, there is something called vue-bulma

23 Mar
1 year ago

lorvent left a reply on Can I Keep Using Elixir/Gulp After Migrating To Laravel 5.4?

yes, in package.json add elixir

npm install laravel-elixir --save

and remove mix from package.json

then remove webpack.mix.js and add your old gulpfile.js

02 Feb
1 year ago

lorvent started a new conversation Problem Installing Laravel 5.1

Hello,

installing laravel 5.1 throwing composer error with illuminate/support being not compatible.

anyone else facing same issue and found any fix?

26 Jan
1 year ago

lorvent left a reply on Laravel 5.4 Dev Npm Run Dev Error

removing node_modules and installing again with new package.json works for me too.

25 Jan
1 year ago

lorvent left a reply on Laravel 5.4 Dev Npm Run Dev Error

@JeffreyWay it has default code

const { mix } = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');

lorvent left a reply on Laravel 5.4 Dev Npm Run Dev Error

after following those 2 steps, now my npm run dev running

but throwing another error

> cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
                                                                           73% optimizeD:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\index.js:246
                                var shouldExtract = !!(options.allChunks || chunk.isInitial());
                                                                                  ^

TypeError: chunk.isInitial is not a function
    at D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\index.js:246:55
    at D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3025:16
    at eachOfArrayLike (D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:941:9)
    at eachOf (D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:991:5)
    at Object.eachLimit (D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3089:3)
    at ExtractTextPlugin.<anonymous> (D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\index.js:244:10)
    at Compilation.applyPluginsAsync (D:\xampp\htdocs\josh_laravel54\node_modules\tapable\lib\Tapable.js:71:13)
    at Compilation.seal (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:525:7)
    at Compiler.<anonymous> (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compiler.js:397:15)
    at D:\xampp\htdocs\josh_laravel54\node_modules\tapable\lib\Tapable.js:103:11
    at Compilation.<anonymous> (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:445:10)
    at D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:417:12
    at D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:332:10
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:52:16
    at done (D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:246:17)
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:44:16
    at errorAndCallback (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:202:5)
    at errorOrWarningAndCallback (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:225:13)
    at D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:229:12
    at onDoneResolving (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\NormalModuleFactory.js:29:20)
    at D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\NormalModuleFactory.js:85:20
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:726:13
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:52:16
    at done (D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:241:17)
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:44:16
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:723:17
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:167:37
    at D:\xampp\htdocs\josh_laravel54\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:24:19
    at onResolved (D:\xampp\htdocs\josh_laravel54\node_modules\enhanced-resolve\lib\Resolver.js:38:18)
    at D:\xampp\htdocs\josh_laravel54\node_modules\enhanced-resolve\lib\Resolver.js:127:10

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Seenu\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v6.9.4
npm ERR! npm  v4.1.1
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script 'cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\xampp\htdocs\josh_laravel54\npm-debug.log

looks like mix is immature yet,

anyone recommend using gulp/elixir or stick to mix and wait till bugs fixed?

thanks

10 Sep
2 years ago

lorvent left a reply on 5.3 Image Validation Only If Image Is Uploaded

that makes image required, i want image to be optional and if its uploaded then it should have only allowed extensions.

09 Sep
2 years ago

lorvent started a new conversation 5.3 Image Validation Only If Image Is Uploaded

In 5.3, How can i validate an image only if its uploaded.

a rule like 'pic_file' => 'mimes:jpg,jpeg,bmp,png|max:10000', would validate pic_file only if its uploaded in 5.2

but in 5.3, i am getting error as image extension is wrong eventhough i didn't upload image.

how can i make validation optional? or how i can add a rule dynamically in Requests (not in controller)

Thanks.

27 Aug
2 years ago

lorvent left a reply on [?bug] Nested Relationships Error

yes but thats a big burden on server as my db size may grow fast.

26 Aug
2 years ago

lorvent started a new conversation [?bug] Nested Relationships Error

I Have Item model ItemCompetitor model with Item hasMany 'ItemCompetitorSales` model with ItemCompetitor hasMany

now, when showing single item i want to get last 2 rows of ItemCompetitorSales for each ItemCompetitor

so my ItemCompetitor looks like this

public function sales()
    {
        return  $this->hasMany(ItemCompetitorSaleCount::class,'item_competitor_id','competitor_id')
            ->orderBy('created_at','desc')
            ->take(2);
    }

So lets say for item = 1, there are 10 competetirors, each competitor has 5 competitor sales so i want to get 10 x 2 = 20 rows from ItemCompetitorSale model

but i am getting only 2

if i change take(2) to take(20) it returns 20 rows but again 5 rows from each for first 4 competitors which is not what i want.

Is this a possible bug with laravel or am i doing wrong?

05 Aug
2 years ago

lorvent left a reply on When Would You Update The Laravel Framework In A Project?

I have upgraded projects from l4 to l5 because its a major change and some clients still running l4 happily.

usually i get tempted and move personal project to latest version but honestly i don't see any benefit.

if i want to utilize a new feature, again its extra work (assuming your old code is working properly already)

so currently my strategy is sticking to LTS (everywhere not just with laravel but also with system OS) if a new LTS version comes and your app still used by people then go for it.

if its a client project, upgrade as many times as client wants :D

lorvent left a reply on Odd Domain Redirecting To My Site.

it happened to me just today,

i had a vps with DO long before and i have a sub-domain pointing to it after client work is over, i destroyed my droplet

today, i am collecting my portfolio and when i typed that domain ( i forgot i destroyed droplet) its showing someone else site, i was surprised a bit first then realized what is going on.

mine is opposite story of what you are experiencing.... so mostly it may be their mistake (unknowingly).

lorvent left a reply on Laravel 5.3 Failing On Gulp Watch

laravel-elixir v6 is still buggy as @JeffreyWay making breaking changes.

whenever i try v6 (because of beautiful terminal output) i encounter problems and usually goes back to v4

29 Jul
2 years ago

lorvent started a new conversation Testing: Get Contents Of A File

Hi, I want to automate testing for following task.

I want to open say routes.php and check for contents, see xyz and don't see abc

can anyone tell me how to do that?

thanks.

27 Jul
2 years ago

lorvent left a reply on Laravel CI Testing With GitLab

currently i am using something like envoyer for live deployments on each commit, can we do same with gitlab ci?

lorvent left a reply on A Few Laracasts Things I Would Like Clearing Up

for #1, checkout https://github.com/REBELinBLUE/deployer same as forge/envoyer but open source

lorvent left a reply on Laravel Task Scheduling From Database

Thanks, i will try this and update the post.

26 Jul
2 years ago

lorvent left a reply on Laravel Task Scheduling From Database

if i have 100 subscribers and each subscriber sets their own time, i can't make use of javascript

lorvent started a new conversation Laravel Task Scheduling From Database

Hi, I am building a service where people can register to fetch API at regular intervals like 5mins, 15mins etc

and since every person uses a different schedule, i can't manually write all scheduling into kernel.php

is there any way to utilize database for task scheduling?

any help is appreciated.

18 Jul
2 years ago

lorvent left a reply on Get Distinct Dates Data

I am also thinking, is it better to store created_at (or other field) in just Y-m-d format so that i can get unique values easily?

lorvent left a reply on Best Place To Store API Methods

I am making a connect to an API, there are 50+ methods.

i make around 10 methods from each controller.

currently, i wrote a wrapper method to make calls and put it in my base controller, so i am making calls with $this->method()

lorvent left a reply on Get Distinct Dates Data

@willvincent @jimmck can you help me write eloquent code for that max? instead of raw queries

my current code looks like this

$arr = [];

        $competitor = Competitor::findOrFail($id);
        $competitorData = CompetitorSaleCount::where('competitor_id',$competitor->id)
            ->get();
        foreach ($competitorData as $competitorDataObject) {
            $newArray = [];
            $newArray[] = $competitorDataObject->created_at->format('Y-m-d');
            $newArray[] = $competitorDataObject->sales;


            array_push($arr, $newArray);
        }
//        return collect($arr)->unique()->values();
//        return array_unique($arr,SORT_REGULAR);
        JavaScript::put([
            'foo' => 'bar',
            'user' => 'seenu',
            'age' => 29,
            'data' => collect($arr)->unique()
        ]);
        return view('admin.competitors.show', compact('competitor','competitorData'));

16 Jul
2 years ago

lorvent left a reply on Get Distinct Dates Data

@willvincent exactly, when searching for a user records,

  • i want to get only one record per day (as per created_at column)
  • which is most recent

so on a day, if we have 3 rows, i want to pick only one.

Currently, i found a workaround for it

  1. get all data from database
  2. store it into new array while formatting created_at to Y-m-d format
  3. applying array_unique($final_array,SORT_REGULAR)

so that i am getting only one row per day.

but this is not efficient because i am getting all rows from database...

lorvent left a reply on Best Place To Store API Methods

@d3xt3r Currently i am doing that approach only but want to know, is there any better option.

lorvent left a reply on Get Distinct Dates Data

i mean, how?

what is the syntax?

lorvent started a new conversation Get Distinct Dates Data

I have a table where lets say i have following data

| id | user_id | value | created_at | updated_at | |---|---|---|---|---| |1 | 1 | 1329 | 2016-07-16 21:37:54 | 2016-07-16 21:37:54 | |2 | 2 | 860 | 2016-07-16 21:37:55 | 2016-07-16 21:37:55 | |3 | 1 | 1329 | 2016-07-16 21:38:53 | 2016-07-16 21:38:53 | |4 | 2 | 860 | 2016-07-16 21:38:53 | 2016-07-16 21:38:53 | |5 | 1 |1329 |2016-07-16 21:39:06 |2016-07-16 21:39:06| |6 | 2 |860|2016-07-16 21:39:06|2016-07-16 21:39:06|

Now, i want to get user_id 1's data but i want to get only one for each date but here for 2016-07-16 i have 3 rows, i want to select only one.

can i anyone guide me, how to get that?

thanks.

lorvent left a reply on Best Place To Store API Methods

Thanks Saeed, yes Traits looks like good location, but i am confused with too many options :( like traits, repositories

lorvent started a new conversation Best Place To Store API Methods

I want to make many API calls and it comes to around 50 methods, whom i am going to use in many Controllers,

so i am wondering what is the best place to store all those methods?

thanks.

09 Jul
2 years ago

lorvent started a new conversation Remove Timezone Difference Before Saving Into Db

Hello, I get datetime from API like 2015-04-11T23:20:39+10:00 where +10:00 is timezone

I want to store data in UTC only i.e. remove 10hours from API timezone.

so that i can show data properly to user.

Can anyone tell me how to do that?

Currently, i am doing something like below without any luck

$timezone = new \DateTimeZone('UTC');
            $status = ItemSale::firstOrNew([
                'item_id' => $item_id,
                'sold_at' => Carbon::createFromFormat('Y-m-d\TH:i:sP',$row->sold_at,$timezone),
            ]);

Thanks.

15 Jun
2 years ago

lorvent left a reply on Sublime Text 3 Syntax Highlight

preferences->color scheme->material theme and choose a theme

16 May
2 years ago

lorvent left a reply on Delete Cache On Save/update

Excellent explanation @nickwest thanks for taking your time to explain it so nice

@rsdev000 thanks for the links, actually i mean those event fires only....since they are fired automatically, i can clear cache.

ofcourse i already have a cache clear route, which i hit whenever i feel something wrong going on.

lorvent left a reply on Delete Cache On Save/update

Currently i am deleting cache in store and update methods but i guess there must be an elegant way using model listeners, events etc.

lorvent left a reply on Delete Cache On Save/update

Sorry, that doesn't answer my question.

i know Cache::flush(); but i want a way to delete cache only when a new row is inserted or existing row updated for certain tables/models.

lorvent left a reply on Column Name And Relationship Name Same

Hi, Thanks for the response.

I already have some other user columns so this one has to be a different, ofcourse i can append _id to make it something like edited_by_id() as relationship name.

$model->edited_by()->first_name is not working, its throwing some other error.

lorvent started a new conversation Column Name And Relationship Name Same

Hello,

Can i have column name and relationship name same?

ex:

I have a column edited_by in Abc.php model

and i want to get full details of user mentioned in edited_by from users table so i have relationship like below

public function edited_by(){
        return $this->hasOne('App\User','id','edited_by');
    }

now, if i try to access $model->edited_by->first_name its throwing error 'trying to get property of non-object'

is there any way to fix it other than having different names?