pickab00

pickab00

Member Since 1 Year Ago

Experience Points 6,530
Experience
Level
Lessons Completed 2
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

04 Nov
1 month ago

pickab00 started a new conversation Mailgun Authentication Error On Live Server

Last night I was testing my laravel app on local development with the same settings. env is setup correctly and there seem to be no issue on local development on my PC. And I pushed the same thing this morning to the server. Nothing has changed and the env is as it is. But I am getting this error:

Failed to authenticate on SMTP server with username "[email protected]" using 2 possible authenticators. Authenticator LOGIN returned Swift_TransportExcep ▶

" in /home/mywebsite/mysite/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457

The same thing still works on my local development.

03 Nov
1 month ago

pickab00 started a new conversation Change Login/Register Redirect Path

So I did change it from /home to /portal. I changed it here:

protected function authenticated(Request $request, $user)
    {
        return redirect('/portal');
    }

And for register, here:

return $this->registered($request, $user)
                        ?: redirect('/portal');

For some reason, this does not work for me:

protected $redirectTo = '/portal';

And now the thing is, When I login/register, it redirects me to /portal just fine. But when I am logged in and if I type /login or /register on the URL bar, it redirects me to /home. I am not able to find where this is exactly happening. And an explanation would be greatly appreciated!

02 Nov
1 month ago

pickab00 left a reply on Is Editing Auth/RegisterController.php Wrong?

I see. This helped a lot. Thanks!

pickab00 left a reply on Is Editing Auth/RegisterController.php Wrong?

Shoot I completely forgot about $fillable. I am more used to using save() in most cases and a lot less create(). Thanks!

pickab00 started a new conversation Is Editing Auth/RegisterController.php Wrong?

Well the breakdown of this question is this.

I was having an issue where I was not able to add anything else but 'name', 'email', 'password'. I tried to add 'mobile'. The diedump does display the value being passed. But it is not being inserted to the database.

So I changed this:

protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'mobile' => $data['mobile'], //This does not work!
            'password' => bcrypt($data['password']),
        ]);
    }

to this:

protected function register(Request $request){

          $register = new User;

          $register->name = $request->name;
          $register->email = $request->email;
          $register->mobile = $request->mobile;
          $register->password = bcrypt($request->password);

          $register->save();

      }

As the routes point to Auth/[email protected] I decided to test this. Please bare in mind that I did this to see if I was doing something wrong somewhere. So is it wrong to use this instead of the laravel way? And most importantly, why isn't mobile being passed to db? It is stored in the $data array for sure but it does not hit the db.

29 Oct
1 month ago

pickab00 left a reply on Updating All Previous Posts With Specific Field Being = 1

@neilherbertuk Thanks a bunch! It never occoured to me to use reject. And yes I will keep in mind to use timestamps. You are right to be honest. I would want to know in the future what was featured and what was not.

Again, Thanks! Good day!

pickab00 started a new conversation Updating All Previous Posts With Specific Field Being = 1

Ok I honestly did not know what to type as the question title. Here is whats going on.

I have a column in my posts table "featured". It is a boolean. The result is either true or false. So a post can be featured or not. The problem is that when I display these posts, there is a specific area for featured posts to appear and I am taking 3 latest featured posts. Something like so:

$post = Post::where('featured', '1')->take(3)->latest()->get(); //something like so

The problem is that I have marked 5 of my posts as featured. The archive section on the page takes from the posts table but ignores the featured items. So I still have 2 items which are ignored by the archive and which is not being displayed on featured (as the limit for featured is 3). So my question is, how can I tell laravel to set all posts which is having featured as 1, to set them to 0 if they are not the ones currently being displayed. Every post other than the current latest 3 featured posts which are taken from db. Because currently this is being done manually. I have to go and remove them manually by going to edit post and unticking "featured" box. Should the updating process be done on the above code or when I am adding a new "featured" item? Hope this makes sense.

22 Oct
1 month ago

pickab00 left a reply on Difference Between Logout POST And GET Method

Yes. All the above questions has been answered. On mobile. Will accept once logged in from pc.

pickab00 left a reply on Difference Between Logout POST And GET Method

Ok thanks for the suggestion.

pickab00 left a reply on Difference Between Logout POST And GET Method

If i go to example.com/logout, without being logged in and just going to that url gives me 405 method not allowed. There is no sessiok to end basically. I’m just typing /logout on the url and giving me 405.

pickab00 left a reply on Difference Between Logout POST And GET Method

@Cronix Yeah forgot about that. So what about the method not allowed? How can I not get method not allowed on blank /logout form post?

pickab00 started a new conversation Difference Between Logout POST And GET Method

So I am aware that laravel had GET method for logout until the release of 5.3. Of course we can still use the GET method though the default scaffold creates a form with a POST method. What I want to know is what is the better way? What are the flaws of using GET and Advantages of using POST.

Also, If I write domain.com/logout, It gives me the good old MethodNotAllowed error. And We know why. That is why I wanted to change to GET method but I want to know the difference between having the POST and GET method.

pickab00 left a reply on Remove Password Reset Routes/Methods

@kvithalani that is correct. Not that there is anything wrong with overriding the methods. But it is always simpler and saves a lot of time rather than going after each of the method. Thanks again! Did not see that. Was this updated? As far as I know, the full routes were used on web.php after you intiate the login scalfold correct? Did laravel update this to be inside of route.php at any point? Or am I just tripping and it has always been in route.php?

pickab00 left a reply on Remove Password Reset Routes/Methods

@kvithalani in that case, it is better to not override any methods from any files and just comment out the route in web.php correct?

@bobbybouwmann thanks. But it is a bit wierd that they put those routes in route.pho. Just my opinion.

21 Oct
1 month ago

pickab00 started a new conversation Remove Password Reset Routes/Methods

In my laravel App, I have configured multiauth. And I wanted to remove the default auth. I have overridden the register method and login method. As well as the password reset method which is responsible for showing the forms. The links /login, /home, /register & password/reset does not work. This was of course as intended. But however, /password/email does work and gives me method not allowed error. Now I am aware of why it is posting the error. My question is, how can I abort this to 404 like the others mentioned above? And where are the routes located? Did they remove the routes as of 5.5? I am on 5.6.

25 Sep
2 months ago

pickab00 left a reply on Difference Between !== & !=

I drifted off. Edited. This has been resolved. So many times by so many people. RESOLVED!

pickab00 left a reply on Difference Between !== & !=

Yes @Snapey that is what I was trying to say since last night! I just wanted to confirm this. Perhaps my SQL Native Driver needs to be enabled and updated. Anyways. Thanks guys!

pickab00 left a reply on Difference Between !== & !=

Yes it must have been a typo on his side.

It has indeed gone wrong xD. I just wanted to confirm that my OP was correct. And look where it got us xD

pickab00 left a reply on Difference Between !== & !=

@Snapey My server does not except this. 4 !== 5 returns false because of the type difference. I am on laravel 5.6, PHP 7.2.10. The only difference is that I have my MySQL Native Driver disabled. So if I am taking a value from db and comparing it with some other value like the example above, it returns false. But 4 != 5 returns true.

I think It has to do with MySQLnd

24 Sep
2 months ago

pickab00 left a reply on Difference Between !== & !=

I’m not sure what to mark. I kind of explained it on the OP too

pickab00 left a reply on Difference Between !== & !=

Guys I’m so sorry. That was a typo. I meant !==.

@Snapey 4 !== 5 will return false won’t it? But 4 != 5 will return true. Because of the type difference. 4 is not equal to 5 is correct. But also it is false because int is equal to int. Hope I am making sense here. 4 !== 5. Both are integers. However 4 !== “5” is true. “5” is a string. So they are not equal in anyway.

@jlrdw Yes it was a typo and you are absolutely correct.

@Cronix Yes it was a typo. It is !== and !=

So to wrap things up, !== is same as === and != is the equivalent of ==. !== will return true only if the baluws AND types are different. Where as != will be true if the value is different and does not care about the types (int, string etc)

pickab00 left a reply on Difference Between !== & !=

Yes that is what I said above. Basically if it was a string and an int, it will be true. But in this case they both are int's. 5 !== 4 is false. But 5 !== "4" is true because the types is not equal to each other.

pickab00 started a new conversation Difference Between !== & !=

So I recently encountered an error with when I had !===, it returns to true. Say for an example, if 4 !== 5 it becomes false on my live server. But If I use just != it works as intended.

Does !== mean that the type should also not match? I mean an Int and a String. Where as for !=, it matters only for the value and it does not care about the type. Am I on the right page?

So what is the difference? Also I should note that !== works perfect on my local development.

21 Sep
2 months ago

pickab00 left a reply on Live Server Variable = Int Not Working

It is available and enabled

pickab00 left a reply on Live Server Variable = Int Not Working

Ok so that solves it. === is checking for both values and types. My output from query is coming as a string. The problem is solved for now. It slipped my mind. Thanks for the help. Though I want to get to the bottom of why a string is being output. I'll have an in-depth look at this and SQL as well. I am accepting the answer for now. Shall I continue this thread if I find something useful?

pickab00 left a reply on Live Server Variable = Int Not Working

@tykus This does not help either. The same issue comes. I did cast it as a bool and even changed the type to bool. Yet the error persists. The thing is, If I were to make changes, then there is a lot of places I need to make this change on.

pickab00 left a reply on Live Server Variable = Int Not Working

@tykus Value of $var is indeed a query. That was a sample code. Here is what I am doing.

@if($authGalleries->approved === 1) YES @else NO @endif

$authGalleries in controller:

$authGallery = Gallery::with('admin')->with('images')->where('lang', '=', '1')->where('admin_id', '=', $auth)->latest()->get();

$auth is the current authenticated user. That's the whole thing. I have always noticed that If I used two digit int's, I have to use quotes. But not with single int values like 1. But in this case, my live server laravel (same thing) demands it to be inside quotes?

pickab00 left a reply on Live Server Variable = Int Not Working

@Galavant My development server php version is 7.2.8 while my live server is at 7.2.10. That can't be the issue here can it?

pickab00 started a new conversation Live Server Variable = Int Not Working

So I have a if statement on my blade which looks something like this.

@if($var === 1) YES @else NO @endif

This works on my local development. But It displays NO to all on my live server with the same code. But If I change the 1 to '1' it works. How come this is happening.

P.S I still have my env set as local still.

11 Aug
4 months ago

pickab00 left a reply on Dynamic Menu Class "Active"

@Snapey This is what I finally tried.

<li class="{{ active(['home/'.$menus->link, 'home/'.$menus->link.'/*']) }}"><a href="/dv/{{$menus->link}}">{{$menus->name}}</a></li>

This works. So basically What I am Saying is that take the category routes and all the subcategory routes as well. From the watson active docs, I could have simply passed an array of named routes or simply routes and that is what I tried.

Thanks a bunch for the help!

pickab00 left a reply on Dynamic Menu Class "Active"

@Snapey already tried that. Does not work.

pickab00 started a new conversation Dynamic Menu Class "Active"

I have a dynamic menu which is being taken from a table. categories is the table and the relational table is subcategories. So category has many subcategories. It is a hasMany relationship. Also the menu is inside a partial file. Here is what I have in my controller for the $menu variable.

$menu = Category::with('subcategories')->get();

And my partials file.

@foreach($menu as $menus)
        <li><a href="/dv/{{$menus->link}}">{{$menus->name}}</a></li>
    @endforeach 

Here is how my route looks like.

Route::prefix('home')->group(function() {

Route::get('{link}', 'Front\Dhiv\[email protected]')->name('pages.category');
Route::get('{link}/{sub}', 'Front\Dhiv\[email protected]')->name('pages.subcategory');

});

I have used https://github.com/dwightwatson/active package with no luck. What are my options to add active with the current setup?

07 Aug
4 months ago

pickab00 left a reply on Difference Between URL Refresh And Refresh Button

Yap removed that part. Still on the whole "passing parameter" thing. Meaning /search/what+ever+here kinda thing. But yeah this works the same way and like you mentioned, SEO approved (they really need to come up with emojis) thumbs up

All jokes aside, Thank you!

pickab00 left a reply on Difference Between URL Refresh And Refresh Button

Here is the updated Route:

Route::get('/search', 'Main\[email protected]');

Form:

{!! Form::open(['method' => 'GET', 'action' => 'Main\[email protected]']) !!}
<input type="text" id="search-input" name="search" class="form-control front-search" placeholder=" Search...">
{!! Form::close() !!}

Result (URL):

http://experimental.io/search?search=this+is+my+search

This works great! Is there any way I could cleanup the url?

pickab00 left a reply on Difference Between URL Refresh And Refresh Button

That I am always good at doing.

I was actually looking for an alternative other than to display the action, method and other stuff and just completely use js, jquery, ajax etc... My application currently is based off of almost completely ajax and I wanted actually be able to use js for this one. Will using the above method be recommended or should I do this the simple way and save the hustle?

pickab00 left a reply on Difference Between URL Refresh And Refresh Button

Yes that is the second parameter which is suppose to be the input of search. Here is what I had in mind (If I were to use JS). Doing something like this (Not tested):

var query $('#form #search').val();
var submit $('#form #submit');

submit.click(function(e){

e.preventDefault();

    window.location('/search/'+);

});

And so now my form can be something like this:

<form id="form">
<input type="text" id="search" " class="form-control front-search thaanaKeyboard" placeholder=" Search...">
<input type="submit" id="submit" value="Search">
</form>

pickab00 left a reply on Difference Between URL Refresh And Refresh Button

@tykus This is what I had in mind:

Route::match(['get', 'post'], '/search/{search}', 'Front\Dhiv\[email protected]');

So in my html I am doing something similar to this:

{!! Form::open(['method' => 'POST', 'action' => ['Front\Dhiv\[email protected]', 'you shall not pass']]) !!}
                <input type="text" name="search" class="form-control front-search" placeholder="Search...">
                {!! Form::close() !!}

So my question now is, How would I pass the second parameter for the search. Should I use JS to just take the input value and put it in there? Or is there a right Laravel/PHP way?

pickab00 started a new conversation Difference Between URL Refresh And Refresh Button

I am currently doing a simple search query with laravel and I was wondering the difference between hitting the reload button and actually refreshing by clicking URL bar and hitting return button. Here is what I've done.

Route::match(['get', 'post'], '/search', 'Main\[email protected]');

I am not passing any parameters or such. I am aware that with the current setup, the reload button would do a GET request. This is why I've used match in this situation. I get the current searched results just fine. But if I go on to the URL bar and hit the return button, it gives me all the posts. It is obvious that as there is no set parameter given to search for, and when GET method is used, it just displays all the available data. Now how can I resolve this? Do I 'have' to pass in the search input's data to the route in order for this to not happen?

Whats the best bet here?

06 Aug
4 months ago

pickab00 left a reply on OrderBy Relationship With Latest()?

Lol. Everybody gets a piece of the pie. Isn’t that ideal. Anyways. Thanks?

pickab00 left a reply on OrderBy Relationship With Latest()?

Lol. Anyways. Not sure at this point whos answer I should tick as solved.

pickab00 left a reply on OrderBy Relationship With Latest()?

Thanks. I will keep that in mind. And yes. I do agree the year should not be on a separate table and related to movies. That is completely wrong. I had a separate year column in my movies table previously. Removed it later because the client wanted the ability to add the years.

pickab00 left a reply on OrderBy Relationship With Latest()?

Thats one solution. What about join? Would that work? Just curious and as a last resort. Will join work? And then run the query I want?

pickab00 left a reply on OrderBy Relationship With Latest()?

Yeah that is true. But in this case, what are my options?

pickab00 started a new conversation OrderBy Relationship With Latest()?

So I have a relationship table called years which is related to movies. movies belongs to year. year has many movies. That is the basis. Here is my controller:

$moviesLatest = Movie::with('tags')->where('category_id', '=', '1')->where('active', '=', '1')->take(12)->get();

movies table has a column named year_id. Now from the above code, How would I say "take the movies where relationship year is in descending order, but at the same time display latest movies from that descending order"?

This is what I've tried so far. 1:

$moviesLatest = Movie::with('tags')->where('category_id', '=', '1')->where('active', '=', '1')->with(['year' => function($q) {
        $q->orderBy('year', 'desc');
    }])->take(12)->latest()->get();

2:

$moviesLatest = Movie::with('tags')->where('category_id', '=', '1')->where('active', '=', '1')->whereHas('year', function ($q){
        $q->orderBy('year', 'desc');
    })->take(12)->latest()->get();

This does not seem to work. What is the right way?

pickab00 left a reply on Pivot Table Not Working As Intended

Lol sorry. I need sleep! Thanks mate!

pickab00 left a reply on Pivot Table Not Working As Intended

But how would I take just the value tag (this being the name column)

pickab00 left a reply on Search Function Does Not Work On The Search Result Page

@newbie360 lol! You were right. I forgot to update the template for form. Thanks mate!

pickab00 left a reply on Pivot Table Not Working As Intended

@Tray2 This is what I am trying to do. I am trying to get the tags name as array and put that array inside of this:

$related = Movie::whereHas('tags', function ($q) use($movie){
        $q->whereIn('tag', '=', //Here is the tags name arary);
    })->get();

pickab00 started a new conversation Pivot Table Not Working As Intended

I have a pivot table which stores tag_id and movie_id from tags and movies table. When I try to output related tags of a specific movie, I get the array result just fine.

$movie = Movie::with('tags')->findOrFail($movie_id);

return $movie->tags;

And the result:

[

{ "id": 16, "admin_id": 1, "tag": "Drama", "bgcolor": "#28ABE3", "deleted_at": null, "created_at": "2018-08-04 14:40:59", "updated_at": "2018-08-04 14:40:59", "pivot": { "movie_id": 29, "tag_id": 16 } }, { "id": 24, "admin_id": 1, "tag": "Mystery", "bgcolor": "#FFC33C", "deleted_at": null, "created_at": "2018-08-04 14:41:36", "updated_at": "2018-08-04 14:41:36", "pivot": { "movie_id": 29, "tag_id": 24 } }, { "id": 30, "admin_id": 1, "tag": "Thriller", "bgcolor": "#F05B47", "deleted_at": null, "created_at": "2018-08-04 14:42:00", "updated_at": "2018-08-04 14:42:00", "pivot": { "movie_id": 29, "tag_id": 30 } } ]

Now I can't do return $movie->tags->tag; so what I did was this.

foreach($movie->tags as $tags){
        return $tags;
    }
//Which allows me to do return $tags->tag;

But this returns only the first one. What am I doing wrong? I am iterating the collection tags right? But it displays just the firs occurrence?