jlrdw

jlrdw

Member Since 5 Years Ago

Experience Points
559,330
Total
Experience

0 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
192
Lessons
Completed
Best Reply Awards
632
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 50
559,330 XP
Aug
09
23 hours ago
Activity icon

Awarded Best Reply on Multi Parameter In Search 'GET'

Append the parameters to pagination links:

From docs:

Appending To Pagination Links

You may append to the query string of pagination links using the appends method. For example, to append sort=votes to each pagination link, you should make the following call to appends:

{{ $users->appends(['sort' => 'votes'])->links() }}

If you wish to append all current query string values to the pagination links you may use the withQueryString method:

{{ $users->withQueryString()->links() }}

Also try moving your paginate to just before return view:

$product->paginate(10);

Example:

       $query = Dog::where('dogname', 'like', $dogsch);
        if ($aval == "n") {
            $query->where('adopted', '=', 1);
        } else if ($aval == "y") {
            $query->where('adopted', '=', 0);
        }
        $dogs = $query->orderBy('lastedit', 'DESC')->paginate(5);

       $params = array('psch' => $dogsearch, 'aval' => $aval);

And view:

{{ $dogs->appends($params)->links() }} 
Activity icon

Replied to Instantiate Laravel Model Referenced By String

Okay, I missed that.

Activity icon

Replied to Multi Parameter In Search 'GET'

Just like I did here:

        if ($aval == "n") {
            $query->where('adopted', '=', 1);
        } else if ($aval == "y") {
            $query->where('adopted', '=', 0);
        }

You have to work it out in some if statements while building up the query.

First pass is a post from a search form, all other passes is a get request.

Aren't you retrieving the parameters from the request, if not, use the network tab in your browser developer tools and see what request and response you are getting.

Did you move paginate, it can go last after all other parts are built up.

And example:

        If (!empty(Request::input('psch'))) {
            $dogsearch = Request::input('psch');
        } else {
            $dogsearch = "";
        }


In your case check for null, and you can use a ternary if also.

public function search(Request $request)
    {
        $query = Products::select('id', 'cats_id', 'brands_id', 'name_ar', 'admins_id')
            ->with('admins:id,name')
            ->with('cats:id,cats_name_ar')
            ->with('brands:id,brands_name_ar');
        if ($request->s !== null) {
            $query->where('name_ar', 'LIKE', "%{$request->s}%");
        }
        if ($request->discount == '1') {
            $query->where('discount', '!=', null);
        }
	$product = $query->paginate(10);
	
	// if sending parameters as array
	$params = [your params array];
	return view('admin.product.indexproduct', compact('product', 'params'));  // if sending params
        return view('admin.product.indexproduct', compact('product'));  //if not sending params
    }


Activity icon

Replied to Multi Parameter In Search 'GET'

Append the parameters to pagination links:

From docs:

Appending To Pagination Links

You may append to the query string of pagination links using the appends method. For example, to append sort=votes to each pagination link, you should make the following call to appends:

{{ $users->appends(['sort' => 'votes'])->links() }}

If you wish to append all current query string values to the pagination links you may use the withQueryString method:

{{ $users->withQueryString()->links() }}

Also try moving your paginate to just before return view:

$product->paginate(10);

Example:

       $query = Dog::where('dogname', 'like', $dogsch);
        if ($aval == "n") {
            $query->where('adopted', '=', 1);
        } else if ($aval == "y") {
            $query->where('adopted', '=', 0);
        }
        $dogs = $query->orderBy('lastedit', 'DESC')->paginate(5);

       $params = array('psch' => $dogsearch, 'aval' => $aval);

And view:

{{ $dogs->appends($params)->links() }} 
Activity icon

Replied to Data Cannot Be Shown With Wherebetween

First, have your dates in the correct format, meaning:

2020-09-08

for use in a query. Is that the format you are sending to the query.

Activity icon

Replied to Laravel Got Stuck After Login. Laravel 5.8

I just logged in, in chrome, but I use the authenticated method from the trait.

    public function authenticated(Request $request, $user)
    {
        
        $role = $user->role;
        $checkrole = explode(',', $role);
        if (in_array('admin', $checkrole)) {
            return redirect('admin/index');
            
        } else {
            return redirect('pet/index');
        }
    }

What happens if nothing is modified, and you only use the out of the box authentication, then can you login in Chrome?

Activity icon

Replied to Is Currently Unable To Handle This Request. On Form Post Submit

You should consider at least some sanitizing on raw post:

    $log_email = trim($_POST['log_email']);    // sanitize these with strip_tags
    $log_password = trim($_POST['log_password']);

Have you checked to make sure session is being written?

Activity icon

Replied to Laravel Got Stuck After Login. Laravel 5.8

I have not had to modify any out of the box middleware, I use the trait for redirects. Never had a problem with out of box Auth.

Activity icon

Replied to Loading On Submit

What JS library are you using?

Activity icon

Replied to Arrays In Form Names - Good Or Bad Practice?

Could you show some code.

Activity icon

Replied to How Can I Make This Rating System In HTML, CSS And PHP?

I'm not familiar with fa fa-star-o, but doesn't that Library you are using have the CSS to color it.

You could probably change the color in some JavaScript.

Activity icon

Replied to Collection Check For Existing IDs Inside Collection

Turn $request->stockItem into a collection, do a loop, and each Loop see if it's part of $editableStockItemIds. I imagine using in.

Edit: Not in, but contains, I was thing sql at first -- sorry.

Activity icon

Replied to Improving Problem Solving & Logical Thinking?

I have actually learned quite a bit of newer PHP techniques by looking at how Taylor did things in the vendor folder. After all Taylor has to know PHP real well in order to write a framework.

Aug
08
1 day ago
Activity icon

Replied to Deploy Laravel On Bluehost

To add, there should be a place to pick me PHP version, you may not need to actually do an upgrade.

Activity icon

Replied to Get WithCount() Of Nested Relationship

Try

$mycount = $departmentLessons->count();
Activity icon

Replied to How Can I Make The <a> Tag Like <button> Using CSS?

Padding, background color, etc

Look at laravels pagination templates, you will get the idea of how its done.

Activity icon

Replied to How To Show Data In Relate Table Laravel

Where you have so from this i can create total 10000

Add a derived column there and just calculate the total: Similar to a income expense report:

Or a check ledger:

Total column is derived (calculated) column.

order_detail
+----+------------+------------+--------------+-------+
| id |  order_id  | price      |   qty  | total   |


total is order_detail.price * order_detail.qty for that column.
Activity icon

Replied to Will PHP Run The Queries Within A Condition If It Is Not True?

It should only run if it's blank. To have an alternative you would want an else statement.

Not sure what you are trying to do.

Aug
07
2 days ago
Activity icon

Replied to App.js In The Head Or The Body? (Laravel Added By Default In The Head), Why?

There are videos on Vue some of them are free I would watch some. Jeffrey will explain how this all works.

Activity icon

Replied to App.js In The Head Or The Body? (Laravel Added By Default In The Head), Why?

I don't use Vue I use regular JavaScript and fetch Js.

Activity icon

Replied to App.js In The Head Or The Body? (Laravel Added By Default In The Head), Why?

In the head is where you load the library. Scripts where you're actually doing something goes at end.

Activity icon

Replied to Convert A Sql Query To Php Laravel Query

You can use your original query in laravel, use the db facade, here is an example:

https://laracasts.com/discuss/channels/laravel/sql-native-to-query-builder

Activity icon

Replied to Convert A Sql Query To Php Laravel Query

Look at the example queries in that chapter. Not rewriting your query but here is an example of what one looks like:

$quy = Powner::query()->leftJoin('dc_pets', 'dc_powners.ownerid', '=', 'dc_pets.ownerid')
                ->select('dc_powners.ownerid', 'dc_powners.oname')
                ->selectRaw('count(dc_pets.petid) as countOfPets')
                ->groupby('dc_powners.ownerid')
                ->orderby('dc_powners.oname')
                ->get();

Results basically give:

ownerid, oname, countOfPets

Like:

5|Bob|3
4|Greg|9
2|Rob|1

But if you are new to this seriously work some of those examples in the documentation and watch some free videos in the from scratch series.

And eloquent also has all query Builder methods.

https://laravel.com/docs/7.x/queries#joins

Right in that section Taylor has examples of a left join. Please review the documentation.

Activity icon

Replied to What Is Your Process When Starting To Work On A Project?

See how the client wants their forms laid out.

Activity icon

Replied to Convert A Sql Query To Php Laravel Query

I'd start with the examples in the query Builder chapter. There are good examples of groupby, aggregates Etc.

https://laravel.com/docs/7.x/queries

Activity icon

Awarded Best Reply on Deploy A Laravel App

No, PHP artisan serve is for development. If Apache is the server there set it up correctly.

Also digital ocean has tutorials.

Activity icon

Replied to Pagination

You could paginate your collection if you want to, https://laracasts.com/discuss/channels/guides/paginate-collection-simple-example-guide Second example.

Activity icon

Replied to Datatable Alternatives

I normally just use HTML tables with some JavaScript and a mix of Ajax as needed.

A little more work but once you done it a couple or three times you can kind of use what you have as a guide or template for other projects.

Activity icon

Replied to Custom Sorting Of Collection's Json Object Attribute

You could put into a collection and use collection methods.

Activity icon

Replied to Deploy A Laravel App

No, PHP artisan serve is for development. If Apache is the server there set it up correctly.

Also digital ocean has tutorials.

Activity icon

Replied to Problem With Displaying Validation Rule In Login Form In Laravel

The out of box authentication has login validation already. So if using custom, still look over how Taylor accomplished it and just duplicate that. I've gotten many ideas from Taylor.

Activity icon

Replied to File Uploads On Windows Server

You can have more than one folder to store images, sub folders.

Example"

storage\app\UploadedFiles\products
storage\app\UploadedFiles\some_other_image_folder
-------- etc

Do they need named like AXF8JV8as4tdoOubZsVNnwAYvoZaZ73lfAPVf7jP.png

Sometimes I name like:

ann478_127.jpg

Where 478 is count + 1 of images. and 127 is user id.

And a method I have only lets user 127 see their images.

Activity icon

Replied to How Can I Update The Cart In A The Tag Using The `ajax` Data In Laravel?

Get the information from data like:

data[0].whatever

You may need to loop, I don't know your whole setup.

Use your network dev tools to see exactly how "data" is returned, probably a json array of objects.

Or take a tutorial on json and json arrays and how to loop and get data from them.

Aug
06
3 days ago
Activity icon

Replied to Does Laravel Validates Or Sinitizes Page Parameter.

Generally a parameter is used somewhere in code, so binding parameters in a raw expression takes care of it.

From the example in the docs:

$users = DB::select('select * from users where active = ?', [1]);

The last part is binding.

Also I wrote a custom router in a framework and for uri parameters I send them through this:

    public static function fixUriParts($rvalue)
    {
        $rvalue = empty($rvalue) ? NULL : trim(strip_tags($rvalue));
        $rvalue = strtok($rvalue, '?');
        $rvalue = htmlspecialchars($rvalue);
        return $rvalue;
    }

But why sanitize a page parameter, I have never seen that come up or asked before.

But you are free to run any parameter through htmlspecialchars if you want to.

Also see this article: https://www.cloudways.com/blog/prevent-xss-exploits-using-laravel-validation-and-sanitization/

Activity icon

Replied to Response->download Working Only Sometimes

Check for the existence of the completed zip file prior to running the delete. Maybe somehow delete is taking place prior to everything being zipped.

Activity icon

Replied to Forms, Query Strings, And Controller Parameters

When submitting a form you don't need a parameter there:

Route::get('/fabrication/weldtub', '[email protected]')->name('weldtub.show');

Just request the data:

$serial = $request->serial;

Its a form there, not a link.

A link

<a href="<?php echo 'weldtub/' . $row->serial; ?>">Edit</a>  // just example.

A link and a submitted form are not the same.

That should be a post form the way you are using it.

Activity icon

Replied to Forms, Query Strings, And Controller Parameters

See the chapter on routing, they would be passed as parameters rather than get request would be the only difference.

Similar to passing parameters to a function.

Activity icon

Replied to Response->download Working Only Sometimes

See second answer down here, try tracing all or any errors:

https://stackoverflow.com/questions/20029606/invalid-or-unitialized-zip-object/39775980

Also go here https://www.php.net/manual/en/class.ziparchive.php

Then scroll town to see this function: function ZipStatusString( $status )

Activity icon

Replied to Navigating Laracasts

I'd go here https://laracasts.com/browse/all and pick a topic. You'll see what you viewed already.

Activity icon

Replied to What Is The Best Way To Export 1 Million Records

Print out this post here, and show the replies.

Activity icon

Replied to CSRF TOKEN Mismatch Exception Laravel 5.8?

Try several other post, punch into google:

site:laracasts.com CSRF TOKEN mismatch exception

Surely one of the replies will help.

Google search is more powerful than search here, I find many answers that way.