walidabou

walidabou

Member Since 2 Years Ago

Experience Points
7,610
Total
Experience

2,390 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
12
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 2
7,610 XP
Jul
07
3 months ago
Activity icon

Awarded Best Reply on Where Clause From API Array

Try this:

$filteredFlights = array_filter($flights, function($var) {
	return $var['isOld'] == false;		//or return $var->isOld == false;
});

dd($filteredFlights);

or use this helper:

use Illuminate\Support\Arr;

$filteredFlights = Arr::where($flights, function ($value, $key) {
    return $value['isOld'] == false;
});
dd($filteredFlights);
Activity icon

Replied to Where Clause From API Array

Try this:

$filteredFlights = array_filter($flights, function($var) {
	return $var['isOld'] == false;		//or return $var->isOld == false;
});

dd($filteredFlights);

or use this helper:

use Illuminate\Support\Arr;

$filteredFlights = Arr::where($flights, function ($value, $key) {
    return $value['isOld'] == false;
});
dd($filteredFlights);
Activity icon

Replied to How Do I Get The Max Value?

I think you shouldn't use paginate because max return only one record. and additionally you just want to fetch the max value of episode column, so you don't need with() and groupBy().

$maxEpisode = Video::max('episode');
Activity icon

Replied to Options For Routing To Visitors, Dashbaord And Admin

The best way I think is using this package https://github.com/nWidart/laravel-modules this package seperate your models,controllers,view...

Jun
29
4 months ago
Activity icon

Replied to Return A Json File Of Only The Latest Records Per Each Foreign Key

try this:

$payments = Tenant::with('payments', function($q){
  return $q->latest()->limit(3);
})->get();

in your Tenant model:

public function payments()
{
  return $this->hasMany('App\Payment',...);
}
Activity icon

Replied to Laravel Request::all() Should Not Be Called Statically

As MEESHAL mentioned, you should call it $request->all(). And where is your code?

Activity icon

Replied to Undefined Variable: Image_name

That means the image is not uploaded so php won't execute your if block. make sure that you upload the image correctly, or as temporary solution you can define the variable before the if statement like this:

$image_name = 'default.jpg';

  if ($request->hasFile('image')) {
        $image = $request->file('image');
        $image_name = $image->getClientOriginalName();
        $image->move(public_path('images/images'), $image_name);
    }
    Style::create([
        'style_name' => $request->style_name,
        'image' => $image_name,
        'email' => $request->email,
        'style_logo' => $filename,
        'founder' => $request->founder,
        'website' => $request->website,
    ]);

So in this case if the image was uploaded correctly the $image_name will be the one inside if block, otherways it will be 'default.jpg'

Jun
26
4 months ago
Activity icon

Replied to Eloquent And Css

put it as inline style.

<div style="background:url('.../$user->image')"></div>

You can't add php code to external css

Jun
24
4 months ago
Activity icon

Replied to Laravel Components And Vue.js

This is just a button and there is no problem with it. It doesn't affect the SEO

Jun
22
4 months ago
Activity icon

Replied to Error Update Model With Unique Field

Can you show us your UserUpdateRequest.php ?

Activity icon

Replied to Getting Response From A POST Request

Do you mean that you don't know how to handle the response in your frontend ?

Activity icon

Replied to Getting Response From A POST Request

So you can return just the reference:

return response()->json(['reference' => $booking->reference]);
Activity icon

Replied to Getting Response From A POST Request

Can you clarify your question more? Do you want to return the newly created booking to the customer ?

Activity icon

Replied to Props Component Rendering Issue

What is it ?

Jun
21
4 months ago
Activity icon

Replied to Props Component Rendering Issue

"when selected_articles is empty the component doesn't show at all" => That is obvious because you have an "if" condition inside the component. The question is: what do you want to show when the selected_articles is empty ? Probably you want to show an alert or message or something...

You can do something like this:

<template>

  <div>

    <loading-animation v-if="isLoading"></loading-animation>

    <div v-if="! isLoading">
      <show-articles v-if="selected_articles.length > 0"></show-articles>
      <articles-empty v-if="selected_articles.length === 0">Sorry! no articles</articles-empty>
    </div>

  </div>

</template>

<script>

export default {
  data() {
    return {
      isLoading: false,
      selected_articles: []
    }
  },
  created() {
    this.isLoading = true //show the loading animation

    //Start your request to fetch the data...........................

    //When fetching data is done
    this.selected_articles = data //the selected articles fetched from the api
    this.isLoading = false //Hide the loading animation and show the "show-articles" component
  }
}
</script>
Activity icon

Replied to How To Replace A Component To Other Components Using Vue Router

Just add a "dashboard" component as your home page in your "router" file like this:

import Dashboard from '.../Dashboard'

const routes = [
    {
        path: '/',
        component: Dashboard,
        name: 'dashboard'
    }
	//...
]
Jun
19
4 months ago
Activity icon

Awarded Best Reply on How Can I Shorten This Code

Try this

$exchangeRateToDollar = Currency::where('currencyType','ETB')->firstOrFail()->exchangeRate;
$startPriceDollar = $request->start_price * $exchangeRateToDollar;
$endPriceDollar = $request->end_price * $exchangeRateToDollar;

$organizations = Organization::withCount(['rooms','confrences'])->with(['typeOfOrganization','user'])->where('approved', 1)->when(request(['start_price', 'end_price']), function($query) use ($startPriceDollar, $endPriceDollar) {
			return $query->where(function($q) {
			 return $q->where('organizations.avg_price', '>=', request('start_price'))->where('organizations.avg_price', '<=', request('end_price'));
			})->orWhere(function($q) {
			 return $q->where('organizations.avg_price', '>=', $startPriceDollar)->where('organizations.avg_price', '<=', $endPriceDollar);
	});
})->get();

$organizations = $organizations->paginate(21);
Activity icon

Replied to How Can I Shorten This Code

Try this

$exchangeRateToDollar = Currency::where('currencyType','ETB')->firstOrFail()->exchangeRate;
$startPriceDollar = $request->start_price * $exchangeRateToDollar;
$endPriceDollar = $request->end_price * $exchangeRateToDollar;

$organizations = Organization::withCount(['rooms','confrences'])->with(['typeOfOrganization','user'])->where('approved', 1)->when(request(['start_price', 'end_price']), function($query) use ($startPriceDollar, $endPriceDollar) {
			return $query->where(function($q) {
			 return $q->where('organizations.avg_price', '>=', request('start_price'))->where('organizations.avg_price', '<=', request('end_price'));
			})->orWhere(function($q) {
			 return $q->where('organizations.avg_price', '>=', $startPriceDollar)->where('organizations.avg_price', '<=', $endPriceDollar);
	});
})->get();

$organizations = $organizations->paginate(21);
Activity icon

Replied to Help With Load()

$contentPage ??!! Where did you get this variable from ? you should use $page

Activity icon

Awarded Best Reply on Controller And Compact

You can put your variable in protected method and call it from any method.

public function show()
{
    return view('demo', ['role' => $this->user_role()]);
}

public function some_method()
{
    echo $this->user_role();
}

//Protected method
protected function user_role()
{
    return auth()->user()->role;
}
Activity icon

Replied to Difference Between Auth()->user()->id And Auth::user()->id

They do the same job, Just the "auth()" called a 'Helper function' and "Auth::" called facade

Activity icon

Replied to Controller And Compact

You can put your variable in protected method and call it from any method.

public function show()
{
    return view('demo', ['role' => $this->user_role()]);
}

public function some_method()
{
    echo $this->user_role();
}

//Protected method
protected function user_role()
{
    return auth()->user()->role;
}