laravel-5.2

Calculate Age from date stored in database in Y-m-d using Laravel 5.2

吃可爱长大的小学妹 提交于 2019-12-03 03:05:54
Hi User's add their DOB through the Form that store in database, I would like calculate age from stored date in the database which is in this format Y-m-d, My Question is : How to calculate Age? Where to put the logic , In Controller or Model? How to pass the stored Date in view in this format 'm-d-Y' How to pass the result of logic which is age in view. I am using something as below in my model is this Right? This is controller: public function index() { $profile = User::find($this->userid())->profiledetailsHasOne; //This has Dob field return view('profile.index',['profile' => $profile ]); }

Undefined variable: errors — Laravel 5.2

你离开我真会死。 提交于 2019-12-03 02:26:58
I am new in Laravel and using laravel version 5.2. I created a controller and request named as ArticlesController and CreateArticleRequest respectively and i defined some validation rules. CreateArticleRequest <?php namespace App\Http\Requests; use App\Http\Requests\Request; class CreateArticleRequest extends Request { public function authorize() { return true; } public function rules() { return [ 'title' => 'required|min:3', 'body' => 'required|max:400', 'published_at' => 'required|date', ]; } } ArticlesController <?php namespace App\Http\Controllers; use App\Article; //use Illuminate\Http

how to use GROUP_CONCAT in laravel

天大地大妈咪最大 提交于 2019-12-03 02:09:18
$assignment = assignment::find(Crypt::decrypt($id)); $assignment_details = $assignment->raw_plan()->groupBy('flag')->get(); I want to following result of this query in laravel SELECT GROUP_CONCAT(name) AS 'names' FROM `raw_plans` where `assignment_id` = 1 GROUP BY`flag` Please suggest me how to use GROUP_CONCAT in laravel You can use relations as query builder to fetch the results as: $assignment_details = $assignment->raw_plan() ->select(DB::raw('group_concat(name) as names')) ->where('assignment_id', 1) ->groupBy('flag') ->get(); Update Use table_name.* in select to get all the fields.

laravel 5.2 How to get route parameter in blade?

非 Y 不嫁゛ 提交于 2019-12-03 01:16:15
this is my url http://project.dev/blogs/image-with-article so, here I need the parameter image-with-article in my blade to display which is a parameter named slug here is in my routes file I need the slug paramter in blade. Route::get('/blogs/{slug}', ['as'=>'blog.by.slug', 'uses'=> 'CmsController@show']); I'm not sure what you mean. If you're trying to construct the route in a Blade template, use <a href="{{ route('blog.by.slug', ['slug' => 'someslug']) }}">...</a> If you're trying to access the given parameter, I would suggest passing it from the controller: // CmsController public function

Laravel Upgrading To 5.2.0 From 5.1 error

五迷三道 提交于 2019-12-02 23:19:32
Getting the error on composer update command. My composer.json file is: { "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "php": ">=5.5.9", "laravel/framework": "5.2.*", "illuminate/html": "^5.0", "barryvdh/laravel-debugbar": "~2.0", "spatie/laravel-paginateroute": "^2.0", "darkaonline/l5-swagger": "~2.0", "yajra/laravel-datatables-oracle": "~5.0", "phpoffice/phpexcel": "^1.8" }, "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", "phpunit/phpunit": "~4.0", "phpspec

Laravel Policies - How to Pass Multiple Arguments to function

巧了我就是萌 提交于 2019-12-02 19:27:23
I'm trying to authorize a users character to delete/update post. I was using policies to do so, but I could only pass one parameter to the policy function. If I pass more than the user and another variable, the variable isn't passed into the function. Models: User has many characters, a character can post multiple posts. So for authorization purposes, I would have to compare the post's character_id with the current character's id...- Per the docs , you can pass more multiples to the Gate Facade: Gate::define('delete-comment', function ($user, $post, $comment) { // }); But I couldn't find

How to force Laravel Project to use HTTPS for all routes?

南楼画角 提交于 2019-12-02 19:03:57
I am working on a project that requires a secure connection. I can set the route, uri, asset to use 'https' via: Route::get('order/details/{id}', ['uses' => 'OrderController@details', 'as' => 'order.details', 'https']); url($language.'/index', [], true) asset('css/bootstrap.min.css', true) But setting the parameters all the time seems tiring. Is there a way to force all routes to generate HTTPS links? Mirceac21 You can set 'url' => 'https://youDomain.com' in config/app.php or you could use a middleware class Laravel 5 - redirect to HTTPS . Here are several ways. Choose most convenient.

without select category not show subcategory

独自空忆成欢 提交于 2019-12-02 17:57:43
问题 This is create.blade.php file. In this include css and js file too.. Html code and ajax code view file @extends('layouts.app') @section('content') <link rel="stylesheet" href="http://www.codermen.com/css/bootstrap.min.css"> <script src="http://www.codermen.com/js/jquery.js"></script> <form enctype="multipart/form-data" method="post" action="{{route('post.store')}}" > @csrf <div class="form-group col-md-8"> Category<select name="category" id="category" class="form-control"> <option>select<

How to clear Route Caching on server: Laravel 5.2.37

泄露秘密 提交于 2019-12-02 17:30:44
This is regarding route cache on localhost About Localhost I have 2 routes in my route.php file. Both are working fine. No problem in that. I was learning route:clear and route:cache and found a small problem below. if I comment any one route in my route.php file and then run below command php artisan route:cache This will keep the route disabled because the route list is in cache now. Now, go to route.php file and try to remove commented route and then try to run that enabled url. still it will show 404 because I need to remove cache by using below command php artisan route:clear So far

laravel 5.2 custom log file for different tasks

僤鯓⒐⒋嵵緔 提交于 2019-12-02 14:10:36
Can we create a custom log file for different purposes in laravel 5.2 like for order related log entries that should be in order.log and for payment related stuff the entry should get logged in payments.log I want to find the best possible Laravel way. Currently we can only change the log file frequency (like daily, single) or we can change the name of the log file other than default i.e laravel.log massreuy There is a simple way: use Monolog\Logger; use Monolog\Handler\StreamHandler; $log = ['orderId' => 10, 'description' => 'Some description']; //first parameter passed to Monolog\Logger sets