This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::domain('{location}.example.com')->group(function () { | |
Route::get('employees/{id}/{name}', 'EmployeesController@show')->name('employees.show'); | |
}); | |
route('employees.show', ['location' => 'raleigh', 'id' => 5, 'name' => 'chris']); // http://raleigh.example.com/employees/5/chris |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get('burgers', 'BurgersController@index')->name('burgers'); | |
route('burgers'); // http://example.com/burgers | |
route('burgers', ['order_by' => 'price']); // http://example.com/burgers?order_by=price | |
Route::get('burgers/{id}', 'BurgersController@show')->name('burgers.show'); | |
route('burgers.show', 1); // http://example.com/burgers/1 | |
route('burgers.show', ['id' => 1]); // http://example.com/burgers/1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
str_plural('dog'); // dogs | |
str_plural('cat'); // cats | |
str_plural('dog', 2); // dogs | |
str_plural('cat', 1); // cat | |
str_plural('child'); // children | |
str_plural('person'); // people |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$array = ['albums' => ['rock' => ['count' => 75]]]; | |
$count = data_get($array, 'albums.rock.count'); // 75 | |
$avgCost = data_get($array, 'albums.rock.avg_cost', 0); // 0 | |
$object->albums->rock->count = 75; | |
$count = data_get($object, 'albums.rock.count'); // 75 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* 渲染頁面 | |
* resources/views/pages/about.blade.php | |
*/ | |
// 原始 | |
Route::get('/about', function() { | |
return view('pages.about'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$client = new \GuzzleHttp\Client(); | |
$response = $client->request('POST', 'https://api.imgur.com/3/image', [ | |
'headers' => [ | |
'authorization' => 'Client-ID ' . 'app_id', | |
'content-type' => 'application/x-www-form-urlencoded', | |
], | |
'form_params' => [ | |
'image' => base64_encode(file_get_contents($request->file('image')->path())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, 'https://api.imgur.com/3/image'); | |
curl_setopt($curl, CURLOPT_TIMEOUT, 30); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . 'app_id')); | |
curl_setopt($curl, CURLOPT_POST, 1); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, base64_encode(file_get_contents($request->file('image')->path()))); | |
$response = curl_exec($curl); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controllers; | |
use App\MemberLog; | |
class MemberLogController extends Controller | |
{ | |
protected $model; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
class MemberLog extends Model | |
{ | |
protected $table = 'cs_member_visit_log'; | |
protected $guarded = []; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function create($attributes) | |
{ | |
$typein = in_array($attributes['type'], ['SignUp', 'ShareVideo', 'Subscription']); | |
$existLog = $typein && $this->existLogs($attributes['type']); | |
$doSomething = $this->doSomething($attributes['type']); | |
if ($existLog OR $doSomething) { | |
throw new GetLimitTimesException('Oops! it\'s get in limit.'); |