deansatch

deansatch

Member Since 3 Years Ago

Experience Points
69,760
Total
Experience

240 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
302
Lessons
Completed
Best Reply Awards
55
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 14
69,760 XP
Apr
07
2 days ago
Activity icon

Awarded Best Reply on HALP! Laravel Mix Not Using My App.css

Well yes it just sounds like cache. Use versioning. It isn’t difficult and will take you less than a minute to set up.

https://laravel.com/docs/7.x/mix#versioning-and-cache-busting

Activity icon

Replied to HALP! Laravel Mix Not Using My App.css

Well yes it just sounds like cache. Use versioning. It isn’t difficult and will take you less than a minute to set up.

https://laravel.com/docs/7.x/mix#versioning-and-cache-busting

Activity icon

Replied to HALP! Laravel Mix Not Using My App.css

So if you load the page http://laravel6.test/css/app.css does it show what you want??

If not does this show it http://laravel6.test/css/app.css?v=1

Apr
06
3 days ago
Activity icon

Replied to Get User Name Inside A Query HELP!! Thanks In Advance

It is difficult to understand exactly what you are trying to do but I think this might be it?

return $user->directs()->with('user')->get();

Activity icon

Replied to Get User Name Inside A Query HELP!! Thanks In Advance

Also why do you want a perfectly good line of code which returns the correct results to be replaced with a different line of code that has an apparently different meaning?

Activity icon

Replied to Get User Name Inside A Query HELP!! Thanks In Advance

Your user model relationship looks wrong. Should it not be this?


 public function directs()
    {
        return $this->hasMany('App\Sponsor' );
    }

Activity icon

Replied to Get User Name Inside A Query HELP!! Thanks In Advance

sorry...remove the brackets.

return $user->directs;

Activity icon

Replied to Get User Name Inside A Query HELP!! Thanks In Advance

You don't need ->with('user') as directs() is the users.

return $user->directs();

//should return user with 'directs' (which are also users)

Mar
31
1 week ago
Activity icon

Replied to How To You Usually Sync Your Local And Remote DB?

I wouldn’t say I was attacking you. I was just recommending trying a workflow that the majority of Laravel devs use as it would solve the issue you now have. Take it or leave it, but don’t take it to heart

Activity icon

Replied to How To You Usually Sync Your Local And Remote DB?

I know most people like to work they way they have always worked and changing is a nightmare, but writing your own migrations is just as 'visual' as any other way really and it would be well worth your time to use this problem as an excuse to start doing it that way. It will make life easier on any dev that might come in on one of your projects if it is done in a more standardised way, as well as giving you more opportunities to work on other projects with devs/agencies that work this way too.

Activity icon

Replied to How To You Usually Sync Your Local And Remote DB?

Migrations would be perfect for this. Any table changes made during development if done via migrations would then be available to run on deployment. So you make your local changes, push to repo, deploy however and run migrate. If you are using envoyer you can set it to run migrate on every deployment

I haven’t used table plus for a while but I’m pretty sure you can export structure only

Activity icon

Replied to How To You Usually Sync Your Local And Remote DB?

Like nfms I assumed you would export and import. Why would you “sync” two databases like that? That sounds no different to simply sharing the same dB credentials on local and remote???

Activity icon

Replied to How To You Usually Sync Your Local And Remote DB?

Take a look at table plus. The limitations of the free version might not even be an issue for you

Activity icon

Replied to Logs/laravel.log Could Not Be Opened: Permission Denied

Not the right way to do it. You shouldn’t need to open it up completely.

Activity icon

Replied to How To You Usually Sync Your Local And Remote DB?

oh...well probably the most popular although not free is https://tableplus.com/ - price is very low though. You can also use it for free with some limitations (2 tabs max etc...) https://tableplus.com/blog/2018/10/tableplus-free-vs-paid.html

Mar
27
1 week ago
Activity icon

Replied to Laravel : Generate Simple Auto Increment Serial Number For Person.

why don't you just use the ID? You can prepend the "PER-" to your output. Why the leading single zero? Are there only going to be a maximum of 99?

Activity icon

Replied to GatsbyJS And Laravel

You should be able to use laravel to provide the api endpoints for a gatsby site to pull from, yes.

Look at this - your laravel project would basically be your headless cms https://www.gatsbyjs.org/docs/sourcing-from-private-apis/

Activity icon

Replied to How To Fix HTTP ERROR 500 IHost Control Panel - Laravel

It takes a bit more fiddling to get things pointing to the right places on shared hosting. Look...

https://laravelarticle.com/deploy-laravel-on-shared-hosting

Activity icon

Replied to Query Where Date_format() Issue

your two where statements seem like they wouldn't work well together anyway - one or the other it seems. Here is one anyway which should help in doing the other

 ->where('customer_id',$customer_id)
		->whereRaw(" DATE_FORMAT(created_at,'%Y-%m-%d %H:%i') >= ? ", [$fromDate]);
        }

or maybe this...

 ->where('customer_id',$customer_id)
		->where(\DB::raw("(DATE_FORMAT(created_at,'%Y-%m-%d %H:%i'))"), ">=", $fromDate);
        }

Mar
26
2 weeks ago
Activity icon

Replied to Trouble Connecting To Database Using Laravel On Host Gator

assuming the credentials are correct try 127.0.0.1 instead of localhost

Activity icon

Awarded Best Reply on Ajax To Pass Onchange

<script>
    $(document).ready(function(){
        $(".custom-select").change(function(){
            var OrderSelection = $(this).val();
		//or for text instead of value
		 //var OrderSelection = $(this).find("option:selected").text()
            alert("You have selected - " + OrderSelection);
        });
    });
</script>



Activity icon

Replied to Ajax To Pass Onchange

<script>
    $(document).ready(function(){
        $(".custom-select").change(function(){
            var OrderSelection = $(this).val();
		//or for text instead of value
		 //var OrderSelection = $(this).find("option:selected").text()
            alert("You have selected - " + OrderSelection);
        });
    });
</script>



Activity icon

Awarded Best Reply on Automatically Create Slug From Title Using Create & Validate Methods

use Illuminate\Support\Str;

public function validateArticle() {
 $validate = request()->validate([
      'title' => 'required',
      'excerpt' => 'nullable',
      'body' => 'nullable'
    ]);

    $validate['slug'] = Str::slug($validate['title'], '-');

return  $validate;
 }

Activity icon

Replied to Code To Upload Audio

That code doesn't upload an image - you need to show more code

Activity icon

Replied to Automatically Create Slug From Title Using Create & Validate Methods

use Illuminate\Support\Str;

public function validateArticle() {
 $validate = request()->validate([
      'title' => 'required',
      'excerpt' => 'nullable',
      'body' => 'nullable'
    ]);

    $validate['slug'] = Str::slug($validate['title'], '-');

return  $validate;
 }

Activity icon

Awarded Best Reply on Accessing Path Function In Model In Index File

if you dump $news are you sure they all have a slug? What you have should work provided all articles in the loop have an id and slug.

public function index() {
    $news = News::latest()->get();
	dd($news);

    return view('news.index', ['articles' => $news]);
  }

Activity icon

Replied to Accessing Path Function In Model In Index File

if you dump $news are you sure they all have a slug? What you have should work provided all articles in the loop have an id and slug.

public function index() {
    $news = News::latest()->get();
	dd($news);

    return view('news.index', ['articles' => $news]);
  }

Activity icon

Replied to Query Where Date_format() Issue

do your query as normal and set the format on your output:


$model = YourModel::all();

$formattedDate = \Carbon\Carbon::parse($model->created_at)->format('Y m d');//any format you watn

Mar
24
2 weeks ago
Activity icon

Awarded Best Reply on Setting Up Project With Domain Name Locally

Did you restart Apache?

Activity icon

Replied to Setting Up Project With Domain Name Locally

Did you restart Apache?

Activity icon

Awarded Best Reply on How To Add Product Color In Right Way

This is beyond the scope of a simple forum question - you need a full tutorial unless you are just asking for a general method, which would basically be...

  1. if your select dropdown is populated from your database, make sure to include the hex code when sending it to your view
  2. use radio buttons instead of a select dropdown
  3. use css and js to replace the default radio button with a circle and set each colour to match the hex code.

Use something like this to create your radio styling - add border-radius: 50%; on the label span to make them circles https://codepen.io/wildbeard/pen/eZZPZr

I'm assuming you are trying to do something like this:

https://i.pinimg.com/originals/ce/fe/c0/cefec04405d1810f566a1eeff44b850c.png

Activity icon

Replied to How To Add Product Color In Right Way

This is beyond the scope of a simple forum question - you need a full tutorial unless you are just asking for a general method, which would basically be...

  1. if your select dropdown is populated from your database, make sure to include the hex code when sending it to your view
  2. use radio buttons instead of a select dropdown
  3. use css and js to replace the default radio button with a circle and set each colour to match the hex code.

Use something like this to create your radio styling - add border-radius: 50%; on the label span to make them circles https://codepen.io/wildbeard/pen/eZZPZr

I'm assuming you are trying to do something like this:

https://i.pinimg.com/originals/ce/fe/c0/cefec04405d1810f566a1eeff44b850c.png

Activity icon

Started a new Conversation Users Email Field Nullable

For reasons I won't go into, I have had to make the email column on the users table nullable. My question is, is this still safe if there are rows of 'users' with email and password both set as null (which should never be able to login - dead user accounts basically).

I feel the validation wouldn't let me login without an email and at least some sort of string for a password but just wanted some reassurance on this one if anyone is 100% sure it is still safe

Thanks

Activity icon

Awarded Best Reply on How To Make A Variable Keep Existing In The Same View?

That is how variables and views work.

Do you mean you want to create a session variable to store a dynamically generated value?

// store the value
request()->session()->put('key', 'value');

$view_variable = request()->session()->get('key');

Activity icon

Replied to How To Make A Variable Keep Existing In The Same View?

That is how variables and views work.

Do you mean you want to create a session variable to store a dynamically generated value?

// store the value
request()->session()->put('key', 'value');

$view_variable = request()->session()->get('key');

Activity icon

Replied to Download Wont Start

if your route calls a method which doesn't return anything it just simply won't return anything other than a white screen - it will still process stuff, just never actually present it to the user (unless the download is directly within the same method - calling it from a different method is the issue).

You probably don't need to return there...if you return a view after your if statement it might present the download along with that view

Activity icon

Replied to How To Get Eloquent Query Between 2 Dates Including Time

No need for the subquery + your < and > were the wrong way round:

$now = Carbon::now('Asia/Kolkata')->toDateTimeString();
$qry = Posts::where('status', 'live')
	->where('start', '<=', $now )
	->where('expiry', '>=', $now)
         ->get();

That should work although in your example assuming 12:01am is start and 11:59pm is expiry. Also, are you db dates datetime?

Activity icon

Awarded Best Reply on Download Wont Start

ok, maybe it is because you aren't returning it:


if ('apotek' == $data['txtCabang']) {
            return self::exportApotek($begin, $end, '5044', 'AP5044');
        } else {
            return self::exportDokter($begin, $end, '5135', 'PK5135');
        }

Activity icon

Replied to Download Wont Start

ok, maybe it is because you aren't returning it:


if ('apotek' == $data['txtCabang']) {
            return self::exportApotek($begin, $end, '5044', 'AP5044');
        } else {
            return self::exportDokter($begin, $end, '5135', 'PK5135');
        }

Mar
23
2 weeks ago
Activity icon

Replied to Search In Nested Relationships

Why not just wrap the whole thing in an if statement?


if( strlen($search) > 0 ){

	//your query

}else{

	$posts = 'no posts';

}


Activity icon

Awarded Best Reply on Can't Set A Cookie To TRUE Or FALSE?

Yes, you can't set a php cookie value as true or false. False would delete the cookie. 1 or 0 as a string is correct behaviour. If you MUST pass a boolean value, handle it like this...

    Cookie::queue(Cookie::forever(request()->name, request()->value ? '1' : '0'));
Activity icon

Replied to Can't Set A Cookie To TRUE Or FALSE?

Yes, you can't set a php cookie value as true or false. False would delete the cookie. 1 or 0 as a string is correct behaviour. If you MUST pass a boolean value, handle it like this...

    Cookie::queue(Cookie::forever(request()->name, request()->value ? '1' : '0'));
Activity icon

Replied to Search In Nested Relationships

Sorry, I still don't understand what you mean

Activity icon

Replied to Can't Set A Cookie To TRUE Or FALSE?

That should work so it must be how you are passing the values from your ajax to your cookie function - can you share more code?

Activity icon

Replied to Search In Nested Relationships

This seems like a new issue so possibly best starting a new thread with full explanation. Not sure exactly what you mean with this one but the second code block looks wrong and should probably be...

$q->whereHas('comments', function ( $q ) use($search, $sort){
                        $q->where('content',  'like', '%'.$search.'%' );
                        if($sort == 'answered'){
                            $q->where('answered', '=', 1);
                        }
                        if($sort == 'new'){
                            $q->where('answered', '=', 0);
                        }
                })

Activity icon

Awarded Best Reply on JSON

This will base it off the headers so if that is ok (i.e. content type is application/json)...

if(request()->isJson()){
	//it is json, continue
}

Activity icon

Replied to JSON

This will base it off the headers so if that is ok (i.e. content type is application/json)...

if(request()->isJson()){
	//it is json, continue
}