#laravel 5.5 new features series
Explore tagged Tumblr posts
Text
[ Part 05 laravel 5.5 new features series ] Introduction to New Feature of Mailable in urdu 2018
[ Part 05 laravel 5.5 new features series ] Introduction to New Feature of Mailable in urdu 2018
[ad_1]
Hello Friends, Welcome to Part 05 of laravel 5.5 new features series by perfect web solutions. In this video tutorial, we will get Introduction to new Mailable Features in Urdu and Hindi language 2018. Laravel provides a clean, simple API over the popular SwiftMailer library with drivers for SMTP, Mailgun, SparkPost, Amazon SES, PHP’s mail function, and sendmail, allowing you to quickly…
View On WordPress
#...#Introduction to New Mailable Features#laravel#laravel 5.5 new features series#laravel 5.5 tutorial in urdu 2018#Mailable Features in urdu#perfect web solutions
0 notes
Video
youtube
With the beginning of 2019, I've decided to code a little startup. I've been programming in an advertising agency for 5 years now and have 8 years experience. I love to code for a hobby and found out this could be a good start to make something on my own. Either for profit or just for fun. The weapon of choice is Laravel 5.5. The frontend will be based on Vue.js Watch other videos from this series: - Part 1: https://youtu.be/n9GzppuVgfs - Part 2: https://www.youtu.be/KjKBqC1ktBM If you are a beginner then I hope you've learned something from this video. If something is unclear, feel free to write a comment and I'll try to answer it. If you are a professional and would like to give me an advice, please leave a comment, I'd be happy to make the app better and learn something new. Find this video helpful in any way? Be sure to drop a like & comment to motivate me to make more videos like this: https://goo.gl/S7S5wU Don't forget to click the "bell" next to the subscribe button and select "Send me all notifications for this channel". Check out my gear on Kit: http://bit.ly/2VuRVp8 About the framework: Laravel is a free, open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller (MVC) architectural pattern and based on Symfony. Some of the features of Laravel are a modular packaging system with a dedicated dependency manager, different ways for accessing relational databases, utilities that aid in application deployment and maintenance, and its orientation toward syntactic sugar. The source code of Laravel is hosted on GitHub and licensed under the terms of MIT License. http://bit.ly/2AeAxtq Social Networks: - Instagram: http://bit.ly/2VjOQrX - Twitter: https://www.twitter.com/_colorscream - Facebook: http://bit.ly/2QgvHDi - Patreon: http://bit.ly/2Vm2zOG Music credits: Waking Dreams - Moments Andy Leech - I Love You AK & Mapps - IV Wiljan & Xandra - Woodlands DNZ - Wanderlust Wiljam - Faraway AK - Our Destination Broke For Free - Smoke Sill Nomyn - The Journey Sappheiros - Embrace Cash - Heaven Above Ferven - Scattered Thoughts Whithe - Smoother Here we go channel: http://bit.ly/29etmV2 http://bit.ly/29dFWaQ http://youtube.com/c/HearWeGoCopyrightFreeMusic https://twitter.com/hearwegochannel http://bit.ly/29etuE1 Photo credits: luis gomes / pexels.com #startup #livecoding #laravel
1 note
·
View note
Text
WHAT’S NEW IN LARAVEL 5.5 Laracasts
WHAT’S NEW IN LARAVEL 5.5 Laracasts
WHAT’S NEW IN LARAVEL 5.5 Laracasts
Here we go again! Currently scheduled for an August release date, we’re on the verge of Laravel 5.5. With that in mind, let’s get a head start on the new features and additions to the framework. As always, there’s quite a few!
Content From: https://laracasts.com/series/whats-new-in-laravel-5-5.
View On WordPress
0 notes
Text
Build a React App With a Laravel Back End: Part 2, React
What You'll Be Creating
This is the second and final part of the series on building a React application with a Laravel back end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be developing the front end using React.
We will also consider all the available options to bridge the gap between Laravel and React. You don't need to have followed part one of the series to understand this tutorial. If you're here to see how React and Laravel fare together, you can, in fact, avoid the first part. You should head over to GitHub, clone the repo, and take the quick recap down below to get started.
A Quick Recap
In the previous tutorial, we developed a Laravel application that responds to API calls. We created routes, a controller, and a model for the simple product listing application. Since it was the controller's job to return a response to the HTTP requests, the view section was entirely skipped.
Then we discussed techniques for exception handling and validation using Laravel. By the end of the tutorial, we had a Laravel back-end API. We can now use this API to build applications for both the web and a wide range of mobile devices.
In this tutorial, we will be shifting our focus towards the front end. The first half of the tutorial is about setting up React in a Laravel environment. I will also introduce you to Laravel Mix (supported by Laravel 5.4 and later), which is an API for compiling assets. In the second half of the tutorial, we will start building a React application from scratch.
Setting Up React in Laravel
Laravel Mix was introduced in Laravel 5.4, and it is currently the ideal way to hook up React and Laravel. With Laravel 5.5, the whole process was made much easier. I've described both methods below.
Using the React Preset Command (Laravel 5.5)
Laravel 5.5 has a brand new feature that lets you scaffold the code for React components using artisan's preset react command. In previous versions of Laravel, setting up React inside Laravel wasn't this easy. If you're running the latest version of Laravel, then run the below command to add a React preset to your project.
php artisan preset react
Laravel by default gets shipped with the Vue preset, and the above command replaces all instances of Vue with React. Interestingly, if you don't need a preset, you can remove them altogether using the php artisan preset none command.
If everything goes well, this should show up in your terminal.
React scaffolding installed successfully. Please run "npm install && npm run dev" to compile your fresh scaffolding.
In the background, Laravel uses Laravel Mix, which is a smooth wrapper for webpack. Webpack, as you might already know, is a module bundler. It resolves all the module dependencies and generates the necessary static assets for JavaScript and CSS. React requires a module bundler to work, and webpack perfectly fits into that role. So Laravel Mix is the layer that sits on top of webpack and makes it easier to use webpack in Laravel.
A better understanding of how Laravel Mix works is important if you need to customize the webpack configuration at a later time. The React preset command gives us no information about how things work in the background. So let's remove the React preset and retrace the steps manually instead.
Manual Method (Laravel 5.4)
If you're running Laravel 5.4, or if you are just curious to see how Laravel Mix is configured, here are the steps that you need to follow:
Install react, react-dom and babel-preset-react using npm. It might be a good idea to have yarn installed too. It's no secret that Laravel and React prefer yarn over npm.
Head over to webpack.mix.js, located inside the root directory of your Laravel project. This is the configuration file where you declare how your assets should be compiled. Replace the line mix.js('resources/assets/js/app.js', 'public/js'); with mix.react('resources/assets/js/app.js', 'public/js');. app.js is the entry point for our JavaScript files, and the compiled files will be located inside public/js. Run npm install in the terminal to install all the dependencies.
Next, go to resources/assets/js. There's already a components folder and a couple of other JavaScript files. React components will go into the components directory. Remove the existing Example.vue file and create a new file for a sample React component.
resources/assets/js/component/Main.js
import React, { Component } from 'react'; import ReactDOM from 'react-dom'; /* An example React component */ class Main extends Component { render() { return ( <div> <h3>All Products</h3> </div> ); } } export default Main; /* The if statement is required so as to Render the component on pages that have a div with an ID of "root"; */ if (document.getElementById('root')) { ReactDOM.render(<Main />, document.getElementById('root')); }
Update app.js to remove all the Vue-related code and import the React component instead.
resources/assets/js/app.js
require('./bootstrap'); /* Import the Main component */ import Main from './components/Main';
Now, we just need to make the assets accessible to the View. The view files are located inside the resources/views directory. Let's add a <script> tag to welcome.blade.php, which is the default page rendered when you navigate to localhost:8000/. Remove the contents of the view file and replace it with the code below:
resources/views/welcome.blade.php
<!doctype html> <html lang=""> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Laravel React application</title> <link href="" rel="stylesheet" type="text/css"> </head> <body> <h2 style="text-align: center"> Laravel and React application </h2> <div id="root"></div> <script src="" ></script> </body> </html>
Finally, execute npm run dev or yarn run dev to compile the assets. If you visit localhost:8000, you should see:
React embedded inside Laravel's view.
The package.json has a watch script that auto-compiles the assets when any changes are detected. To enable this mode, run npm run watch.
Congrats, you've successfully configured React to work with Laravel. Now, let's create some React components for the front end.
Developing the React Application
If you're new to React, you will find the rest of the tutorial somewhat challenging. I recommend taking the React Crash Course for Beginners series to get acquainted with the React concepts better. Let's get started!
A React application is built around components. Components are the most important structure in React, and we have a directory dedicated for components.
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called "props") and return React elements describing what should appear on the screen. — Official React Docs
For the application that we are building, we will start with a basic component that displays all the products returned by the server. Let's name it the Main component. The component should take care of the following things initially:
Fetch all the products from the API (GET /api/products).
Store the product data in its state.
Display the product data.
React isn't a full-fledged framework, and hence the library doesn't have any AJAX features on its own. I will be using fetch(), which is a standard JavaScript API for fetching the data from the server. But there are tons of alternatives to make AJAX calls to the server.
resources/assets/js/component/Main.js
import React, { Component } from 'react'; import ReactDOM from 'react-dom'; /* Main Component */ class Main extends Component { constructor() { super(); //Initialize the state in the constructor this.state = { products: [], } } /*componentDidMount() is a lifecycle method * that gets called after the component is rendered */ componentDidMount() { /* fetch API in action */ fetch('/api/products') .then(response => { return response.json(); }) .then(products => { //Fetched product is stored in the state this.setState({ products }); }); } renderProducts() { return this.state.products.map(product => { return ( /* When using list you need to specify a key * attribute that is unique for each list item */ <li key={product.id} > { product.title } </li> ); }) } render() { /* Some css code has been removed for brevity */ return ( <div> <ul> { this.renderProducts() } </ul> </div> ); } }
Here we're initializing the state of products to an empty array in the constructor. Once the component mounts, we use fetch() to retrieve the products from /api/products and store it in the state. The render method is used to describe the UI of the component. All the products get rendered as a list there.
The page just lists the product titles, which is boring. Moreover, we don't have any interactive elements in there yet. Let's make the product title clickable, and on click, more details about the product will get rendered.
Displaying Product Data
Here's the list of things that we need to cover:
A state to track the product that was clicked. Let's call it currentProduct with an initial null value.
When a product title is clicked, this.state.currentProduct is updated.
The product details of the concerned product are displayed on the right. Until a product is selected, it displays the "No product selected" message.
resources/assets/js/component/Main.js
import React, { Component } from 'react'; import ReactDOM from 'react-dom'; /* Main Component */ class Main extends Component { constructor() { super(); /* currentProduct keeps track of the product currently * displayed */ this.state = { products: [], currentProduct: null } } componentDidMount() { //code omitted for brevity } renderProducts() { return this.state.products.map(product => { return ( //this.handleClick() method is invoked onClick. <li onClick={ () =>this.handleClick(product)} key={product.id} > { product.title } </li> ); }) } handleClick(product) { //handleClick is used to set the state this.setState({currentProduct:product}); } render() { /* Some css code has been removed for brevity */ return ( <div> <ul> { this.renderProducts() } </ul> </div> ); } }
Here we've added createProduct into the state and initialized it with the value null. The line onClick={ () =>this.handleClick(product) } invokes the handleClick() method when the list item is clicked. The handleClick() method updates the state of currentProduct.
Now to display the product data, we can either render it inside the Main component or create a new component. As previously mentioned, splitting the UI into smaller components is the React way of doing things. So we will create a new component and name it Product.
The Product component is nested inside the Main component. The Main component passes its state as props. The Product component accepts this props as input and renders the relevant information.
resources/assets/js/component/Main.js
render() { return ( /* The extra divs are for the css styles */ <div> <div> <h3> All products </h3> <ul> { this.renderProducts() } </ul> </div> <Product product={this.state.currentProduct} /> </div> ); } }
resources/assets/js/component/Product.js
import React, { Component } from 'react'; /* Stateless component or pure component * { product } syntax is the object destructing */ const Product = ({product}) => { const divStyle = { /*code omitted for brevity */ } //if the props product is null, return Product doesn't exist if(!product) { return(<div style={divStyle}> Product Doesnt exist </div>); } //Else, display the product data return( <div style={divStyle}> <h2> {product.title} </h2> <p> {product.description} </p> <h3> Status {product.availability ? 'Available' : 'Out of stock'} </h3> <h3> Price : {product.price} </h3> </div> ) } export default Product ;
The application should look something like this now:
Adding a New Product
We've successfully implemented the front end corresponding to retrieving all the products and displaying them. Next, we need a form to add a new product to the product list. The process for adding a product might feel a bit more complex than just fetching the data from an API.
Here's what I think is required to develop this feature:
A new stateful component that renders the UI for an input form. The component's state holds the form data.
On submit, the child component passes the state to the Main component using a callback.
The Main component has a method, say handleNewProduct(), that handles the logic for starting a POST request. Upon receiving the response, the Main component updates its state (both this.state.products and this.state.currentProduct)
That doesn't sound very complex, does it? Let's do it step by step. First, create a new component. I am going to call it AddProduct.
resources/assets/js/component/AddProduct.js
class AddProduct extends Component { constructor(props) { super(props); /* Initialize the state. */ this.state = { newProduct: { title: '', description: '', price: 0, availability: 0 } } //Boilerplate code for binding methods with `this` this.handleSubmit = this.handleSubmit.bind(this); this.handleInput = this.handleInput.bind(this); } /* This method dynamically accepts inputs and stores it in the state */ handleInput(key, e) { /*Duplicating and updating the state */ var state = Object.assign({}, this.state.newProduct); state[key] = e.target.value; this.setState({newProduct: state }); } /* This method is invoked when submit button is pressed */ handleSubmit(e) { //preventDefault prevents page reload e.preventDefault(); /*A call back to the onAdd props. The current *state is passed as a param */ this.props.onAdd(this.state.newProduct); } render() { const divStyle = { /*Code omitted for brevity */ } return( <div> <h2> Add new product </h2> <div style={divStyle}> /*when Submit button is pressed, the control is passed to *handleSubmit method */ <form onSubmit={this.handleSubmit}> <label> Title: { /*On every keystroke, the handeInput method is invoked */ } <input type="text" onChange={(e)=>this.handleInput('title',e)} /> </label> <label> Description: <input type="text" onChange={(e)=>this.handleInput('description',e)} /> </label> { /* Input fields for Price and availability omitted for brevity */} <input type="submit" value="Submit" /> </form> </div> </div>) } } export default AddProduct;
The component basically renders an input form, and all the input values are stored in the state (this.state.newProduct). Then, on form submission, handleSubmit() method gets invoked. But AddProduct needs to communicate the information back to the parent, and we do this using a callback.
The Main component, which is the parent, passes a function reference as props. The child component, AddProduct in our case, invokes this props to notify the parent of the state change. So the line this.props.onAdd(this.state.newProduct); is an example of a callback that notifies the parent component of the new product.
Now, inside the Main component, we shall declare <AddProduct /> as follows:
<AddProduct onAdd={this.handleAddProduct} />
The onAdd event handler is chained to the component's handleAddProduct() method. This method hosts the code for making a POST request to the server. If the response indicates that the product has been successfully created, the state of products and currentProducts is updated.
handleAddProduct(product) { product.price = Number(product.price); /*Fetch API for post request */ fetch( 'api/products/', { method:'post', /* headers are important*/ headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify(product) }) .then(response => { return response.json(); }) .then( data => { //update the state of products and currentProduct this.setState((prevState)=> ({ products: prevState.products.concat(data), currentProduct : data })) }) }
Don't forget to bind the handleProduct method to the class using this.handleAddProduct = this.handleAddProduct.bind(this); in the constructor. And here's the final version of the application:
What Next?
The application is incomplete without the delete and update features. But if you've been following the tutorial closely until now, you should be able to fill in the void without much trouble. To get you started, I've provided you the event handler logic for both the delete and update scenario.
Logic for Deleting a Product
handleDelete() { const currentProduct = this.state.currentProduct; fetch( 'api/products/' + this.state.currentProduct.id, { method: 'delete' }) .then(response => { /* Duplicate the array and filter out the item to be deleted */ var array = this.state.products.filter(function(item) { return item !== currentProduct }); this.setState({ products: array, currentProduct: null}); }); }
Logic for Updating an Existing Product
handleUpdate(product) { const currentProduct = this.state.currentProduct; fetch( 'api/products/' + currentProduct.id, { method:'put', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify(product) }) .then(response => { return response.json(); }) .then( data => { /* Updating the state */ var array = this.state.products.filter(function(item) { return item !== currentProduct }) this.setState((prevState)=> ({ products: array.concat(product), currentProduct : product })) }) }
What you need to do is dive in, get your hands dirty, and finish the application using the above logic. I will drop you a hint: The delete button should ideally go inside the Product component, whereas the update feature should have a component of its own. I encourage you to take up this challenge and finish the missing components.
Summary
We've come a long way from where we started. First, we created a REST API using the Laravel framework. Then, we discussed our options for mixing Laravel and React. Finally, we built a front end to the API using React.
Although we primarily focused on creating a single-page application using React, you can create widgets or components that are mounted to specific elements in your views. React is very flexible because it's a library, and a good one.
Over the last couple of year, React has grown in popularity. In fact, we’ve a number of items in the marketplace that are available for purchase, review, implementation, and so on. If you’re looking for additional resources around React, don’t hesitate to check them out.
Have you tried experimenting with Laravel and React before? What are your thoughts? Share them with us in the comments.
via Envato Tuts+ Code http://ift.tt/2xyH9kp
0 notes
Text
Laravel 5.5 New Features - New Routing Methods #11
Laravel 5.5 New Features – New Routing Methods #11
[ad_1]
Laravel 5.5 New Features – Redirect and View : The New Routing Methods
Get news about Laravel 5.5 here.
Donate Any amount to Support Bitfumes via Paypal http://www.Paypal.me/bitfumes/10
Join Our Slack Community – https://goo.gl/pqCjZH
You May Also Like
Sass Beginner Series – https://goo.gl/rjH2MP
Vue Beginner To advanced Series…
View On WordPress
1 note
·
View note
Text
[ Part 03 Laravel 5.5 New Features Series ] Introduction of frontend scaffolding in Urdu 2018
[ Part 03 Laravel 5.5 New Features Series ] Introduction of frontend scaffolding in Urdu 2018
[ad_1]
Hello Friends, Welcome to Part 03 of Laravel 5.5 New Features Series, in this video tutorial, we will learn about new feature introduced in laravel 5.5 of php artisan preset type which will help us to manage front end scaffolding in laravel 5.5
If you like the video, then please do like it, then subscribe to our channel for more videos and don’t forget to press the Bell Icons.
اگر آپ کو…
View On WordPress
0 notes
Text
[ Part 04 Laravel 5.5 New Features Series ] Introduction to Form Validation and Rules in Urdu 2018
[ Part 04 Laravel 5.5 New Features Series ] Introduction to Form Validation and Rules in Urdu 2018
[ad_1]
Hello Friends,
Welcome to Part 04 of Laravel 5.5 New Features Series, in This Video Tutorial we will learn new Feature of Laravel 5.5 where we can define Form Validation as well as we can easily create Custom Validation Rules using New php artisan make:rule from the command line.
If you like the video, then please do like it, then subscribe to our channel for more videos and don’t forget…
View On WordPress
0 notes
Text
Dynamic templates in Laravel Blade with View::first
When building dynamic components or pages sometimes we want to display a custom template if it exists or otherwise fall back on a default one.
For example, imagine we are building a pages module, and some pages like “About Us” or “Contact Us” will need a custom template (for example to display pictures or a contact form), while others like “Terms of services” will do fine with a default template.
We can solve this problem with a series of conditionals or by using view()->exists() to check if a custom template exists or not, however, Laravel 5.5 brings us a better and more elegant way as I’ll demonstrate in the following video:
Using View::first
The view()->first() method allows us to replace the following code:
if (view()->exists('custom-template')) { return view('custom-template', $data); } return view('default-template', $data);
With a simpler, more expressive version:
return view()->first( ['custom-template', 'default-template'], $data );
You have to pass an array of templates as the first argument and the first method will load the first template it finds.
Of course, you can pass as many templates as you want and even use dynamic names:
return view()->first([ "pages/{$page->slug}", "pages/category-{$page->category->slug}", "pages/default-template" ], $data);
Remember you can also use this feature using its facade version:
\View::first($templates, $data)
This dynamic view loading feature was added to Blade in Laravel v5.5 and is a great way of keeping your controllers simple by avoiding extra conditionals when dealing with dynamic templates.
The post Dynamic templates in Laravel Blade with View::first appeared first on Laravel News.
via Laravel News http://ift.tt/2xkInmV
0 notes