laravel

Laravel Password Reset Token

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-07 19:15:21
问题 Okay, this is very beginner, but I'd like an explanation. In the built-in Laravel password reset in the "postReset" method below, it specifies "token"...however, when using {!! csrf_field() !!} in the view, it generate as the input name="_token". Does the _ count as an actual character when matching up the names? Just confused how the database migration uses "token", but the csrf field sets up the input name as "_token". public function postReset(Request $request) { $this->validate($request,

Access to another requested input in custom rule class - Laravel

落爺英雄遲暮 提交于 2021-02-07 19:12:47
问题 I need to access $request->important in passes method. I need it to validate name based on this value class TestCustom implements Rule { public function passes($attribute, $value) { // } public function message() { return 'some txt'; } } Used like this: use App\Rules\TestCustom; $request->validate([ 'name' => ['required', new TestCustom], 'important' => ['required', 'string'], ]); 回答1: It's much better to pass data to rule constructor and use it inside rule afterwards. This way you can use

Laravel Password Reset Token

百般思念 提交于 2021-02-07 19:09:57
问题 Okay, this is very beginner, but I'd like an explanation. In the built-in Laravel password reset in the "postReset" method below, it specifies "token"...however, when using {!! csrf_field() !!} in the view, it generate as the input name="_token". Does the _ count as an actual character when matching up the names? Just confused how the database migration uses "token", but the csrf field sets up the input name as "_token". public function postReset(Request $request) { $this->validate($request,

Indirect modification of overloaded property App\Category::$thesizes has no effect

自古美人都是妖i 提交于 2021-02-07 18:27:29
问题 For a webshop im trying to generate a table that looks like: Tablename: category 1 productname S M L X total name1 1 0 1 3 5 name2 0 1 0 2 3 Tablename: category 2 productname S L X total name5 1 1 3 5 name8 0 0 2 2 There is a table for each category, each category has his own sizes (table 2 has no size M for example). The tables show the amount of ordered products per size per product in each category. In the application there is a model OrderProducts which are ordered products in each Order

Laravel 5.1 Snappy pdf image not rendering in pdf file

最后都变了- 提交于 2021-02-07 18:20:31
问题 I am using barryvdh/laravel-snappy to generate pdf file. I have two image files 1. yourlogohere.png is in public/image/ folder and 2. logo2.png is in folder other than public i.e. storage/app/logo and to get this file I defined a route (www.example.org/logo/logo.png) and use following code to access it. public function logo($filename) { $file = Storage::disk('local_logo')->get($filename); $mime = 'image/png'; return (new Response($file, 200))->header('Content-Type', $mime); } Problem: When I

What are the best practices for creating a “settings” model in Laravel 5?

你离开我真会死。 提交于 2021-02-07 18:15:09
问题 This is my first project using Laravel (I'm starting with 5.2). I'm building a self managed website. There's an admin that should save site settings for using later in the website. Eg: Background color, social networks, carousel with pictures, products, etc. My first try was creating a model "Setting" with: id | key (unique) | value . When I tried to save social networks (to display in the site header), I realized I'd have to save in "value" a json with URL, title, etc... Ugly implementation

Laravel - Get website unique visitor count

我与影子孤独终老i 提交于 2021-02-07 14:53:57
问题 I want to collect the unique amount of visitors on my website and store them in a database. Even when someone without an account accesses the website the visitor count goes up. How can I accomplish this? I know I have to fetch the users IP address or something along those lines but I don't know how to fetch the IP address of a user without an account when the page loads Currently I have this DB table Visitors - ip - date_visited Route Route::get('/', function () { $ip = Request::ip(); return

Laravel - Get website unique visitor count

放肆的年华 提交于 2021-02-07 14:53:15
问题 I want to collect the unique amount of visitors on my website and store them in a database. Even when someone without an account accesses the website the visitor count goes up. How can I accomplish this? I know I have to fetch the users IP address or something along those lines but I don't know how to fetch the IP address of a user without an account when the page loads Currently I have this DB table Visitors - ip - date_visited Route Route::get('/', function () { $ip = Request::ip(); return

Laravel - Get website unique visitor count

試著忘記壹切 提交于 2021-02-07 14:53:00
问题 I want to collect the unique amount of visitors on my website and store them in a database. Even when someone without an account accesses the website the visitor count goes up. How can I accomplish this? I know I have to fetch the users IP address or something along those lines but I don't know how to fetch the IP address of a user without an account when the page loads Currently I have this DB table Visitors - ip - date_visited Route Route::get('/', function () { $ip = Request::ip(); return

Laravel 5.0.* middleware to remove prefix locale from url before routes are processed

前提是你 提交于 2021-02-07 14:13:59
问题 I am looking for a way to make all app route's have multiple locales without using route groups. This is because I use an external extensions package, which means routes are registered in many places. Essentially I want to have /foo/bar as well as /en/foo/bar, /de/foor/bar, /es/foo/bar etc all to be recognised and processed by the /foot/bar route Route::get('foo/bar', function () { return App::getLocale() . ' result'; }); So the above would give me 'en result' or 'de result' or 'es result'. I