Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > บทความจากสมาชิก > Laravel::Respone การจัดการ redirect ในสไตน์ของ Laravel



 
Clound SSD Virtual Server

Laravel::Respone การจัดการ redirect ในสไตน์ของ Laravel

Laravel::Respone การจัดการ redirect ในสไตน์ของ Laravel ครับ หัวข้อนี้ว่าด้วยการการส่งกลับนะครับ ใน Laravel ใช้ฟังชัน Redirect::to() ซึ่งท่านอาจะลองเอาไปเปรียบเทียบความกระชับและง่ายกับ ตัวอื่นดูก็ได้นะครับ

การ redirect แบบพื้นฐาน
Code (PHP)
return Redirect::to('user/profile');


redirect แล้วส่งค่าไปด้วย
Code (PHP)
     return Redirect::to('user/profile', 301);


redirect ไปด้วย https
Code (PHP)
return Redirect::to_secure('user/profile');


redirect ไปหน้าแรก
Code (PHP)
    return Redirect::home();


Redirect กลับไปก่อนหน้านี้
Code (PHP)
return Redirect::back();


Redirect ไปยัง route ที่สร้างไว้
Code (PHP)
return Redirect::to_route('profile');


Redirect ไป method ใน controller
Code (PHP)
	return Redirect::to_action('home@index');


Redirect ไปพร้อมกับพารามิเตอร์
Code (PHP)
return Redirect::to_route('profile', array($username));


Code (PHP)
return Redirect::to_action('user@profile', array($username));


แสดง Flash Data หลังการ redirect
หลังจากเรา login หรือ logout ก็สามารถสร้าง flash message บอกได้

Code (PHP)
	return Redirect::to('profile')->with('status', 'Welcome Back!');


สามารถเซตค่าคำประกาศในคลาส Sessiom นะครับ
Code (PHP)
$status = Session::get('status');



Downloads ส่งไฟล์ให้ผู้ใช้งานโหลดโดยใช้ Class Respone ครับ
Code (PHP)
return Response::download('file/path.jpg');


Errors
อีกความสามารถของ Class Respone ในการตอบกลับค่า error โดย View ที่จะแสดงเราต้องไปเซตใน ไฟล์ route ครับ
สร้างการตอบกลับ ว่าไม่มีหน้าที่เรียก
Code (PHP)
return Response::error('404');


สร้างการตอบกลับว่า Server ไม่ทำงาน
Code (PHP)
	return Response::error('500');


Reference : http://www.laravel.com





   
Share
Bookmark.   

  By : taqman
  Article : บทความเป็นการเขียนโดยสมาชิก หากมีปัญหาเรื่องลิขสิทธิ์ กรุณาแจ้งให้ทาง webmaster ทราบด้วยครับ
  Score Rating :
  Create Date : 2013-05-10
  Download : No files
Sponsored Links
ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่