To put it simply, Repository pattern is a kind of container where data access logic is stored. It hides the details of data access logic from business logic. In other words, we allow business logic to access the data object without having knowledge of underlying data access architecture. Mar 7, 2015 https://bosnadev.com/2015/03/07/using-repository-pattern-in-laravel-5
https://bosnadev.com/2015/03/07/using-repository-pattern-in-laravel-5
andersao/l5-repository
├── ├── ├── ├── ├── ├── ├──
http://kamranahmed.info/blog/2015/12/03/creating-a-modular-application-in-laravel
├── ├── ├── ├── ├── ├── ├── ├── ├── ├── ├── ├── ├── ├──
public function newDeal(Request $request) { $data = $request->all(); // some stuff $page = "new_deal/new_deal_" . $data['page']; return view($page, [ 'active_step' => $data['page'], 'template_step' => 'app_deal_steps', 'origin' => 'new_deal', 'title' => 'New Deal', 'customers' => new AppDeals(), ]); }
public function newDeal(Request $request) { $data = $request->all(); // some stuff $page = "new_deal/new_deal_" . $data['page']; return view($page, [ 'active_step' => $data['page'], 'template_step' => 'app_deal_steps', 'origin' => 'new_deal', 'title' => 'New Deal', 'customers' => new AppDeals(), ]); } X
public function newDeal(Request $request, AppDeals $deal) { $data = $request->all(); // some stuff $page = "new_deal/new_deal_" . $data['page']; return view($page, [ 'active_step' => $data['page'], 'template_step' => 'app_deal_steps', 'origin' => 'new_deal', 'title' => 'New Deal', 'customers' => $deal, ]); }
public function store(Request $request) { $result['message'] = 'Success'; try { $data = $request->all(); $userId = Auth::user()->id; $company = App::make(Company::class) ->where('created_by', $userId) ->first(); $company->save($data); } catch (Exception $error) { $result['message'] = $error->getMessage(); } return response()->json($result); }
$invoices = []; foreach ($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
$invoices = []; foreach ($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
$invoices = []; foreach ($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
$invoices = new Collection(); foreach ($request as $each) { $invoices->push(new Invoice([ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ])); }
// Retrieve the first item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
// Retrieve the first item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
// Retrieve the first item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
// Retrieve the first item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
$invoices = []; foreach ($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
public function update(Request $request) { // do something return Auth::user()->id; }
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016

Laravel, the right way - PHPConference 2016

  • 11.
    To put itsimply, Repository pattern is a kind of container where data access logic is stored. It hides the details of data access logic from business logic. In other words, we allow business logic to access the data object without having knowledge of underlying data access architecture. Mar 7, 2015 https://bosnadev.com/2015/03/07/using-repository-pattern-in-laravel-5
  • 12.
  • 13.
  • 14.
  • 34.
  • 35.
  • 37.
    public function newDeal(Request$request) { $data = $request->all(); // some stuff $page = "new_deal/new_deal_" . $data['page']; return view($page, [ 'active_step' => $data['page'], 'template_step' => 'app_deal_steps', 'origin' => 'new_deal', 'title' => 'New Deal', 'customers' => new AppDeals(), ]); }
  • 38.
    public function newDeal(Request$request) { $data = $request->all(); // some stuff $page = "new_deal/new_deal_" . $data['page']; return view($page, [ 'active_step' => $data['page'], 'template_step' => 'app_deal_steps', 'origin' => 'new_deal', 'title' => 'New Deal', 'customers' => new AppDeals(), ]); } X
  • 39.
    public function newDeal(Request$request, AppDeals $deal) { $data = $request->all(); // some stuff $page = "new_deal/new_deal_" . $data['page']; return view($page, [ 'active_step' => $data['page'], 'template_step' => 'app_deal_steps', 'origin' => 'new_deal', 'title' => 'New Deal', 'customers' => $deal, ]); }
  • 40.
    public function store(Request$request) { $result['message'] = 'Success'; try { $data = $request->all(); $userId = Auth::user()->id; $company = App::make(Company::class) ->where('created_by', $userId) ->first(); $company->save($data); } catch (Exception $error) { $result['message'] = $error->getMessage(); } return response()->json($result); }
  • 42.
    $invoices = []; foreach($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
  • 43.
    $invoices = []; foreach($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
  • 44.
    $invoices = []; foreach($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
  • 45.
    $invoices = newCollection(); foreach ($request as $each) { $invoices->push(new Invoice([ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ])); }
  • 46.
    // Retrieve thefirst item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
  • 47.
    // Retrieve thefirst item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
  • 48.
    // Retrieve thefirst item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
  • 49.
    // Retrieve thefirst item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
  • 50.
    $invoices = []; foreach($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
  • 60.
    public function update(Request$request) { // do something return Auth::user()->id; }