laravel

How to handle datetime between php (Laravel api) and javascript (AngularJS)

◇◆丶佛笑我妖孽 提交于 2021-02-05 18:52:26
问题 I'm utterly stuck trying to make php api exchange dates with angular frontend. From PHP to JS I seem to have it sorted. Since Laravel handles dates through Carbon I just added \Carbon\Carbon::setToStringFormat('c'); to app.php which makes dates come out in ISO 8601. PHP example: 2015-02-04T00:53:51+02:00 AngularJS date filter also seems to understand this format well and even reads the timezone correctly. What I have yet to get working is posting JS date objects back to PHP api. JS example:

Extension gd is missing from your system - laravel composer Update

守給你的承諾、 提交于 2021-02-05 14:29:51
问题 I newly install Dompdf in Laravel Project via Composer ( composer require barryvdh/laravel-dompdf ). After enter the Command Terminal Reply Following Errors. Problem 1 - dompdf/dompdf v0.7.0 requires ext-gd * -> the requested PHP extension gd is missing from your system. - barryvdh/laravel-dompdf v0.7.0 requires dompdf/dompdf ^0.7 -> satisfiable by dompdf/dompdf[v0.7.0]. - Installation request for barryvdh/laravel-dompdf ^0.7.0 -> satisfiable by barryvdh/laravel-dompdf[v0.7.0]. To enable

PHP Startup: Unable to load dynamic library 'php_mongodb.dll'

旧巷老猫 提交于 2021-02-05 12:21:09
问题 I'm trying to get Laravel MongoDB working in my local machine (Windows 10 home, x64) by following this tutorial I have installed XAMPP 7.3.11 on D:\xampp succesfully and tested that the server can be reached (enter localhost:80 on browser) I proceeded on extracting php_mongodb.dll I got from pecl(mongodb 1.6.0 for Windows, 7.3 Non Thread Safe, x64 ) on D:\xampp\php\ext and add the line extension=php_mongodb.dll on the file D:\xampp\php\php.ini After selecting 'the command-line PHP you want to

Can't seed the database in Laravel

时间秒杀一切 提交于 2021-02-05 12:18:01
问题 I'm currently seed my database in Laravel, migrations works properly and I am able to see the tables in SQL workbench. But when I run the command php artisan db:seed nothing happens. I can't find the cause of it. I'm pretty new to Laravel. DB name is 'Laravel', the table name is 'books'. Seeder Code: DB::table('books')->insert($books = [ ['name' => 'Harry Potter', 'writer_name' => 'J.K. Rowling', 'isbn' => '9780739360385'], ['name' => 'Game of Thrones', 'writer_name' => 'George R.R. Martin',

How to get the JSON content of a HTTP Post request?

ぐ巨炮叔叔 提交于 2021-02-05 12:16:12
问题 I want to send a JSON file from my Unity application to my Laravel backend. It seems there is something wrong with my post request but I can't figure out what it is. Sending the request using Unity public void SendRequest() { // serializable struct OfferData data = new OfferData(OfferSize.JUMBO, OfferType.AD, 50, 10); StartCoroutine(RequestHandler.Post(API_URL + "shop/store", JsonUtility.ToJson(data), (response) => { if (response == null) { return; } // success Debug.Log(response); })); } The

Can't seed the database in Laravel

泪湿孤枕 提交于 2021-02-05 12:16:04
问题 I'm currently seed my database in Laravel, migrations works properly and I am able to see the tables in SQL workbench. But when I run the command php artisan db:seed nothing happens. I can't find the cause of it. I'm pretty new to Laravel. DB name is 'Laravel', the table name is 'books'. Seeder Code: DB::table('books')->insert($books = [ ['name' => 'Harry Potter', 'writer_name' => 'J.K. Rowling', 'isbn' => '9780739360385'], ['name' => 'Game of Thrones', 'writer_name' => 'George R.R. Martin',

Elasticquent(ElasticSearch) Laravel limit

◇◆丶佛笑我妖孽 提交于 2021-02-05 11:21:27
问题 Hi I'm trying to get all results with elasticSearch query, but it returns only 10 results if $limit value is null. $videos = Video::searchByQuery([ 'match' => [ $field => $request->$field ], ],null,null,null); so how to get all results ? 回答1: That's because the default size for requests is 10 and not passing a length limit to any framework is probably going to set it to the default. You can use from and size with large values though: Though from and size can be set as request parameters, they

Laravel APP_LOCALE in spanish

為{幸葍}努か 提交于 2021-02-05 10:54:29
问题 In Laravel 5.4, in .env I have: APP_LOCALE=es APP_FALLBACK_LOCALE=en APP_LOCALE_PHP=es_US and in config/app.php : 'locale' => env('APP_LOCALE', 'es'), 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'), 'locale_php' => env('APP_LOCALE_PHP', 'en_US'), But I want to set as spanish. For example, In a controller I have: $mydate = date('d F Y', strtotime($data->created)); $data->created is a string that comes from database, from column created_at . This way it show as: 14 August 2017 English,

Adding a backslash to the end of a PHP string

时光总嘲笑我的痴心妄想 提交于 2021-02-05 09:30:30
问题 I'm attempting to do a basic query in Laravel by querying a table that holds polymorphic relationships. The table has a column called record_type which holds values such as App\MedicationError and App\PressureUlcer . I want to run a query similar to this: `Action::where('record_type','App\MedicationError')` I have a set of variables containing strings like MedicationError and PressureUlcer . How would I go about prefixing those strings with App\ ? The reason I am having difficulty myself is I

Laravel Model Get Method Decoding JSON

ⅰ亾dé卋堺 提交于 2021-02-05 09:29:16
问题 Hi there below is what I'm storing in my db but when I use my get method in my model I have to use json_decode twice when formating my data why is this happening and can I have it just use it once somehow. json exactly in db: "[{\"id\":\"1\",\"country\":\"New Zealand\",\"shipping_rate\":\"1\"},{\"id\":\"2\",\"country\":\"Australia\",\"shipping_rate\":\"2\"}]" Model Get Method: public function getshippingAttribute() { return $this->attributes['shipping'] ? json_decode(json_decode($this-