Prido

Member Since 8 Months Ago

Experience Points
2,570
Total
Experience

2,430 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.

  • Community Pillar

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

Level 1
2,570 XP
May
17
3 weeks ago
Activity icon

Replied to Handle Multiple Events Of The Same Class

I have a betting system, i get results from an external API, results for games come at different times as games olay at different times, when results come i then get all tickets that are not closed and update the status based on results,

Activity icon

Started a new Conversation Handle Multiple Events Of The Same Class

I have an event that is fired wen some value is updated in my db. This event has a listener that gets a list of database rows on a table and performs some updates. So my fear is if the even fires the listener will start the process and if the second event fires before the first process finish, what will happen? I want these processes to wait for each other?

Wen an even is fired does it run on the same thread? Like the php sequence doenst go on until the event process is done?

May
13
4 weeks ago
Activity icon

Started a new Conversation Transactions And Events

I have a DB transaction.


DB::transaction(function() {
foreach($products as $product) {
$product = Product::find($product->id) ;
$product->price = 2;
$product->update();
} 
}) ;

I want that If any of the products is updated we fire an event once after the transaction finish

May
08
1 month ago
Activity icon

Replied to Laravel Schedular

Yes it works perfectly. Am so confused with this kind if behavior. Wen i run the command directly it works wen i run artisan schedule run the command is executed on the console and reaches the last part of the code but never does the critical work... If i do an insert be4 the try catch it inserts but if i put it just inside the try catch nothing happens. But the code in App\Core\Import is valid runs great manually

Activity icon

Started a new Conversation Laravel Schedular

I am trying to make a laravel task that runs every minute. I created a comand class GetDataEveryMinute


public function handle() {

$import = new App\Core\Import() ;
$import->getDataFromApi() ;
}

The import class


public function getDataFromApi() {

try{
\ logic to get data from the api and update db

} catch() {} 
}

The kernel class


public function schedule(Schedule $schedule) {

$schedule->command('everyminute') - >everyMinute() ;

} 

Now wen i call php artisan schedule:run, the command is executed correctly but never reach the try catch in the logic class. But when i do this to the kernel it works

public function schedule(Schedule $schedule) {
$schedule->call(function() {
$import = new App\Core\Import() ;
$import->getDataFromApi() ;
}) - >everyMinute() ;

}

This works perfect but i dnt know why the command approach is refusing

Apr
26
1 month ago
Activity icon

Started a new Conversation Consuming API Directly Or Saving Into Db First

I am creating a betting site that i have to poll for updated data even every 5 seconds interval. So now i want to think of the best way between fetching data from api then save in db then front-end gets data from my db. Or i get the data directly from api to front-end. Which can be the best way.

Apr
12
2 months ago
Activity icon

Started a new Conversation Api Model Resources

I have 3 models for example, they are related User, Post, Comment

UserResource


return [
'name' => $this->user_name, 
'posts' => PostResource::collection($this->whenLoaded('posts')) 
] ;

PostResource


return [
'title' => $this->title, 
'comments' => CommentsResource::collection($this->comments) 
] ;

CommentResource

return [
'comment' =>$this->comment 
// 'user' => UserResource::collection($this->post->user) 
] ;

Now the problem is sometimes i need to create CommentResource and also get user through post. I can fix the UserResource by including the whenLoaded on posts to avoid loop, but ts hard to handle on the comment when i call the UserResource::collection(User::all()) the UserResource in comment will loop.

Apr
10
2 months ago
Activity icon

Started a new Conversation Best Way To Send And Receive Data API

I am developing an API for my angular app. I display some general data on the homepage and also have a slider that displays boosted items. Now the question is, is it appropriate to send multiple API calls to load the homepage. One request gets general list of items. The other request grabs list of boosted items.

Mar
29
2 months ago
Activity icon

Started a new Conversation What Is The Best Way When Creating An Api

What is the best way when creating an api. Restructuring i.e


$model_datas = Model::all();
$data =[];
$item =[];
foreach($model_datas as $model_data){
$item['id'] = $model_data->id;
$item['title'] = $model_data->title;
$item['created'] = $model_data->created_at;
$data[] = $item;
}

return json_encode($data);

OR just return


return json_encode($model_datas);

Mar
24
2 months ago
Activity icon

Started a new Conversation Whats The Best Way To Store And Render Dynamic Css.

Whats the best way to store and render dynamic css. For example i let user select styling for a component, save in db then render wen serving the page. Any one who can help or has a tutorial link

Mar
11
3 months ago
Activity icon

Started a new Conversation Laravel Scheduling

I am creating a soccer betting site, i have to collect live match data from an external API and render to users as fast as possible because outcome odds change at any given time, now i need to make a schedule that collects data from API and update my database, this has to be done on regular periods as low as 3 to 6 seconds, my chalenge is the crone calls is limited to 1 minute so as the laravel schedule, hw can i do my task

Mar
10
3 months ago
Activity icon

Started a new Conversation Error While Fetching Data From API

I am fetching data from api recursively getting 100 items per request as the data is paginated by default from the API. I then save this data to the db again and again untill all records are finished. When the fetching reach page number 25 that means 2500 records it throw an error " could not resolve host name for "https://api.com"" Or sometimes " no data received from server" Am stuck here. Total records are like 40 000

Mar
07
3 months ago
Activity icon

Started a new Conversation Eloquent

// from category model
public function products()
{
return $this->hasMany(Products::class);
}

//  getting categories
$categories = Category::where('status', 'active')->get();

// somewhere maybe in a loop
// HERE IS MY PROBLEM
$var = $category->products->where('column', 'value');

Activity icon

Started a new Conversation Fetching Data From API The Right Way

How to fetch huge amounts of data from an external API. My laravel app has to fetch huge amounts of data in form of json from an external API, how can i do this and not suffer the limits and memory errors or timeouts

Feb
28
3 months ago
Activity icon

Started a new Conversation Getting Min Count On Eloquent Relationship

I have products model and category model with relationship. Category hasmany products. Now i want to get where category has the least number of products

Feb
10
4 months ago
Activity icon

Started a new Conversation Vue Update DOM

I have a list of products created usin v-for. The prices of these products periodicaly change so i request for new dat in every X seconds. Now how can i update only prices on the product list in DOM without recreating the list or moving the forcus

Feb
09
4 months ago
Activity icon

Started a new Conversation Update Values When On Data Change

I am using jquery on front end in blade.php. I loop through products and display them using jquery. The prises for these products change at any given moment. How can i make only the price fields listen to data change and update only where there is change without reloading or taking user elsewhere

Feb
08
4 months ago
Activity icon

Started a new Conversation Rendering Html From Jquery

Is it good practice rendering html from jquery. For example

var html = " <div>this is div content and some dynamic values goes here</div>";

// maybe loop the var html here

Jan
17
4 months ago
Activity icon

Started a new Conversation Auto Synch Data

I am trying to make an api call to retrieve data to display to a view then i want the data displayed to change without refresh automatically wen thr db values change. The db values are changed by a functions that runs as a job periodically..

Activity icon

Started a new Conversation Singleton Class

I want to be able to automaticall create a singleton instance of a class wen laravel starts then be able to call its functions or access variables like for example the class is called MyClass Then use like Myclass->function();

Jan
16
4 months ago
Activity icon

Started a new Conversation Typscript In Laravel

Getting error wen trying to add typscript to laravel

<script src="{{ asset('index.ts') }}" ></script>

also tried

<script type="module" src="{{ asset('index.ts') }}" ></script>

First method produce this error

"cannot use import statement outside a module"

Jan
04
5 months ago
Activity icon

Started a new Conversation Globals In Laravel

I want to make a global function from a glabal class that is initialized once..

private $var = [];

class Example {

public function example($param)
{
$this->var[$param] = $param;
}

}

In another file maybe controller

example($param);

So the Example class must auto new Example Then i must be able to call example(); from any where mantaining the existing instance of class

Jan
01
5 months ago
Activity icon

Replied to Is My Code Enough!!

Help devs

Dec
31
5 months ago
Activity icon

Replied to Please Check My Code

Hi good people. Please help me out

Dec
30
5 months ago
Activity icon

Replied to Please Check My Code

Help

Activity icon

Started a new Conversation Please Check My Code

I am trying to create a page builder and this how i render the blocks on the browser: I store everything in array then loop to create elements bassed on the array. Below is my code

index.php

$contentArr =[
    ['eltype'=>'row','content'=>[['eltype'=>'col','content'=>[['eltype'=>'widget','widgetname'=>'title','content'=>[['title'=>'The Title']]]]]]]
];
$data = '';
foreach ($contentArr  as $key => $value){
//every block starts with container row
    $t=new row("row", $value['content']);
    $data .= $t->render();
}

print_r($data);

row.class.php

class row{

    private $eltype;
    private $content;
    private $props = [];
    private $elName;

    public function __construct($eltype, $content)
    {
        $this->eltype = $eltype;
        $this->content = $content;
    }

    public function render()
    {
        if('row' == $this->eltype)
        {
            $data = '';

               foreach ($this->content as $key => $value)
               {
                   $eltype = $value['eltype'];
                   if('col' == $eltype)
                   {
                       $t=new col($eltype, $value['content']);
                       $data .= $t->render();
                   }elseif ('widget' == $eltype)
                   {
                       $t=new widget($eltype, $value);
                       $data .= $t->render();
                   }

               }
            return $data;
        }
    }
}

col.class.php

class col{
    private $eltype;
    private $content;

    public function __construct($eltype, $content)
    {
        $this->eltype = $eltype;
        $this->content = $content;
    }

    public function render()
    {
        if('col' == $this->eltype)
        {
            $data = '';


               foreach ($this->content as $key => $value)
               {
                   $eltype = $value['eltype'];
                   if('col' == $eltype)
                   {
                       new col($eltype, $value['content']);
                   }elseif ('widget' == $eltype)
                   {
                       $t=new widget($value['widgetname'], $value['content']);
                       $data .= $t->render();
                   }
               }

            return $data;
        }
    }
}

widget.class.php

class widget{

    private $eltype;
    private $content;

    public function __construct($eltype, $content)
    {
        $this->eltype = $eltype;
        $this->content = $content;
    }

    public function render()
    {
//here $this->eltype has to be a class in the widget list
        $wdgt = $this->eltype;
        $wdgt=new $wdgt();
        return $wdgt->render($this->eltype, $this->content);

    }
}

title.class.php

class title
{
private $title;
    public function render($elname, $content)
    {

        return '<h1>'.$content[0]['title'].'</h1>';
    }
}

The above code prints "The Title" Am i doing it right?... I am overwhelmed with other page builders their code is a lot of lines and complex and i start to lose confidence in mine Am i doing it right here

Activity icon

Replied to Is My Code Enough!!

Ok so what i have done.

I have 4 classes. Class Row, Class Col, Class Widget, Class Title and an index file

index.php

$contentArr =[
    ['eltype'=>'row','content'=>[['eltype'=>'col','content'=>[['eltype'=>'widget','widgetname'=>'title','content'=>[['title'=>'The Title']]]]]]]
];
$data = '';
foreach ($contentArr  as $key => $value){
//every block starts with container row
    $t=new row("row", $value['content']);
    $data .= $t->render();
}

print_r($data);

row.class.php

class row{

    private $eltype;
    private $content;
    private $props = [];
    private $elName;

    public function __construct($eltype, $content)
    {
        $this->eltype = $eltype;
        $this->content = $content;
    }

    public function render()
    {
        if('row' == $this->eltype)
        {
            $data = '';

               foreach ($this->content as $key => $value)
               {
                   $eltype = $value['eltype'];
                   if('col' == $eltype)
                   {
                       $t=new col($eltype, $value['content']);
                       $data .= $t->render();
                   }elseif ('widget' == $eltype)
                   {
                       $t=new widget($eltype, $value);
                       $data .= $t->render();
                   }

               }
            return $data;
        }
    }
}

col.class.php

class col{
    private $eltype;
    private $content;

    public function __construct($eltype, $content)
    {
        $this->eltype = $eltype;
        $this->content = $content;
    }

    public function render()
    {
        if('col' == $this->eltype)
        {
            $data = '';


               foreach ($this->content as $key => $value)
               {
                   $eltype = $value['eltype'];
                   if('col' == $eltype)
                   {
                       new col($eltype, $value['content']);
                   }elseif ('widget' == $eltype)
                   {
                       $t=new widget($value['widgetname'], $value['content']);
                       $data .= $t->render();
                   }
               }

            return $data;
        }
    }
}

widget.class.php

class widget{

    private $eltype;
    private $content;

    public function __construct($eltype, $content)
    {
        $this->eltype = $eltype;
        $this->content = $content;
    }

    public function render()
    {
//here $this->eltype has to be a class in the widget list
        $wdgt = $this->eltype;
        $wdgt=new $wdgt();
        return $wdgt->render($this->eltype, $this->content);

    }
}

title.class.php

class title
{
private $title;
    public function render($elname, $content)
    {

        return '<h1>'.$content[0]['title'].'</h1>';
    }
}

Am not sure if i am making it right

Dec
29
5 months ago
Activity icon

Started a new Conversation Is My Code Enough!!

Hi sir hope you are well...

I am upto creating drag and drop funtionality to my software... i tried looking at wordpress's page builders like elementor, their code is too complex for me to even get the idea what is going on. Now i ended doing it my self and it seems to work so far but the code is so few as compared to thoz wordpress page builders. My code is short and few files and am nw not confident with the code. I guess when you started you came accross the possition where i am right now..

Dec
25
5 months ago
Activity icon

Replied to Page Builder

I am aware of tht. I intend to create a mini cms. So am finding a way to implement the functions like tht of elementor

Activity icon

Started a new Conversation Page Builder

Is there a laravel package like elementor in wordpress.. Or php script

Dec
24
5 months ago
Activity icon

Started a new Conversation Dynamic CSS

I have in db the attributes of html div in form of array.

$atrr = [
"margin-top"=>"4px",
"padding"=>"3px 4x 4px 3px",
"border-top"=>"4px solid black"
];

Now how can i create a valid css from this array the right way

Dec
12
6 months ago
Activity icon

Replied to Rendering Components

Components is a custom abstract class. product_slider_comp class depends on some functions implemented in components... i failed to find a way to get rid of the html and use view instead.. basically am trying to make my system behave like page builders , where array is looped to construct html elements..

Activity icon

Replied to Rendering Components

There is my code am rendering components bassed on an array. So this is just one class of a component.. am not sure if am doing it ryt or if there is another better way

Activity icon

Replied to How To Write Code In Laracast?

​`​`` Test

​`​``

Activity icon

Replied to How To Write Code In Laracast?

​``fff​``

Activity icon

Started a new Conversation Rendering Components


class product_slider_comp extends components
{
    //this is a product courosel slider
    public $attr;
    public $content;

    public function __construct($attr, $content = null)
    {
        //attributes and content come as array
        $this->content = $content;
        $this->attr = $attr;
    }
//render function
    public function render()
    {
        $productSlider = '';
//this will render if there is atlist one of subheading and heading from attributes
        if (isset($this->attr['heading']) || isset($this->attr['subheading'])) {
            $productSlider .= '
					<div class="col-md-12">
						<div class="main-title-tt">
							<div class="main-title-left">';
            $productSlider .= isset($this->attr['subheading']) ? '<span>' . $this->attr['subheading'] . '</span>' : '';
            $productSlider .= isset($this->attr['heading']) ? '<h2>' . $this->attr['heading'] . '</h2>' : '';
            $productSlider .= '
                            </div>
							<a href="#" class="see-more-btn">See All</a>
						</div>
                    </div>';
        }

        $productSlider .= '
					<div class="col-md-12">
                        <div class="owl-carousel featured-slider owl-theme">';
//the filterProducts function is abstruct and returns an object of product
        $products = $this->filterProducts($this->attr);
        if (!$products || count($products) == 0) {
            return;
        }
        foreach ($products as $product) {
            $productSlider .= '
							<div class="item">
								<div class="product-item">
									<a href="#" class="product-img">';
            $productSlider .= empty($product->featuredImg) ? '' : '<img src="' . asset($product->featuredImg) . '" alt="">';

            $productSlider .= '<div class="product-absolute-options">';
            $productSlider .= empty($product->discount) ? '' : '<span class="offer-badge-1">' . $product->discount . '% off</span>';
            $productSlider .= '<span class="like-icon" title="wishlist"></span>
										</div>
									</a>
									<div class="product-text-dt">';
            $productSlider .= ($product->stkquantity > 0) ? '<p>Available<span>(In Stock)</span></p>' : '<p>Not Available<span>(In Stock)</span></p>';
            $productSlider .= '<p>Available<span>(In Stock)</span></p>
										<h4>' . $product->post_title . '</h4>
										<div class="product-price">' . empty($product->discount) ? '' : '$' . $this->discountedprice($product->discount, $product->price) . '<span>' . $product->price . '</span></div>';
            $productSlider .= '<div class="qty-cart">
											<div class="quantity buttons_added">
												<input type="button" value="-" class="minus minus-btn">
												<input type="number" step="1" name="quantity" value="1" class="input-text qty text">
												<input type="button" value="+" class="plus plus-btn">
											</div>
											<span class="cart-icon"><i class="uil uil-shopping-cart-alt"></i></span>
										</div>
									</div>
								</div>
                            </div>';
        }

        $productSlider .= '
			</div>
        </div>';

        return $productSlider;
    }

    public function discountedprice($discount, $price)
    {

        //returns discounted price
    }

}​
Dec
08
6 months ago