laravel-5.2

Laravel 5.2: Undefined class form

拈花ヽ惹草 提交于 2019-12-04 19:28:45
I have a problem with using Form command in a Composer + Laravel 5.2 project with PhpStorm as IDE. I'm using Laravel Collective 5.2. in my composer.json , so it should work. (sadly, it's not which is the reason I'm here...) The providers: Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class, Collective\Html\HtmlServiceProvider::class, my aliases. 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, The problem: It's returned as a undefined class when I'm using {!! Form::close() !!} or any form command in my blade.php . Did I misunderstood something

How to insert a post with multi category and with multi column deferent category in laravel?

久未见 提交于 2019-12-04 19:21:49
Hello all I am a new laravel, I have problem with my project. I have 2 table: posts: id title category_id category: id name(PHP, Laravel, Ruby) Ex:I want result like, if I am insert a post into posts database title=Jonh and chosse two category name(PHP,Laravel), and the result will two column like posts(id=1 title(jonh) category_id(1), id=2 title(jonh) category_id(2)) but it still not work I try to find in google and youtube follow and it not work, and here is my code: View(create.blade.php) {!!Form::open(array('route' => 'store', 'method' => 'POST'))!!} {{Form::text('title')}}<br> @foreach(

Regex Validation in Laravel 5.2

ε祈祈猫儿з 提交于 2019-12-04 17:25:57
问题 Below is my rule for password: return [ 'Password' => 'required|min:8|max:100|regex:[a-z{1}[A-Z]{1}[0-9]{1}]', 'Password_confirmation' => 'required|min:8|max:100|regex:[a-z{1}[A-Z]{1}[0-9]{1}]', ]; I am trying to add the rule such that it must have atleast one small char atleast one big char atleast one number atleast one special char min 8 chars I tried this and it works required|confirmed|min:8|max:100|regex:/^[\w]{1,}[\W]{1,}$/ , on a regex tester software . but not sure why it does not

Passing page URL parameter to controller in Laravel 5.2

女生的网名这么多〃 提交于 2019-12-04 13:50:22
In my application I have a page it called index.blade , with route /index . In its URL, it has some get parameter like ?order and ?type . I want to pass these $_get parameter to my route controller action, query from DB and pass its result data to the index page. What should I do? Achraf Khouadja If you want to access the data sent from get or post request use public function store(Request $request) { $order = $request->input('order'); $type = $request->input('type'); return view('whatever')->with('order', $order)->with('type', $type); } you can also use wildcards. Exemple link website.dev

How to get Laravel Query Builder result as integer

谁都会走 提交于 2019-12-04 12:47:03
问题 I'm using Laravel Query Builder to query MySQL database but it returns integer values as string values. I have the following query. $query = DB::table('store_products')->select('products.id', 'products.name', 'products.unit_type', 'products.price', 'products.image_path', 'products.is_popular', 'store_products.price AS store_price') ->join('products', 'products.id', '=', 'store_products.product_id') ->join('product_categories', 'product_categories.product_id', '=', 'store_products.product_id')

What does double colon in laravel means

杀马特。学长 韩版系。学妹 提交于 2019-12-04 11:14:11
Example : Auth::guard($guard)->guest() I dont get what double colon (::) notation means in laravel framework. from http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php I learn that it stand for scope resolution operator to access static, constant and overridden properties or methods of a class. but from laravel I learn that Auth means the alias for class facade so I need an explanation of the example above especially guard(parameter)->guest() means. I'm still new to php and now learning laravel framework for my back-end. :: Scope Resolution Operator This is called as scope

How to get the queued job from job ID in Laravel?

耗尽温柔 提交于 2019-12-04 10:04:52
Is there any way to get the queued job from the job ID in Laravel? While adding the job to the queue, I store the job ID. Later at some point of time (there is a delay to process the job in the queue), I want to remove the job from the queue. If I can get the job on the queue using the job ID, I can use delete() method to remove it. I use this code for laravel 5.5 : use Illuminate\Contracts\Bus\Dispatcher; $job = ( new JOB_CLASS() )->onQueue('QUEUE_NAME')->delay('DELAY'); $id = app(Dispatcher::class)->dispatch($job); It is a queue so you can not select it, but if you are logging the data also

Override table prefix for a model

浪子不回头ぞ 提交于 2019-12-04 10:03:59
Hello I've in config/database.php a prefix (mysql) like this: 'prefix' => 'myprefix_', But I need, only for one model, to use a different prefix like: protected $table = 'otherprefix_mytable'; In this way laravel looking for "myprefix_otherprefix_mytable". Any help? In your app/config/database.php make 2 different connections like 'connections' => array( # first prefix 'mysql1' => array( 'driver' => 'mysql', 'host' => 'host1', 'database' => 'database1', 'username' => 'user1', 'password' => 'pass1' 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => 'prefix1', ), # second prefix

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

◇◆丶佛笑我妖孽 提交于 2019-12-04 09:39:57
问题 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()

Laravel Validation If checkbox ticked then Input text is required?

匆匆过客 提交于 2019-12-04 08:52:42
I have been reading Laravel validation documentation. I am not clear how to combine two rules. For example: <input type="checkbox" name="has_login" value="1"> <input type="text" name="pin" value=""> If has_login checkbox is ticked then Input text pin value is required. If has_login is not ticked then Input text pin is not required. Laravel Validation: public function rules() { return [ 'has_login' => 'accepted', 'pin' => 'required', ]; } Use required_with or required_if required_with:foo,bar The field under validation must be present and not empty only if any of the other specified fields are