@archiebango If you just read the documentation, you should be able to figure out all your questions by your own. Anyways, I will assume that you really need the help and answer the questions:
with() is used to pass a variable to your view. That variable would be called
$i and would contain the number where the paginator started counting for the current page. That may sound confusing, so few examples:
On page 3, the variable will equal to (3 - 1) * 5 = 10 (the items on page 3 would be from 10 to 15)
On page 5, the variable will equal to (5 - 1) * 5 = 20 (the items on page 5 would be from 20 to 25)
However, that variable is redundant in most cases. The paginator itself has a lot of build-in methods that should be enough. Usually, there is no need to make such calculations, so I would bet the developer who wrote the code wasn't aware of the paginator's build-in features.
request() is a helper function that would return an instance of the
Illuminate\Http\Request class. That class has a
validate() method which raises an exception if some of the validation rules are not met. Then the exception handler handles that validation and automatically return a response. So the code after the
validate() method would be executed only if the validation passes.
The first line obviously takes all the request data and create an article with it.
The second line is again quite obvious - redirect to a named route
with() method just adds the
success key into the session for the next request only. Other developers may write
->withSuccess('Article created successfully'); which is again the same thing.