laravel

Create date - Carbon in Laravel

穿精又带淫゛_ 提交于 2021-01-20 23:55:41
问题 I'm starting to read about Carbon and can't seem to figure out how to create a carbon date . In the docs is says you can; Carbon::createFromDate($year, $month, $day, $tz); Carbon::createFromTime($hour, $minute, $second, $tz); Carbon::create($year, $month, $day, $hour, $minute, $second, $tz); But what if I just recieve a date like 2016-01-23 ? Do I have to strip out each part and feed it to carbon before I can create a carbon date? or maybe I receive time like 11:53:20 ?? I'm dealing with

Laravel [1045] 解决方法 Access denied for user 'homestead'@'localhost'

岁酱吖の 提交于 2021-01-20 21:14:56
Laravel [1045] 解决方法 Access denied for user 'homestead'@'localhost' 参考文章: (1)Laravel [1045] 解决方法 Access denied for user 'homestead'@'localhost' (2)https://www.cnblogs.com/clew/p/5894239.html 备忘一下。 来源: oschina 链接: https://my.oschina.net/u/4437974/blog/4915781

Check if variable exist in laravel's blade directive

≯℡__Kan透↙ 提交于 2021-01-20 16:23:54
问题 I'm trying to create blade directive which echo variable (if variable defined) or echo "no data" if variable undefined. This is my code in AppServiceProvider.php : <?php namespace App\Providers; use Blade; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Blade::directive('p', function($ex) { error_log(print_r($ex,true)); return '<?php $defined_vars = get_defined

Check if variable exist in laravel's blade directive

夙愿已清 提交于 2021-01-20 16:20:50
问题 I'm trying to create blade directive which echo variable (if variable defined) or echo "no data" if variable undefined. This is my code in AppServiceProvider.php : <?php namespace App\Providers; use Blade; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Blade::directive('p', function($ex) { error_log(print_r($ex,true)); return '<?php $defined_vars = get_defined

Check if variable exist in laravel's blade directive

♀尐吖头ヾ 提交于 2021-01-20 16:16:06
问题 I'm trying to create blade directive which echo variable (if variable defined) or echo "no data" if variable undefined. This is my code in AppServiceProvider.php : <?php namespace App\Providers; use Blade; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Blade::directive('p', function($ex) { error_log(print_r($ex,true)); return '<?php $defined_vars = get_defined

Laravel Nested @foreach By 2 Different Model in View

白昼怎懂夜的黑 提交于 2021-01-20 13:53:36
问题 Model // Relationship in \App\FatherRegistrars and \App\MotherRegistrars and \App\GuardianMaleRegistrars \App\GuardianFemaleRegistrars public function student_registrars() { return $this->belongsToMany('App\StudentRegistrars')->withTrashed(); } Controller public function index(Request $request) { $dataFathers = \App\FatherRegistrars::get(); $dataMothers = \App\MotherRegistrars::get(); $dataGM = \App\GuardianMaleRegistrars::get(); $dataGF = \App\GuardianFemaleRegistrars::get(); // manual

Laravel Nested @foreach By 2 Different Model in View

梦想与她 提交于 2021-01-20 13:51:36
问题 Model // Relationship in \App\FatherRegistrars and \App\MotherRegistrars and \App\GuardianMaleRegistrars \App\GuardianFemaleRegistrars public function student_registrars() { return $this->belongsToMany('App\StudentRegistrars')->withTrashed(); } Controller public function index(Request $request) { $dataFathers = \App\FatherRegistrars::get(); $dataMothers = \App\MotherRegistrars::get(); $dataGM = \App\GuardianMaleRegistrars::get(); $dataGF = \App\GuardianFemaleRegistrars::get(); // manual

How to run laravel in root directory without the public folder?

狂风中的少年 提交于 2021-01-20 13:06:23
问题 I am running the latest version of laravel on my own server running Debian and Apache2 . The contents of laravel are located in /var/www which is what my domain name is pointed to however all of the functionality happens through the public directory so I would have to go to http://mydomain.com/public to access anything. I would like to change it so that I only have to access http://mydomain.com . Is this possible? How can I change this? Would I have to move everything up another level to the

How to run laravel in root directory without the public folder?

笑着哭i 提交于 2021-01-20 13:05:10
问题 I am running the latest version of laravel on my own server running Debian and Apache2 . The contents of laravel are located in /var/www which is what my domain name is pointed to however all of the functionality happens through the public directory so I would have to go to http://mydomain.com/public to access anything. I would like to change it so that I only have to access http://mydomain.com . Is this possible? How can I change this? Would I have to move everything up another level to the

Select SUM from subquery while using whereHas in Laravel

一个人想着一个人 提交于 2021-01-20 11:51:48
问题 I have 2 tables, customers and customer_invoices , and I want to get all the customers with a condition on their invoices, and select specific columns (customers.id, customers.last_name, and the sum of the total_price of the invoices for each customer), I have this query : $result = Customer::whereHas('customerInvoices', function(Builder $q) { $q->where('customer_invoices.status', 1); })->select([ 'customers.id', 'customers.last_name', \DB::raw('SUM(customer_invoices.total_price) as sum') ])-