STEREOH

STEREOH

Member Since 4 Years Ago

Dijon

Software Engineer at Intitek.fr/APRR.fr

Experience Points 37,180
Experience Level 8

2,820 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 228
Lessons
Completed
Best Reply Awards 29
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.

29 Apr
2 months ago

STEREOH left a reply on Laracasts Search

Then again would be appreciated if the search form redirected to the "Forum search" page if we hit "Enter" in the "Discussion" tab.

STEREOH left a reply on Laracasts Search

Why don't you just hit "Enter" and filter your search however you want in the "Browse" page that is made specifically for what you ask ?

25 Apr
2 months ago

STEREOH left a reply on Should I Use Voyager With This Project?

I'd say if your goal is to learn while creating your application and you have time, the best solution will always be to do it yourself.

19 Apr
3 months ago

STEREOH left a reply on How To Update A Model

You forgot the parenthesis

$this->subscriptions()->where(['user_id' => auth()->id()])->update(['active' => false]);

STEREOH left a reply on One Question About TDD With Laravel 5.8

I think it is if i'm not mistaken.

STEREOH left a reply on Fix It

What are you waiting for Snapey ? Fix it !

Good laugh

STEREOH left a reply on Display BelongsTo Relation In Details Of Nova Resource

Yeah sorry, I didn't see the nova tag.

Never used it so I can't help you.

STEREOH left a reply on SQLSTATE[42S02]: Base Table Or View Not Found: 1146

1 - Stop reviving dead threads 2 - Learn to read ? 3 - run php artisan migrate 4 - Did you even create a migration ?

STEREOH left a reply on Display BelongsTo Relation In Details Of Nova Resource

belongsTo is used to define your relationship in your model.

can you show me your Order Model ?

if you did things correctly it's pretty simple

//Model "Order"

public function user()
{
    return $this->belongsTo(User::class);
}
//Either in your Controller or View

$order->user // will get you the user 

// now all you have to do is to get his infos : 

$order->user->email //for example
17 Apr
3 months ago

STEREOH left a reply on Array_merge(): Expected Parameter 2 To Be An Array, String Given

Plus for your converter to work index()method should only return the view and you should probably make a second method called by a Route::post() to handle the conversion.

STEREOH left a reply on Array_merge(): Expected Parameter 2 To Be An Array, String Given

Well first of all

Route::get('temp', function() {
    return view('temp', '[email protected]');
});

???

Route::get('temp', '[email protected]');
16 Apr
3 months ago

STEREOH left a reply on ReferenceError: Axios Is Not Defined

you have to import it to be able to use it.

Assuming you already installed it with npm.

<script>
import axios from 'axios';
15 Apr
3 months ago

STEREOH left a reply on Only Posting X Times A Minute

You could count the number of posts the user created in the last minute and if it's > 6 redirect back.

STEREOH left a reply on Api Routes In Non SPA Application.

@TYKUS - woops , wrote it too fast + tired , that is if he doesn't want it to show from a browser request.

@kovbo to add to @tykus answer you can work it out with $request->ajax() or $request->wantsJson()

STEREOH left a reply on Api Routes In Non SPA Application.

You shouldn't ever call a get route with AJAX.

Use only posts.

STEREOH left a reply on Laravel Upgrade To 5.8 Error

Check that the PHP in your PATH is the good one (7.1.3+)

STEREOH left a reply on Defining Form Input Fields From Controller

I like to treat those not as validation, as it is client-side validation that may or may not be supported by every browser or worse bypassed. The only real validation is your Controller validation.

I prefer to treat it as QoL for the user, therefore, styling.

STEREOH left a reply on Defining Form Input Fields From Controller

You could counter-argument that the controller shouldn't have knowledge of the styling of your inputs ( classes, placeholders ... )

STEREOH left a reply on Defining Form Input Fields From Controller

I can't see how it would be bad practice. You do you :)

That being said, I would, personally, not do it as I really like to make my markup myself. Plus that would make implementing a frontend Framework more difficult.

STEREOH left a reply on BelongsToMany Inverted Relationship

You should indeed use it.

Now it seem you don't have a subscription_id column in your plans table. Does it have an other name ? If so you must override it with a third parameter.

hasManyThrough(Plan::class, Subscription::class, 'specific_column')
14 Apr
3 months ago

STEREOH left a reply on Textarea - Default Value Repeats When Old Function Is Used

<textarea class="form-control" id="Description" rows="10" name="description">
{{ old('description', "
Item:
Qty:
Each:
Total:
") }}
</textarea>

12 Apr
3 months ago

STEREOH left a reply on 404 Not Found

can you show your route file please?

STEREOH left a reply on Excel Import Date Format Issue .

@VANDAN - Well that's a shame ... all you had to do is click on the link, find the format method, click on it and you would have had all the examples.

'Bill_Date' => \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row['1'])->format('Y-m-d');

STEREOH left a reply on Excel Import Date Format Issue .

It's a DateTime object, so just use it ?

https://www.php.net/manual/en/class.datetime.php

hint : use formatmethod

STEREOH left a reply on Response->json($array) Giving Out Too Much Input And Not Just Json?

@ASHLEYP - No problem, have fun :)

Don't forget to mark the post as answered !

STEREOH left a reply on Response->json($array) Giving Out Too Much Input And Not Just Json?

@ASHLEYP - shouldn't your index method return the result from your login method ?

    public function index(Request $request)
    {
        return $this->login($request);
    }

STEREOH left a reply on Getting All Records Which Relationship Doesn't Have A Specific Value In Laravel 5.5.

You just need doesntHave.

Question::doesntHave(‘Answers’, function ($query) { $query→where(‘user_id’, $user_id); });

STEREOH left a reply on Vue.components() Vs Vue.use() And Why I Can't Get Calendar To Work.

@CHRISGRIM - Did you import it ?

// import component and stylesheet
import AirbnbStyleDatepicker from 'vue-airbnb-style-datepicker'
import 'vue-airbnb-style-datepicker/dist/vue-airbnb-style-datepicker.min.css'

11 Apr
3 months ago

STEREOH left a reply on Get Data From Database Error.

You don't have to do all of that, just do :

return view('Dashboard')->with('posts',Auth()->user()->posts);

STEREOH left a reply on Resetting Progress On Courses

You can unmark each lesson as watched by clicking on the "Lesson Completed" button but not an entire course at once.

10 Apr
3 months ago

STEREOH left a reply on Count In Controller

$group = Group::count();

STEREOH left a reply on Returning Count To Blade

@AIN - You're in an array.

just add to the array like that :

return view('yourView', ['admin' => $admin, 'second' => $nextVariable, ....]);

STEREOH left a reply on Returning Count To Blade

Are you passing your $admin collection to your view?

https://laravel.com/docs/5.8/views#passing-data-to-views

STEREOH left a reply on Laravel 5.5 PHP Error

You probably get this error because you have a null coalesce in your code. Keep in mind that laravel isn't compatible anymore with PHP 7.0 since Laravel 5.5 (last version compatible)

So either downgrade your laravel version to 5.5, or find an other hosting plan.

STEREOH left a reply on Add A Blog

I would do it myself if I was you but you can indeed use one of the many packages possible.

Just search Laravel blog package on google, I couldn't recommend you one specifically since I don't use them.

08 Apr
3 months ago

STEREOH left a reply on Getting A Value From A Cell In A Database

If your goal is to get the First row with this code, just replace get() with first().

STEREOH left a reply on /public_html/cache/files Permissions

@BEHNAMPMDG3 - I'm wondering who's the biggest Exp Farmer here?

  • @crushedcoder who has 80exp 1 thread and one reply trying to help (even if it was a bad attempt )
  • @behnampmdg3 who has a whopping 21k exp posting 3 dumb threads a day that could easily be solved with a google search.

Laracasts is a community, not your personal tech support. Be glad you get answers and learn to point the wrong ones and the good ones. :)

STEREOH left a reply on What Controller Should Be Responsible For Static Pages?

@TYKUS - I like this approach too.

I only use a controller to get some data on some of my pages, but I can agree that if you only need a purelly static page there's no need for it.

STEREOH left a reply on What Controller Should Be Responsible For Static Pages?

I would use either of the two first options you cited.

The 2 last options are too specific and you don't want to create a controller for each static page you create.

Just create a StaticPageController (or PageController) and redirect your route to a specific method in it.

05 Apr
3 months ago

STEREOH left a reply on Check Input First

You can validate your inputs and check if your city exists like this.

$adress = request()->validate([
    'city_name' =>  'exists:cities,name'
]);

STEREOH left a reply on Could Someone Explain How This Works? - PHP Practitioner Episode 20

It is SQL parameter binding.

Basically this code :

$sql = sprintf(
         'INSERT INTO %s(%s) values (%s)', 
         $table, 
         implode(', ', array_keys($parameters)),
         ':' .implode(', :', array_keys($parameters))
        );

will produce a string like this :

INSERT INTO users(name, etc...) values (:name, :etc...)'

Preparing this statement with pdo , you will tell it to wait for an array with a key on name.

Then you execute passing your parameter array wich happens to have a key of name.

So it will bind the value of the key nameto the :name in the request.

03 Apr
3 months ago

STEREOH left a reply on Group Then Sum? (For Leaderboard)

You should really take a look at the documentation, this is SQL 101. https://laravel.com/docs/5.8/queries#ordering-grouping-limit-and-offset

User::selectRaw('id, sum(score)')
   ->groupBy('id)
   ->get();
01 Apr
3 months ago

STEREOH left a reply on Count Every Fourth Record

well, assuming your data is correct, you don't need to count from the last free meal, you only need to know how many reservations have been made, and check if the result of the modulo is 3.

Now if you're not sure about your data or really want to count from the last free meal.

$lastFreeMeal = Reservation::where('free_meal', 1)->last();
$count = Reservation::where([
    ['guest_id', 1],
    ['id', '>', $lastFreeMeal->id]
])->count();

if ($count == 3) {
    // Free Meal
}

STEREOH left a reply on How To Improve Programming Logic

I feel like many people on this website ( atleast the people posting on these forums ) have close to no basic understanding of logic, basic algorithm and data structure.

In my opinion you can't learn a programming language ( as easy as php is ) if you haven't got any understanding of how a computer works.

It's like trying to design a house whitout any architectural knowledge. You'll be able to do it , but it's going to take time , and look like shit.

STEREOH left a reply on Count Every Fourth Record

@PICKAB00 - Oh so you already have your reservations in your database.

$fourthReservations = Reservation::where('guest_id', 1)->nth(4, 3); //This will get all fourth reservations in your database

foreach($fourthReservations as $reservation) { //Foreach 4th reservation
    $reservation->free_meal = 1; // Set free_meal to 1
    $reservations->save(); // save it
}

STEREOH left a reply on Count Every Fourth Record

It's ok so now you got all your users resevations , you just want to count it with the count method of you collection.

$reservations = Reservation::where('guest_id', 1)->get();

$count = $reservations->count();