Skip to content

Instantly share code, notes, and snippets.

View FrankFlow's full-sized avatar

FrankFlow FrankFlow

View GitHub Profile
<?php
public function test_get_all_books()
{
$book = factory(App\Book::class, 2)->create();
$this->get('books', ['accept' => 'application/json']);
$this->assertResponseOk();
$this->seeJsonStructure(['data' => [0, 1]])'
}
<?php
Route::get('books', 'BooksController@index');
Route::post('books', 'BooksController@store');
Route::get('books/{book_id}', 'BooksController@show');
Route::patch('books/{book_id}', 'BooksController@update');
Route::delete('books/{book_id}', 'BooksController@destroy');
<?php
\Cache::flush();
$variabile = \Cache::pull('nome');
\Cache::forget('nome');
<?php
// app/Http/routes.php
Route::get('/se_non_ci_sono_recupera_per_sempre', function(){
\Cache::forever('lavoro', function(){
return 'Web Developer'; // questo potrebbe essere il risultato di una query
});
});
<?php
\Cache::forever('nome', 'Francesco');
<?php
// app/Http/routes.php
Route::get('/esiste_cache', function(){
if (\Cache::has('lavoro'))
{
return \Cache::get('lavoro');
}
});
<?php
// app/Http/routes.php
Route::get('/se_non_ci_sono_recupera', function(){
$scadenza = \Carbon\Carbon::now()->addMinutes(10);
\Cache::remember('lavoro', $scadenza, function(){
return 'Web Developer'; // questo potrebbe essere il risultato di una query
});
})
<?php
//app/Http/routes.php
if ( \Cache::has('nome'))
{
return \Cache::get('nome');
}