投稿時間:2022-03-19 06:20:36 RSSフィード2022-03-19 06:00 分まとめ(22件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
TECH Engadget Japanese 航空自衛隊「宇宙作戦群」発足。宇宙領域の指揮統制、監視能力強化 https://japanese.engadget.com/japans-self-defense-forces-established-the-new-space-operations-group-205032886.html 航空自衛隊 2022-03-18 20:50:32
TECH Engadget Japanese 1999年3月19日、モノクロからカラー液晶へと変更になった「ネオジオポケットカラー」が発売されました:今日は何の日? https://japanese.engadget.com/today19-203008155.html 表示 2022-03-18 20:30:08
海外TECH Ars Technica Microsoft Edge’s new Linux beta supports cloud-streamed games on Steam Deck https://arstechnica.com/?p=1842230 stadia 2022-03-18 20:15:43
海外TECH MakeUseOf How to Watch Netflix US From Anywhere in the World https://www.makeuseof.com/watch-netflix-us-anywhere/ How to Watch Netflix US From Anywhere in the WorldNetflix offers way more content in the United States compared to many other countries but we ll teach you how to access it no matter where you live 2022-03-18 20:45:14
海外TECH MakeUseOf How to Master the IF Function in Google Sheets https://www.makeuseof.com/how-to-master-if-function-google-sheets/ sheets 2022-03-18 20:30:13
海外TECH DEV Community Making a Post API in Laravels https://dev.to/jordandev/making-a-post-api-in-laravels-4abm Making a Post API in Laravels Making a Post API in LaravelMaking an api using laravel is very simple and makes it much easier for us to develop it also helps you understand and apply good programming practices So in this example we are going to make an api on posts which we are going to have with authentication and in the end you are going to have a challenge which I will explain to you later as we advance with the project Starting with the projectTo create a project with Laravel from scratch we will start by going to the console and write the following command composer create project prefer dist laravel laravel apipostsNow we have a project created we are going to connect it to our database we do this in our env file DB CONNECTION mysqlDB HOST DB PORT DB DATABASE apipostDB USERNAME rootDB PASSWORD rootReady we have our database connected now we are going to create the models we need in Laravel we have the migrations that are the versions of our database This has many benefits when we develop as a team since we will be able to know what changes were made in the base and in case of errors we can roll back to a previous version Laravel already brings default migrations that we can alter to our liking in our case we will create a new one as follows php artisan make migration create posts tableNow we have our migration but some more things are missing like controller model seeders factory request that will help us with our project We can create them one by one with the artisan commands but Laravel allows us to automate this and create everything with a single command we are going to delete the migration of posts that we have created And let s run the command php artisan make model Post allThis command will create Model factory seeder requests controller and policy We ll use them in a moment but first we ll go to the database migrations folder and open the last migration that was done and we ll see something like this lt phpuse Illuminate Database Migrations Migration use Illuminate Database Schema Blueprint use Illuminate Support Facades Schema return new class extends Migration Run the migrations return void public function up Schema create posts function Blueprint table table gt id table gt timestamps Reverse the migrations return void public function down Schema dropIfExists posts Inside the up function we are going to define our table fields the fields that we will use for now will be id title content deleted at and the timestamps that are created at and updated at by default So our function would look like this public function up Schema create posts function Blueprint table table gt id table gt string title table gt text content table gt dateTime deleted at gt nullable table gt timestamps Ready now we have our migration ready now for this to be reflected in our database we have to run a command remember that the database you configured must already be created but without any table run migrations php artisan migrateAs you can see all our tables have names in the plural and our model in the singular due to the convention used by Laravel I recommend that all the models and tables have names in English to follow the convention The next thing we are going to do is fill our post table with fake data to be able to develop the list method and not do inserts in our database since it is tedious for this we can use the Laravel factories so we have already created our factory thanks to the command we used above but don t worry you can create others with the command php aritsan make factory NameFactoryIn our databases factories PostFactory file we have a method called definition inside the return we can do the following public function definition return title gt this gt faker gt sentence content gt this gt faker gt paragraph deleted at gt null What this will do is use faker to be able to fill our table with fake data but now we have to call it and use this we use it in the database seeders DatabaseSeeders file lt phpnamespace Database Seeders use Illuminate Database Seeder class DatabaseSeeder extends Seeder Seed the application s database return void public function run App Models Post factory gt create As you can see we use the Post model and we say that it creates records with the factory method if you use another version of Laravel the syntax may change but you can see it in the official documentation You may wonder what the seeders are for the seeders are where you can insert data into your database using eloquent methods which is the orm that Laravel has configured by default The factories are the ones that help us generate some records with fake data in a massive way passing only a certain number of records as you already realized a query builder is not used it is only enough to indicate the fields and the value they will have That is why the factories are called within the database seeder the other seeders also have to be called within the database seeder since this is the only one that is executed when we call them using the command php artisan db seed Seeders are executed and records will be inserted into our tableNow we know what migrations seeders and factories are for now we will start creating our api routes and methods In the routes folder we have several files as you can see we have web php api php channels and console We will concentrate on just the web and api where web is for web routes and api is the one we are going to use in this tutorial in the api php file we have a defined route which is the following Route middleware auth sanctum gt get user function Request request return request gt user We are going to delete this and we are going to create a route as follows Route get hello function return Hello World As we can see we prepend the Route class with its method which is the verb that we will have in this route as the second parameter we can use a callback and return a text Now we will test this in postman To start the development server we can execute the command php artisan serveDone but now we must start creating our routes for our api we will use versioning for our api since this way we will use a good practice and our api can grow without affecting other projects that use it We will create the routes Laravel allows us to create routes together with a single line which we will do as follows Route resource v posts PostController class gt only index We use resource to create several routes but since we will only use the index method for now we will tell it through the only function that we only want that route and so we can add the ones we need You will also notice that we add v to the endpoint of our resources this is to be able to mutate our api quickly and safely without other apps that use it breaking in the future for example if we want to change the way the data is displayed or we want to remove fields from our api we would create a resource with v and thus we can better control how our api has changed over timeNow something very important we are going to create the controller of our posts we already have a controller but we are not going to use it we are going to create another controller with the command php artisan make controller Api V PostController apiReady now we have our api Controllers and versioned these are located in the app Http Controllers Api folder and here we can create the v v folder as needed When we created our controller we told it to be of type api with the api flag so we will only have methods unlike normal api controllers which have methods Now we need to change the controller that we reference our route to in the api php file lt phpuse App Http Controllers Api V PostController use Illuminate Support Facades Route Route resource v posts PostController class gt only index With doing this we have it ready now we will start creating our main endpointLet s see what routes we have in our laravel and what controller method is executed when we call them We see this with the command php artisan route listAs we can see we have a few default routes but the one that interests us is the one in position as you can see it is called api v posts and as you can see it has this Api V PostController index this means that when we call this route will execute the index method so that is where we are going to write the logic to respond to the client We are going to make a call to our database and we are going to make the records come ordered and paginated then we will return it as a response of type json The method would be something like this public function index posts Post latest gt paginate return response gt json posts In this way we return the posts as json to the client so now we will see how the data arrives from the postman Ready we already have the response in a paginated way now we are going to work on our second endpoint which is the show method to show a single post according to the id of the parameters for this we must in our api php add another method apart from the index that this would be the show and we will change our resource method to apiResource this so that it does not create more unnecessary routes since the resource has routes this one only has Route apiResource v posts PostController class gt only index show Now if we list our routes we will see a new one that is GET HEAD api v posts post posts show ›Api V PostController showAs we can see this retains a post this refers to the fact that we must pass the id of our post to be able to show the info So let s go to the controller to modify the show method public function show id First we have to look for the post in our database and then return it as a response We have a parameter which is the id that the user puts in the url and thanks to eloquent and the simplicity of laravel we can do the following public function show Post post return response gt json post Adding the Model as the type of the variable Laravel understands this and gives you the record to which the model belongs Now let s see in postman That easy we already have the show method of our api Now we will see the delete method The same process we add the method to our resource in api php and go to the destroy method in our controller Route apiResource v posts PostController class gt only index show destroy PostController public function destroy id Here we can do the same as in the show make Laravel bring us the record automatically public function destroy Post post post gt deleted at now post gt save return response gt json message gt Post deleted Response HTTP NO CONTENT As you can see we only reassign the value of the deleted at field with the now function and the logical deletion is done we do not delete it from the database We return null and as a second parameter we pass a no content code which is we can send it as a number but I prefer to use Response you can see the rest of the code in the official Laravel doc Let s see this in the postman Now we will add that in our index method only the posts that are not deleted are seen so we will add a condition public function index posts Post where deleted at null gt latest gt paginate return response gt json posts In this way this method is solved and the deleted posts will no longer be shown Now we will add that in our show method we do not want the ifno of a deleted post to be seen so we will add an if public function show Post post if post gt deleted at return response gt json message gt Post have been deleted Response HTTP NOT FOUND else return response gt json post We already have solved this other method that easy But what happens if we do the following As you can see we have an html error which is not right so how do we fix this Whenever we consume an api in Laravel we must pass the property in the headersAccept application jsonWith this Laravel already knows that it should send us the error in json so now we will obtain the following response We have a problem which is that I don t want to show this error in this way to the users so we will change the show function in this way public function show id try post Post where deleted at null gt findOrFail id return response gt json post catch ModelNotFoundException e return response gt json message gt e gt getMessage Response HTTP NOT FOUND As you can see we are now using the findOrFail method this will throw us a ModelNotFoundException type exception and we will return the message with a not found code In this way we obtain a shorter message and we do not detail the user so much for security reasons message No query results for model App Models Post Post deleted Now we can do the same in the destroy method public function destroy id try post Post where deleted at null gt findOrFail id post gt deleted at now post gt save return response gt json null Response HTTP NO CONTENT catch ModelNotFoundException e return response gt json message gt e gt getMessage Response HTTP NOT FOUND We are almost done now we are going to format our responses since we are now returning the model and this is not done in Laravel in this way We ll do it using resources and collections The resources help us to format our model and thus return the collections they are exactly the same but it is to return collections we see it in practice Now we will create a resource as follows php artisan make resource V PostResourceHere we will also apply versioning since we can mutate these resources as our api grows Now we go to the file app Http Resources V PostResource lt phpnamespace App Http Resources V use Illuminate Http Resources Json JsonResource class PostResource extends JsonResource Transform the resource into an array param Illuminate Http Request request return array Illuminate Contracts Support Arrayable JsonSerializable public function toArray request return title gt this gt title content gt this gt body created at gt this gt created at We make a return and assign keys and what field we want to be assigned I will leave it this way and now we are going to use it in our PostController public function show id try post Post where deleted at null gt findOrFail id return new PostResource post catch ModelNotFoundException e return response gt json message gt e gt getMessage Response HTTP NOT FOUND Here we return a new instance of the post resource remember that we can only pass one record to our resource for several records we are going to create a collection but for this I will use a version of my api and we will understand the advantages of this practice First we will create the routes resource in api php lt phpuse App Http Controllers Api V PostController as PostControllerV use App Http Controllers Api V PostController as PostControllerV use Illuminate Support Facades Route Route apiResource v posts PostControllerV class gt only index show destroy Route apiResource v posts PostControllerV class gt only index As you can see I create the route only with the index method and I create another controller in the V folder of controllers and I assign an alias to it to avoid conflict in the imports now we create the controller php artisan make controller Api V PostController apiNow we are going to do the index method just like in the PostController version V PostControllerpublic function index posts Post where deleted at null gt latest gt paginate return response gt json posts Ready we have it let s see the postman As you can see it is exactly the same but now in version I only want to send the id and the title so for this we are going to create the collection that will help us give this a structure php artisan make resource V PostCollectionNow we go to the File app Http Resources V PostCollectionand we would have to do something like this public function toArray request return data gt this gt collection target gt organization gt com jordan author gt name gt Jordan email gt jordan mail com type gt post As you can see we add more information and within the data property I want it to return all the data of the collection We use this in V PostController V PostControllerpublic function index posts Post where deleted at null gt latest gt paginate return new PostCollection posts But we have a problem although our structure has changed all the post fields are still displayed To solve this we create a v resource and we will use it in our collection php artisan make resource V PostResourceAnd we modify it lt phpnamespace App Http Resources V use Illuminate Http Resources Json JsonResource class PostResource extends JsonResource Transform the resource into an array param Illuminate Http Request request return array Illuminate Contracts Support Arrayable JsonSerializable public function toArray request return id gt this gt id title gt this gt title Now we have to tell our collection to use this resource lt phpnamespace App Http Resources V use Illuminate Http Resources Json ResourceCollection class PostCollection extends ResourceCollection public collects PostResource class Transform the resource collection into an array param Illuminate Http Request request return array Illuminate Contracts Support Arrayable JsonSerializable public function toArray request return data gt this gt collection target gt organization gt com jordan author gt name gt Jordan email gt jordan mail com type gt post In this way we solve our problem So the applications that consume our old api will not have problems or will fall In this way we have made an api with a few methods applying good programming practices as recommended by the laravel documentation The challenge is that you finish the update and store methods of the api as well as the other methods of version If something is not clear to you you can comment and I will help you with pleasure You can find the complete code in the following github repository 2022-03-18 20:30:28
Apple AppleInsider - Frontpage News Save up to 90% on iPhone cases and photography accessories at Moment https://appleinsider.com/articles/22/03/18/save-up-to-90-on-iphone-cases-and-photography-accessories-at-moment?utm_medium=rss Save up to on iPhone cases and photography accessories at MomentPhotography gear retailer Moment is holding a special sale offering steep discounts on a variety of iPhone cases lenses and more The Moment Rugged Case selection and Moment Wide mm Lens are on saleYou ll find a wide range of phone cases at incredibly low prices as well as other photography centric accessoriesーsome you may not have even known you needed Read more 2022-03-18 20:34:37
海外TECH Engadget LG halts all shipments to Russia https://www.engadget.com/lg-halts-shipments-to-russia-203101113.html?src=rss LG halts all shipments to RussiaLG is joining other tech heavyweights in halting Russian sales following that country s invasion of Ukraine The company said in a statement it was quot suspending quot all product shipments to Russia The firm didn t say how long this would last but noted it would keep a quot close watch quot on the situation LG is quot deeply concerned quot about everyone s welfare and quot committed quot to humanitarian relief according to the notice It s not clear just what prompted the timing of the decision which comes weeks after the late February invasion There s a lot of pressure to act however Apple Microsoft Samsung and others have already frozen shipments and sales in Russia ーLG wasn t going to look good if it continued to serve the Russian market despite that country s war against Ukraine This move could be particularly damaging While LG has left the phone industry it s still a major force in electronics that makes everything from TVs through to air conditioners and refrigerators Between LG s move and Samsung s Russia will have lost two of the largest device brands on the planet Russians are likely to still have options thanks to brands from China and elsewhere but their choices will be considerably narrower 2022-03-18 20:31:01
海外TECH Engadget Xbox Cloud Gaming now works on Steam Deck through the web https://www.engadget.com/xbox-cloud-gaming-steam-deck-support-edge-browser-202511356.html?src=rss Xbox Cloud Gaming now works on Steam Deck through the webYour Steam Deck can now double as an Xbox Cloud Gaming handheld provided you re willing to put in some work The Vergereports Microsoft has brought Xbox Cloud Gaming support to the Steam Deck through a beta release of the Edge browser You ll need to run some command line tasks on top of installing Edge Microsoft recommends a mouse and keyboard during the install but after that you can play Halo Infinite and other titles anywhere you have a reasonably fast internet connection Community Manager Missy Quarry made clear this was quot just the beginning quot of gaming on Edge suggesting the experience might get better Microsoft s team is open to feedback on Edge and the Xbox Cloud Gaming experience Microsoft has devoted significant energy to Steam Deck Support in recent days On top of game streaming support it outlined first party game support for Valve s handheld with word that titles like Deathloop and Psychonauts are verified to play properly Separately Valve enabled basic Windows support by offering drivers It s not shocking that Microsoft would support the Steam Deck despite its use of a Linux based platform Microsoft not only makes money from the Xbox Game Pass Ultimate subscription you ll need to play but gets you to try Edge and games you might have otherwise ignored What the company might lose in immediate Windows sales it could gain in long term customers 2022-03-18 20:25:11
海外TECH Engadget Delivery apps are stepping in to help drivers hit by high gas prices https://www.engadget.com/delivery-apps-are-stepping-in-to-help-drivers-hit-by-high-gas-prices-200936124.html?src=rss Delivery apps are stepping in to help drivers hit by high gas pricesRussia s invasion of Ukraine and the resulting economic sanctions against the aggressor nation are already causing economic havok the world over Inflation is on the rise causing the price of essentials like food medicine and fuel to spike Domestically these additional financial strains are being deeply felt by gig economy workers and delivery drivers who are now struggling to stay on the road as gas averages a gallon nationwide In response some delivery apps have extended financial lifelines to the quot independent contractors quot that their businesses rely upon ーbut not all of them and not entirely without a catch Instacart is the latest service to adjust its pricing in response announcing on Friday morning that it will institute a cent per order surcharge quot over the next month quot to help offset the increased costs to its drivers which have seen a cent increase since February th nbsp Uber has already imposed a fuel surcharge of its own though the amount depends on which state the driver is in and how far the trip is going Roughly the surcharge for a passenger Uber ride will be between to per trip while having the food brought to you instead of the other way around will see a to per trip charge added on The charge went into effect on Wednesday and will be reevaluated in days according to the company Uber beacon of fair labor practices that it is has made assurances that the added charges will go directly to drivers And yes cheapskates the surcharge applies even if you and or your food is riding in an EV nbsp Nearly identically Lyft announced on Monday that it will charge a flat per trip fee ーICE vehicle or not ーstarting next week and leave it in place for days Additionally drivers can get percent cashback on gas through June if they use the company branded debit card nbsp quot We ve been closely monitoring rising gas prices and their impact on our driver community quot Lyft senior communications manager CJ Macklin told Engadget in a statement quot Driver earnings overall remain elevated compared to last year but given the rapid rise in gas prices we ll be asking riders to pay a temporary fuel surcharge all of which will go to drivers quot nbsp DoorDash has enacted a similar cashback scheme for its drivers as well though you ll want to grab a pencil and calculator before trying to navigate it nbsp quot Beginning on March th drivers for Doordash will be able to receive cashback on gas purchases though only if they re enrolled in the company s own DasherDirect Visa cards quot Engadget reporter Amrita Khalid explains quot On top of that drivers who drive a certain amount of miles per week will qualify for weekly gas rewards ranging from to per week Unlocking the discount requires drivers to complete at least miles worth of trips in a week Drivers who total more than miles worth of trips will earn a weekly bonus quot That translates into around of rewards per gallon depending on the distance a Dasher drives nbsp Amazon Flex workers ーdrivers who use their own vehicles to make deliveries for the online retailer s Prime Whole Foods and Fresh branded orders ーhave not unsurprisingly largely been left to their own devices in navigating these higher fuel prices quot We ve already made several adjustments through pricing surges in impacted areas to help ease some of the financial challenges an Amazon spokesperson told MSNBC on Thursday “As the situation evolves we ll continue to make changes where we can to help support our partners The company is quot closely monitoring the situation quot said the spokesperson Engadget has reached out to Caviar owned by DoorDash GrubHub Postmates owned by Uber and Shipt for comment and will update this post upon their replies 2022-03-18 20:09:36
ニュース BBC News - Home Ukraine crisis: Calls for clarity on refugee matching process https://www.bbc.co.uk/news/uk-60791696?at_medium=RSS&at_campaign=KARANGA ukraine 2022-03-18 20:33:21
ニュース BBC News - Home Johnson-Thompson withdraws from pentathlon at World Indoor Championships https://www.bbc.co.uk/sport/athletics/60796405?at_medium=RSS&at_campaign=KARANGA Johnson Thompson withdraws from pentathlon at World Indoor ChampionshipsBritain s Katarina Johnson Thompson says for me this is a triumph after withdrawing from the pentathlon at the World Athletics Indoor Championships 2022-03-18 20:41:25
ビジネス ダイヤモンド・オンライン - 新着記事 落合博満氏のリーダー像がビジネスパーソンに刺さる理由、『嫌われた監督』の著者が解説 - 有料記事限定公開 https://diamond.jp/articles/-/298615 中日ドラゴンズ 2022-03-19 05:25:00
ビジネス ダイヤモンド・オンライン - 新着記事 「リモート認知症介護」当事者のおすすめ便利グッズ10選、離れていてもこれで安心! - 決定版 後悔しない「認知症」 https://diamond.jp/articles/-/298636 「リモート認知症介護」当事者のおすすめ便利グッズ選、離れていてもこれで安心決定版後悔しない「認知症」現役世代は、田舎に住んでいる認知症の親と同居は難しい。 2022-03-19 05:20:00
ビジネス ダイヤモンド・オンライン - 新着記事 在宅介護で「コスパがいい」サービスは?費用と内容の徹底分析で公的介護保険を使い倒す - 決定版 後悔しない「認知症」 https://diamond.jp/articles/-/298635 公的介護保険 2022-03-19 05:15:00
ビジネス ダイヤモンド・オンライン - 新着記事 暴君プーチンの頭の中、NATO分断を目論む「デカップリング」戦略とは - 週刊ダイヤモンド特集セレクション https://diamond.jp/articles/-/298878 2022-03-19 05:10:00
ビジネス ダイヤモンド・オンライン - 新着記事 花王、資生堂、ユニ・チャームで最も増収率が高かった企業とその要因は? - ダイヤモンド 決算報 https://diamond.jp/articles/-/299546 花王、資生堂、ユニ・チャームで最も増収率が高かった企業とその要因はダイヤモンド決算報コロナ禍が年目に突入し、多くの業界や企業のビジネスをいまだに揺さぶり続けている。 2022-03-19 05:05:00
北海道 北海道新聞 岩手で震度5強、津波なし 一関市2200戸停電 https://www.hokkaido-np.co.jp/article/658787/ 一関市戸停電日午後時分 2022-03-19 05:32:41
北海道 北海道新聞 <社説>ロシア軍の蛮行 政治体制転覆許されぬ https://www.hokkaido-np.co.jp/article/658775/ 体制転覆 2022-03-19 05:05:00
ビジネス 東洋経済オンライン コロナで「売れた」「売れなくなった」商品TOP30 オミクロン感染拡大後、「検査薬」が突然の飛躍 | 消費・マーケティング | 東洋経済オンライン https://toyokeizai.net/articles/-/539451?utm_source=rss&utm_medium=http&utm_campaign=link_back 感染拡大 2022-03-19 05:40:00
ビジネス 東洋経済オンライン 岸田首相にも打撃!河井事件「34人一転起訴」の謎 安倍氏、菅氏へ検察が牽制とのうがった見方も | 国内政治 | 東洋経済オンライン https://toyokeizai.net/articles/-/540084?utm_source=rss&utm_medium=http&utm_campaign=link_back 国内政治 2022-03-19 05:20:00
ビジネス 東洋経済オンライン 国立大学長が語る「日本の研究力復活」の必須条件 10兆円ファンドは賛成だがそれだけでは不十分 | 先端科学・研究開発 | 東洋経済オンライン https://toyokeizai.net/articles/-/539375?utm_source=rss&utm_medium=http&utm_campaign=link_back 国立大学協会 2022-03-19 05:10:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)