laravel-5.4

How do I validate Array inputs in Laravel 5.0

血红的双手。 提交于 2019-12-08 05:19:06
问题 I have a table, where the user can fill in information. However, the user can add rows and/or delete rows. I used a cloning function for that. My html looks like: <input type="text" class="form-control" name="TB1_a[]"> <input type="text" class="form-control" name="TB1_b[]"> As you can see, it is an array input. So if the user adds a row, I'll have two values stored in TB1_a[] and TB1_b. Now, I would like to make my rules so that if the user enters information inside TB1_a[0], I would like to

Calculating value differences between two records in Eloquent

ぃ、小莉子 提交于 2019-12-08 05:00:36
问题 I would like to calculate the difference between two records in eloquent. For example, I have following table: ---------------------------------- | Id | value | type | ---------------------------------- | 1 | 100 | FOO | | 2 | 500 | FOO | | 3 | 800 | FOO | | 4 | 200 | BAR | | 5 | 600 | BAR | | 6 | 1000 | FOO | ---------------------------------- Let's say the model name is FooBar, so when I filter the table, for example, using FooBar::where('type', 'FOO')->get(); I will get following result: -

Take back to login page after successfully reset his/her password in laravel 5.4

不羁岁月 提交于 2019-12-08 04:17:30
I want to redirect to login page whenever a user successfully reset his/her password in laravel 5.4. Currently it redirects to dashboard page after successfully reset. I looked around all stuff all are saying to place protected $redirectTo = '/home'; in protected $redirectTo = '/'; But it does not give me any solution. By default Laravel authenticates the user after they reset their password. So it's impossible to redirect to the login page since only guest users can view the login page. Even if you set the $redirectTo to /login , the guest middleware would redirect the user back to /home

How to create Tamil Language Based Web Application in Laravel 5.4

流过昼夜 提交于 2019-12-08 04:09:18
问题 I planed to create Departmental Store Laravel Web Application in Tamil Language Not Using English. How to do it? 回答1: You can create web apps using laravel's Localization. For that, you need to create language strings. Language strings are stored in files within the resources/lang directory. You need to create locale: Route::get('welcome/{locale}', function ($locale) { App::setLocale($locale); // }); Then create file within that directory and save it messages.php name like this: <?php return

Laravel - select with relationship with one query

折月煮酒 提交于 2019-12-08 04:09:13
问题 I have a Person model. Each person may have zero or more cars: class Person extends Model { public function cars() { return $this->hasMany('App\Car'); } } I wish to select and display all persons who have a ford with one running query. So i tried this: $persons = Person::whereHas('cars', function ($query) { $query->where('mark', 'ford'); })->get(); foreach ($persons as $person) { foreach($person->cars()->get() as $car) { print $person->name . " has a " . $car->mark . $car->model } } The

Laravel Query Builder Update with Increment

帅比萌擦擦* 提交于 2019-12-08 04:07:27
问题 Hi I need to fix my query where I will need to update my product quantity with just incrementing it, here is my code with sample. DB::table('product_warehouse') ->where('product_id', $product_id) ->where('warehouse_id', $warehouse_id) ->update(['product_qty' => $old_qty+$product_qty]); 回答1: You can try both ways: DB::table('product_warehouse') ->where('product_id', $product_id) ->where('warehouse_id', $warehouse_id) ->update(['product_qty' => DB::raw('product_qty + ' . $product_qty)]); Or DB:

How do I make Example.vue update in Laravel?

前提是你 提交于 2019-12-08 03:25:41
问题 I just read the answers to this question and wasn't able to get a good response. Laravel Example.vue not updating I also posted this question trying to figure it out on my own but to no avail. how do I load a Vue component in Laravel 5.4? As another attempt, I just did a new reinstall of Laravel, and while I am able to get the default Example.vue component to load multiple times in a single view, I am still unable to change the contents of the component. Funnier thing is that when I run npm

How to order data twice. But make the firts orderBy ineffective

喜你入骨 提交于 2019-12-07 23:33:04
问题 I'm trying to get last 100 posts from database and than order them by likecount or another property and output only 5 of them, that way I will discover most liked 5 posts or viewed, or reported out of last 100 posts. What I tried so far is like below: $lastHundredPost = Post::orderBy('id', 'desc')->take(100); $post = $lastHundredPost->orderBy('likecount', 'desc')->take(2)->get(); this does not disable first orderBy property. Laravel 5.4 回答1: If you want to get result from the first query, use

How to set default postgresql schema for laravel?

不想你离开。 提交于 2019-12-07 16:47:19
问题 I created new postgresql user: CREATE ROLE lara_user SUPERUSER LOGIN PASSWORD 'mypassword'; Then create schema which is owned by this user CREATE schema lara AUTHORIZATION lara_user; In Laravel's .env file I have DB_DATABASE=postgres DB_USERNAME=lara_user DB_PASSWORD=mypassword Laravel don't sees schema lara and still connected to public schema. How can I change and set default schema lara for Laravel ? 回答1: in app/config/database.php 'pgsql' => array( 'driver' => 'pgsql', 'host' =>

Class 'NumberFormatter' not found in Laravel 5.4

狂风中的少年 提交于 2019-12-07 13:59:38
问题 I'm trying to use PHP's intl extension to convert amount into words. For example, 1450 -> One Thousand Four Hundred and Fifty I'm using Laravel 5.4 that runs on XAMPP 3.2.2 server with PHP 5.6.24. As mentioned in similar questions, I've already enabled the intl PHP extension by uncommenting the line as extension=ext/php_intl.dll in PHP.ini file and restarted my server after. $inWords = new \NumberFormatter('en', \NumberFormatter::SPELLOUT); echo $inWords->format(1450); yields the error: