gouseferoz

gouseferoz

Member Since 1 Year Ago

Experience Points
2,860
Total
Experience

2,140 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
5
Lessons
Completed
Best Reply Awards
0
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.

Level 1
2,860 XP
Jan
16
1 month ago
Activity icon

Replied to Hashing And Storing Large Data In MySQL Database,

@xsecrets

Yes, i think i am looking for the encryption.

encrypt and decrypt doesn't save memory.

Can you suggest any other encryption mechanisms.

Regards

Activity icon

Started a new Conversation Hashing And Storing Large Data In MySQL Database,

Hi Guys,

I am trying to hash my data before saving it to the database mainly to: 1) Save the size of the data being saved - If you are going to save large lines of data 2) Security.

I looked up online and found http://www.unit-conversion.info/texttools/sha/#data which does the same.

I was able to hash the data but not sure how to unhash the hashed data.

Can you help me achieve my use case?

Regards, Feroz.

Activity icon

Replied to Calling An API From A Controller

Thank you @sti3bas and @bugsysha

I will check these.

Activity icon

Started a new Conversation Calling An API From A Controller

Hi All,

i am trying to communicate with an external api that supports GET and POST requests and these API responses will be used inside my controller to do some more operations like saving it in DB or any such.

How can i implement this from inside a controller?

Code i was looking for is similar to this:


//This is not an actual code implementation

$api_call = HTTP("https://externalAPI.com/resource?name=feroz");
return $api_call['response'];


Can anyone point me in the right direction?

Regards, Feroz.

Dec
08
2 months ago
Activity icon

Started a new Conversation Laravel With Judge0 API

I am working on a code compiler for my project and i came across Judge0 API which will do the work.

I have setup my docker in the server and the API is active over 3000 port.

The area where i am stuck is how to call this api from my laravel controller.

My use case is to have an UI which will take the input from the user and send that request to the controller, similar to this website https://ide.judge0.com/

Can anyone help me how to do this approach?

Regards, Feroz

Nov
08
3 months ago
Activity icon

Replied to With() And Where() In Eager Loading

@griehle it is not returning any data and the console is showing content.js:21 Uncaught TypeError: Cannot read property 'tagName' of undefined

Activity icon

Started a new Conversation With() And Where() In Eager Loading

Hi,

I am trying to add relations and is confused with the implementation.

I have two tables, users and exams and i added some relations between two like the below code:

//User.pjp
public function exams()
    {
        return $this->hasMany(Exams::class);
    }
//Exams.php
public function user()
    {
        return $this->belongsTo(User::class);
    }

and trying to implement eager loading using the below code:

$exams = Exams::with('user')->get();
        $users = User::all();
        foreach($exams as $exam)
        {
            echo $exam->user;
        }

My requirement is , i want to select a particular exam from the Exams table based on the id but dont know how to implement it.

I need something like

public function showData($id)
    {
        $exams = Exams::with('user')->where('exam_id',$id)->get();
        $users = User::all();
        foreach($exams as $exam)
        {
            echo $exam->user;
        }
}

Can anyone help me how to do this?

Regards,

Activity icon

Replied to Running 2000 Queries Without Big Load On Server.

@chris-lw Can you give me an example of it?

and wouldnt make the sql query again?

Activity icon

Started a new Conversation Running 2000 Queries Without Big Load On Server.

Hi Guys,

I have a use case where i need to run like 2000 sql queries.

I am using the below code:


public function getresults($id){

$sortmarks = StudentExamTable::select('user_id','exam_id','exam_name','status')->where('exam_id',$id)->groupBy('user_id')->get();

$users = UserTable::select('id','name','email')->get();

foreach($sortmarks as $marks)
{
    $highest = StudentExamTable::where('user_id',$marks['user_id'])->where('exam_id',$id)->orderBy('total','desc')->orderBy('id','desc')->where('status','completed')->first();
    $marks->attempt_id = $highest['id'];
    $marks->ques_count = $highest['ques_count'];
    $marks->attempted_ques = $highest['attempted_ques'];
    $marks->positive = $highest['positive'];
    $marks->negative = $highest['negative'];
    $marks->total = $highest['total'];
    $marks->max_marks = $highest['max_marks'];
    $marks->percentage = $highest['percentage'];
    $marks->qualified = $highest['qualified'];
    $marks->created_at = $highest['created_at'];
    $marks->updated_at = $highest['updated_at'];
    $count = StudentExamTable::where('exam_id',$id)->where('user_id',$marks['user_id'])->count();
    $marks->attempted_count = $count;
    foreach($users as $user)
    {
        if($user['id'] == $marks['user_id'])
        {
            $marks->name = $user['name'];
            $marks->email = $user['email'];
        }
    }
}

}

if the first query has 2000 records then the code is going to make 2000+ SQL queries, can anyone help me optimize this code to make it run less sql queries?

Thanks in advance.

Nov
01
3 months ago
Activity icon

Replied to AJAX POST Request Issues In Live Environment

I think i found the issue.

In my code, i was using first() and count() like

$blogs = Posts::where('unique',$request['unique'])->first();
return count($blogs);

Instead, if i do this, the error goes away

$blogs = Posts::where('unique',$request['unique'])->count();
return $blogs;

I am not 100% sure whether this is the exact cause of the issue but with this change i am not getting the HTTP 500 error.

Oct
31
3 months ago
Activity icon

Replied to AJAX POST Request Issues In Live Environment

@jlrdw

I see the data but i am unable to perform the database queries later that in my code.

public function submit(Request $request)
{
    $posts = Posts::where('unique',$request['unique'])->get();
    return count($posts);
}

This wont work.

Activity icon

Replied to AJAX POST Request Issues In Live Environment

@jlrdw I got this from the developer's tools:

jquery-2.2.4.min.js:4 POST https://instacks.in/exam/submit 500
send @ jquery-2.2.4.min.js:4
ajax @ jquery-2.2.4.min.js:4
(anonymous) @ 1572548832:1612
dispatch @ jquery-2.2.4.min.js:3
r.handle @ jquery-2.2.4.min.js:3
Activity icon

Replied to AJAX POST Request Issues In Live Environment

@wafto I dont see anything in the logs except POST Internal Server 500 error.

Activity icon

Started a new Conversation AJAX POST Request Issues In Live Environment

Hello Everyone,

I am trying to implement a AJAX post request in my webpage.

I implemented in my local and its is working just fine but when i uploading the same code to live environment, it is giving the 500 error during post request.

I am not sure what is the issue. Can anyone help me out here.

Jquery Ajax Request

$.ajax({
           type:'POST',
           url:'/blog/submit',
           data:{
               unique: "{{ $uniqueID }}"
           },
           success:function(data){
              console.log(data);
           }
    });

Controller:

public function submit(Request $request)
{
    return $request;
}

The output i see on my console is:

/blog/submit: null
unique: "1572546628"

In my local, i dont see /blog/submit: null but in Live i can see that message.

Any thoughts?

Regards, Feroz.

Sep
27
4 months ago
Activity icon

Replied to Random Method In Eloquent.

I need ids to do something later in the project :)

If the first query shows some errors i will use the later.

Thanks for the help @snapey

Activity icon

Replied to Random Method In Eloquent.

So should I use like

Pages::inRandomOrder()->get()->take(30)->pluck('id');
``
Activity icon

Replied to Random Method In Eloquent.

@snapey It is working without adding get()

Pages::inRandomOrder()->take(30)->pluck('id');
Activity icon

Replied to Random Method In Eloquent.

@snapey thanks for the workaround and inRandomOrder() looks better than `random()'

However to get only a certain number of random records I used

inRandomOrder()->take(30)

Is this the right way of doing that? or is there any better way?

Please clarify.

Sep
26
4 months ago
Activity icon

Started a new Conversation Random Method In Eloquent.

Hi Guys,

I am using a random method to fetch the rows in a random manner. But i feel that random is not picking till the end of the table.

    $getPages = Pages::where('author','feroz')->get()->random(10)->pluck('id');

Is that so?

If yes, can you please suggest me how I can go till the last row of the table.

Regards, Feroz.

Activity icon

Replied to The Page Isnt Working Error

Well, count() has significantly reduced the time to get the data from the database.

Now I am not getting the 502 bad gateway error.

Thanks @wilk_randall

Sep
25
4 months ago
Activity icon

Replied to The Page Isnt Working Error

@munazzil i checked my code, and here is what i observed,

I am making a database query which has over 50000 rows just to get count of rows like:

$count1 = count(MyTable::where('role','user')->get());
$count2 = count(MyTable::where('role','author')->get());

and i am doing this 4 times each having different query parameter.

When i remove this block of code, the page works without any issue.

When i tried to save the direct result into the variable like

$data = Mytable::get();

I am getting 502 Bad Gateway on this page.

I dont know how to optimize this.

Can you help me with it?

Activity icon

Replied to The Page Isnt Working Error

Hey Guys,

Even after the change of the memory_limit,

I can still see the error

Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in
Sep
18
5 months ago
Activity icon

Replied to The Page Isnt Working Error

Any reason why this amount of memory being consumed by PHP?

Activity icon

Replied to The Page Isnt Working Error

Thanks for responding.

I checked the nginx server log and i see a memory issue :

Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/laravel/vendor/symfony/debug/Exception/FatalErrorException.php on line 0" while reading response header from upstream

This error is repetitive while accessing that particular page.

Any solution for this error?

Regards, Feroz.

Activity icon

Started a new Conversation The Page Isnt Working Error

Hey Guys,

I am having a laravel project in production and after logging in I see the error something like this:

This Page isnt working.
Site is unable to handle this request
HTTP ERROR 500

I have the APP_DEBUG=true in my .env file and even it is not displaying any other error details.

But after refreshing the page twice, i can see the data/page is being loaded without any issue.

Can anyone help me in resolving this error?

Regards, Feroz.