Ashraam

Ashraam

Web Developper at Ajaccio

Member Since 4 Years Ago

Ajaccio

Experience Points
104,540
Total
Experience

460 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
890
Lessons
Completed
Best Reply Awards
17
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 21
104,540 XP
May
20
2 months ago
Activity icon

Commented on Techniques For Testing Against A Real API

Don't know why but I can't create a Best Buy account... anyone has this problem (I'm in France)

Activity icon

Awarded Best Reply on Link From Alert To Table

You could do some trick with html anchor, highlight the row using css and and query parameter (?licenceId=X) or just maybe just return the licence (sql query)

May
07
3 months ago
Activity icon

Commented on Programming Katas Explained

Because he is a kata master !

Activity icon

Commented on Programming Katas Explained

The animation is neat !

May
05
3 months ago
Activity icon

Commented on Rapid Code Generation With Blueprint

This is just CRAZY stuff

Apr
14
3 months ago
Activity icon

Replied to Interface In Laravel:

I think it being case-sensitive related problem.

I don't think PHP namespaces are case-sensitive, but when being autoloaded by composer or resolved from the Laravel container they are, due to the fact that the names are stored in arrays that have case-sensitive strings as the key.

Apr
09
4 months ago
Activity icon

Replied to Product Filter Query Return Me 500 Why.

$filterValues = array();
parse_str($request->formData, $filterValues);

$products = Product::where(function($query) use(filterValues) {

	$free = isset( $filterValues['free'] ) ? 'yes' : null;
	if(isset($free) ){
             $query->orwhere('price','<=','0');
        }
            
})->get();

echo json_encode($products);

Add the use word in the function if you want to use a variable outside the function

Activity icon

Replied to Delete Post Image

You should take a look to model observer ( https://laravel.com/docs/7.x/eloquent#observers )

The idea woud be

You create an observer for your post model and in the deleting method you could do something like

function deleting(Post $post) {
   foreach($post->photos as $photo) {
      unlink($photo->path);
      $photo->delete();
   }
}

this is just a silly example you could improve this a tons

Activity icon

Replied to How To Calculate No_of_days Between To Datepickers

In JS you can calculate days between two dates like this:

function days() {
    var a = $("#datepicker_start").datepicker('getDate').getTime(),
        b = $("#datepicker_end").datepicker('getDate').getTime(),
        c = 24*60*60*1000,
        diffDays = Math.round(Math.abs((a - b)/(c)));
    console.log(diffDays); //show difference
}

Now you just have to implement a "onChange" event with your date picker (you should find this on the doc)

Activity icon

Replied to How To Correclty Categories A Nested Relationship?

so use the group by method on the collection ? https://laravel.com/docs/7.x/collections#method-groupby

Or change the problem,

Get the games with theirs groups and results and then group by group

Activity icon

Replied to Problem With Joining Queries And Displaying Data In Blade In Laravel

what about dd($interest) and look all the data

Activity icon

Replied to Web Application Servers Infrastructure And Configuration (to Display And Stream Media With Laravel & Nginx)

I can't respond to all your questions but

  • Display file in FTP, check the Storage facade you can configure a FTP
  • It is a suitable solution ? Well I think infrastructure depends a lot on the traffic ! so can you estimate this ?
Activity icon

Replied to How To Correclty Categories A Nested Relationship?

Group::with('games', 'games.results')->find($groupId);

no ?

Activity icon

Replied to Auto-detect Relationships

Oh ok I see what you want to achieve here, and I don't think there anything to handle this out of the box.

You should pass the relationships you know to load to the controller "manually"

Activity icon

Replied to Stop Adding Poor Quality Laravel Addons

As a laravel champion you should help them to make those packages production ready then !

Activity icon

Awarded Best Reply on Mysql SHOW VARIABLES - Forge

// In the terminal
> mysql -u forge -p

// When logged into mysql
> SHOW VARIABLES
Activity icon

Replied to Mysql SHOW VARIABLES - Forge

// In the terminal
> mysql -u forge -p

// When logged into mysql
> SHOW VARIABLES
Apr
08
4 months ago
Activity icon

Replied to How To Do Laravel Relationship With Foregin Key And Self Relation

If you have done your relationship well you could query things like this

Country::whereHas('[relationship name]', function($q) {
   $q->where('type_of_tour', 'single');
})->get();
Activity icon

Replied to Auto-detect Relationships

You can add

$person = Person::with('pets')->find($request->id);

// OR

$person->load('pets'); //after the save method

// If a person should always has pets eager loaded then you could add this the the person model

$with = ['pets'];
Activity icon

Replied to Problem With Joining Queries And Displaying Data In Blade In Laravel

Why don't you use Eloquent ?

In this case you could have something like this

$user = User::with('interests')->find($userId);

foreach($user->interests as $interest) {
	dd($interest->field->name, $interest->value->label);
}

To achieve this you should create a model UserInterest (pointing to the user_interests table) and add the field and value relationship like this (the $with attribute will eager load relationship each time you access the model)

Class UserInterest extends Model {
   protected $with = ['field', 'value'];

   function value() {
      return $this->belonsgTo(Value::class);
   }

   function field() {
      return $this->belongsTo(Field::class);
   }
}

and then add the interest method to the User model

function interests() {
   return $this->hasMany(UserInterest::class);
}

It's hard to do it without coding it but it should be working somehow

Apr
06
4 months ago
Activity icon

Replied to Slick Carousel- How To Add Three Dots Below The Images?

@nickywan123 I think you have to choose a "best answer"

Activity icon

Replied to Laravel API: Request Is Not Finished Yet

that's weird, don't know where the problem could be sorry :/ Sounds like a Nginx problem imo

Apr
03
4 months ago
Activity icon

Awarded Best Reply on I Get Call To A Member Function IsValid() On Boolean

it's $request->file('admin_image')->isValid() and not $request->hasFile('admin_image')->isValid()

$request->hasFile('admin_image') returns a boolean so it's not an object

Activity icon

Replied to On Any Form Submission It Gives. "The Page Is Expired Due To Inactivity. Please Refresh And Try Again"

this should be like this:

<form method="post" action="[url]">
   @csrf
   // form inputs
</form>
Activity icon

Replied to Add Created By & Updated By To Data

You you use the model observers (https://laravel.com/docs/7.x/eloquent#observers )

or you can add a boot method inside your model like this:

protected static function boot()
{
  parent::boot();
  
  static::created(function($model) {
    $model->created_by = auth()->id();
  });

  static::updated(function($model) {
   $model->updated_by = auth()->id();
  });
}
Activity icon

Replied to I Get Call To A Member Function IsValid() On Boolean

it's $request->file('admin_image')->isValid() and not $request->hasFile('admin_image')->isValid()

$request->hasFile('admin_image') returns a boolean so it's not an object

Activity icon

Awarded Best Reply on Query Fetches Only 2 Records

I don't see any particular problem here..

if you dd($fff) you only have 2 rows ? Then it comes from the data in the DB :/

Anyway you should use Eloquent model instead of DB class, more readable and easiest to use if you have relationship etc

Activity icon

Awarded Best Reply on Problem With Retrieving Models Data

you are using soft deletes, in the database the deleted_at field is null right ? Maybe try without the SoftDeletes trait first

Because I'm not sure soft deletes are taken in consideration while using DB facade

Activity icon

Replied to Problem With Retrieving Models Data

you are using soft deletes, in the database the deleted_at field is null right ? Maybe try without the SoftDeletes trait first

Because I'm not sure soft deletes are taken in consideration while using DB facade

Activity icon

Replied to Link From Alert To Table

You could do some trick with html anchor, highlight the row using css and and query parameter (?licenceId=X) or just maybe just return the licence (sql query)

Activity icon

Replied to WithCount Return Null Within A Notification When Implements ShouldQueue

When you dd(Thread::take(6)->withCount('replies')->get()) with tinker you get the replies_count ?

Did you restart the queue after updating the code ?

Activity icon

Replied to Problem With Retrieving Models Data

Can you copy the Categorie Model code,

oh and you could inline your return statement like this:

$categories = Categories::all() //I'd use get if I were you

return view('news.create', compact('categories'));
Activity icon

Replied to Str_replace || ! Str_replace ?

it's ok, you could inline it like this

$parameters['body'] = str_replace(['<pre>', '</pre>'], ['<pre><code>', '</code></pre>'], $parameters['body']);
Activity icon

Replied to Slick Carousel- How To Add Three Dots Below The Images?

ok then mark the thread as completed !

Activity icon

Commented on Deferred Loading And Caching Server-Fetched Partials

This github package is magnificent !

Activity icon

Replied to Query Fetches Only 2 Records

You have to select fbId field too !

Activity icon

Replied to Thumbnails, Create Or Generate ?

Looks at this package, very good solution to create / resize / fit images (working with GD or Imagick): http://image.intervention.io/

Activity icon

Replied to On Any Form Submission It Gives. "The Page Is Expired Due To Inactivity. Please Refresh And Try Again"

Can you show us the form at least ?

Did you add the csrf token in the form (@csrf)

Activity icon

Replied to Query Fetches Only 2 Records

I don't see any particular problem here..

if you dd($fff) you only have 2 rows ? Then it comes from the data in the DB :/

Anyway you should use Eloquent model instead of DB class, more readable and easiest to use if you have relationship etc

Activity icon

Replied to Slick Carousel- How To Add Three Dots Below The Images?

they should be there, did you call the slick css file in your html ?

Activity icon

Replied to Laravel API: Request Is Not Finished Yet

Does this $response->throw(); tell you something more ?

Activity icon

Replied to The Better Way To Call Model In _construct When Migrate From Beginning

Is this config really needs to be stored in the database ?

Why not in a file in the config folder ?

Activity icon

Replied to Relationship Loading

Hi,

Can you show us the code you use to pass the data to the view ?

Some tips:

  • Use pagination,
  • Select only fields you're using
Activity icon

Awarded Best Reply on Laravel Caching With Redis

Well you should do something like:

$products = Cache::rememberForever('products', function() {
     return Product::with('variations.stock')->get();
});

No if else, if the cache key isn't found it will make the query then cache it for next queries

By the way your error seems to be: you're trying to call the first method on an array (it should be a collection instead)

Activity icon

Replied to [OFF TOPIC] I'm Making My System Available As Opensource

Hey I'll take a look to this, sounds interesting

Activity icon

Replied to Laravel Caching With Redis

Well you should do something like:

$products = Cache::rememberForever('products', function() {
     return Product::with('variations.stock')->get();
});

No if else, if the cache key isn't found it will make the query then cache it for next queries

By the way your error seems to be: you're trying to call the first method on an array (it should be a collection instead)

Mar
13
4 months ago
Activity icon

Replied to Laravel Socialite Problem

Well I did, the urls in the Twitter app are good (it's work on local and dev, so I just had to change the domain which is correct)

Activity icon

Started a new Conversation Laravel Socialite Problem

Hi there,

I’ve got a weird problem and I didn’t find any solution to fix it.

I’ve created an app with the “Sign in with Twitter” option checked to allow user to sign/register via their Twitter account.

I’ve whitelisted all the callbacks uri (for local, dev and prod environment)

It works great on local and dev but not on production. Here is the error: <?xml version='1.0' encoding='UTF-8'?><errors><error code="415">Callback URL not approved for this client application. Approved callback URLs can be adjusted in your application settings</error></errors>

I’m using Laravel and the Socialite Package, did anyone solve this ?

Thanks