pickab00

Experience

5,910

0 Best Reply Awards

  • Member Since 9 Months Ago
  • 1 Lesson Completed
  • 0 Favorites

21st September, 2018

pickab00 left a reply on Live Server Variable = Int Not Working • 1 day ago

It is available and enabled

pickab00 left a reply on Live Server Variable = Int Not Working • 1 day ago

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 • 1 day ago

@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 • 1 day ago

@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 • 1 day ago

@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 • 1 day ago

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.

11th August, 2018

pickab00 left a reply on Dynamic Menu Class "Active" • 1 month ago

@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" • 1 month ago

@Snapey already tried that. Does not work.

pickab00 started a new conversation Dynamic Menu Class "Active" • 1 month ago

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?

7th August, 2018

pickab00 left a reply on Difference Between URL Refresh And Refresh Button • 1 month ago

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 • 1 month ago

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 • 1 month ago

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 • 1 month ago

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 • 1 month ago

@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 • 1 month ago

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?

6th August, 2018

pickab00 left a reply on OrderBy Relationship With Latest()? • 1 month ago

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

pickab00 left a reply on OrderBy Relationship With Latest()? • 1 month ago

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

pickab00 left a reply on OrderBy Relationship With Latest()? • 1 month ago

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()? • 1 month ago

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()? • 1 month ago

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

pickab00 started a new conversation OrderBy Relationship With Latest()? • 1 month ago

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 • 1 month ago

Lol sorry. I need sleep! Thanks mate!

pickab00 left a reply on Pivot Table Not Working As Intended • 1 month ago

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 • 1 month ago

@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 • 1 month ago

@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 • 1 month ago

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?

pickab00 left a reply on Search Function Does Not Work On The Search Result Page • 1 month ago

@komalbhatt I am not passing any parameters to the route. I am just simply doing a query with no parameter. The only thing I am getting is request from form. Could you please elaborate your answer? I could not understand.

5th August, 2018

pickab00 started a new conversation Search Function Does Not Work On The Search Result Page • 1 month ago

After searching, it goes to the result page. In my case:

Route::post('/search', 'Frontend\[email protected]');

To that post page. In that page, there is the same search form as in every other page. Every other page search filtering works fine with no issues. But when I try to search from the result page, I have to select all the fields in order for the search to filter the result. In other pages, I do not have to select all the fields. Here is my controller:

    public function filterSearch(Request $request){

    //imports
    $categories = Category::all();
    $languages = Language::all();
    $years = Year::all();

    //partials menu variable
    $menu = Menu::all();

    $movie = Movie::query();

    // Search for a movie based on its name.
    if ($request->name != null) {
        $movie->where('name', 'LIKE', '%' . $request->name . '%');
    }

    // Search for a movie based on the year.
    if ($request->year != null) {
        $movie->where('year_id', '=', $request->year);
    }

    // Search for a movie based on the language.
    if ($request->language != null) {
        $movie->where('language_id', '=', $request->language );
    }

    // Search for a movie based on the review.
    if ($request->review != null) {
        $movie->where('review', 'LIKE', '%' . $request->review . '%');
    }

    // Get the results and return them.
    $filtered = $movie->latest()->paginate(20);

    //return $request->language;
    return view('frontend/search/filter-search', compact('filtered', 'menu', 'categories', 'languages', 'years'));


}

Here, if I search using the name 'the' and only the year while leaving the language blank, the search works as intended. But on the results page, if I do the same, it gives me no results unless I have all the fields filled. Including the language.

pickab00 left a reply on Search Filter Returns Null • 1 month ago

@Cronix That was the issue all along. Many thanks! Stupidity on my side :D

pickab00 left a reply on Search Filter Returns Null • 1 month ago

@Cronix Still blank. Return is null. I am not passing anything to the route. I am just trying to ask laravel to filter out from Movie model where name and review is equal to their respective values from the form.

pickab00 started a new conversation Search Filter Returns Null • 1 month ago

So I have an 'Advance' Search feature and here is my implementation.

public function filterSearch(Request $request, Movie $movie){

    $movie = $movie->newQuery();

    // Search for a movie based on its name.
    if ($request->has('name')) {
        $movie->where('name', '=', $request->input('name'));
    }

    // Search for a movie based on the review.
    if ($request->has('review')) {
        $movie->where('review', '=', $request->input('review'));
    }

    // Get the results and return them.
    return $movie->get();


}

But I am getting a null Array. Here is the route:

Route::post('/search', 'Frontend\[email protected]');

I am getting null with or without anything being entered. What am I doing wring here?

4th August, 2018

pickab00 left a reply on How To Get Img Src From Blade To Controller • 1 month ago

@Tray2 Thanks this helped me a lot. Finally made it working!

pickab00 left a reply on How To Get Img Src From Blade To Controller • 1 month ago

So what do I do from there? Sorry I am not so experienced with ajax or jquery

pickab00 started a new conversation How To Get Img Src From Blade To Controller • 1 month ago

So what I want to achieve is to get the src attribute from my blade to controller. So if src=images/something.png, then I want to be able to take that src value to the controller. How is this possible?

3rd August, 2018

pickab00 started a new conversation How To Use JSON Data With Select2 In Laravel • 1 month ago

So I want to be able to add the select2 data to database. This is simple and I have it working. But the problem is here. I want to be able to auto add the (lets call it tags) tags if it exists. Let me explain. Here is my controller:

$insert->tags()->sync($request->tags, false);

This is my current workings here. What it does is takes the select2's selected data and enters it on a table called movie_tag. This is a many to many relationship. Here is a JSON result I am taking:

"genre": "",

So now How can I tell Laravel to add the tags (by its id of course) with the movie id just added if the above JSON matches what is inside the tags table? Here is an example of what I am using to get the JSON:

$result['genre']
//result = Horror, Thriller

So how can I take those two, check if they exist in tags table and if they do, enter them in to the movie_tag table and else do not add it?

2nd August, 2018

pickab00 started a new conversation Image Intervention Textbox Resize • 1 month ago

So I am using Image Intervention In my laravel Project and here is my issue. The code:

$img = Image::make('foo.jpg');

    $img->text($ascii, 200, 200, function($font) {
        $font->file(public_path('a_waheed.ttf'));
        $font->size(24);
        $font->color('#fdf6e3');
        $font->align('center');
        $font->valign('top');
    });

    $img->save('download.png');

The $ascii is a modified string value from another language (reason being this does not support RTL and had some rendering issues so had to convert to ascii).

Now how can I set the box Size? The text just keeps on going with no end and out of bound. Couldn't find anything mentioned on Intervention or Image GD. Or maybe it might have slipped.

28th July, 2018

pickab00 left a reply on Change Image Intervention Direction To RTL • 1 month ago

@sammu please check my updated question. It most probably has something to do with encoding.

pickab00 left a reply on $request->ip() Returns 127.0.0.1 • 1 month ago

@martinbean I did use proxy all but it does not seem to be working.

pickab00 left a reply on $request->ip() Returns 127.0.0.1 • 1 month ago

Yeah I asked this because the stack overflow answer said that the throttle uses the Request->ip() as well. That is why I wanted to know if it would effect any other components.

pickab00 left a reply on $request->ip() Returns 127.0.0.1 • 1 month ago

That I get but. What about the stackoverflow answer linked above? What are the drawbacks of using a custom code inside of the Illuminate\Http\Request.php in laravel?

pickab00 left a reply on $request->ip() Returns 127.0.0.1 • 1 month ago

@m7vm7v Really sorry I was looking at the wrong thing. Your suggestion worked.

@Cronix Why won't fidelopers proxy work? I set the proxy to all and yet still it wouldn't work. Also about the above method, what are the drawbacks of this method? And is it safe? And will I have to change it to default if I migrate to some other server/hosting or such?

pickab00 left a reply on $request->ip() Returns 127.0.0.1 • 1 month ago

@m7vm7v Unfortunately this does not return anything. It is returning nothing.

pickab00 started a new conversation $request->ip() Returns 127.0.0.1 • 1 month ago

I am on laravel 5.6 and I am using Cloudways free 3 day trail to test my app. The thing is my code returns 127.0.0.1 but not the real client IP Address. Here is my controller:

$article->ip = $request->ip();

This returns 127.0.0.1 every time even though it is on a live server.

I also tried:

$article->ip = $request->getClientIp();

Which is basically the same as above. Can't think of anyway why this wouldn't work.

26th July, 2018

pickab00 left a reply on Suggestion: Will This Method Make A Difference? • 1 month ago

True. Either way the end result will leave the system being spammed

pickab00 left a reply on Suggestion: Will This Method Make A Difference? • 1 month ago

A person would hit the like button for a post. If i say not to accept anymore likes from this ip for this post and if the persons friend decides to like the same post using his device, it wont accept it would it? Because that would be the same ip from the same network. IP as in the public ip. Taking the machine IP is just plain stupid.

pickab00 left a reply on Suggestion: Will This Method Make A Difference? • 1 month ago

@cmdobueno True. I don’t want to drag this post along but using IP meaning all the devices on the same network can like one post. So basically what i am saying is that if this post has a like from this current IP, then this IP can no longer like this post. But what about multiple devices on the IP?

pickab00 left a reply on Suggestion: Will This Method Make A Difference? • 1 month ago

I know that too. But have a look at the website above. That one makes no sense to me. As it is making ajax requests but does not update the view.

pickab00 left a reply on Suggestion: Will This Method Make A Difference? • 1 month ago

@Cronix True. But I was thinking more of a user experience point. I would not want to login to like a magazines post or to comment on it (Comment is a different story).

pickab00 left a reply on Suggestion: Will This Method Make A Difference? • 1 month ago

Nicely done. One last question which confused me. In the example given on the evercookie site i saw this code.

ec.set("id", "12345");

Here it’s calling evercookie to create a nee cookie. I was wondering how I’d call this in laravel. I mean If I leave it stranded on html or js file, would it be wrong?

So basically just add fingerprint as the cookie value if cookie does not exist? And if the cookie does exist, then start the action insert of likes/dislikes. But if a like exist on a post which has the same cookie value as the current cookie, then stop stroring because it exists. Also throttle to 2 requests per minute. Am I on the right track?

I’d have accepted the answer but currently I’m on mobile. That answers my question but this is the last question above. Is it safe to set the cookie inside of js file or plain html? Because anyone can access and modify it right?

pickab00 left a reply on Suggestion: Will This Method Make A Difference? • 1 month ago

So your suggestion would be to use evercookie? Or should i stick with fingerprinting? If you were to choose between fingerprinting and evercookie, what would your recommendation be?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.