Alessandro Feitoza
Evangelist PHP | Community Manager/Founder PHP com Rapadura
Ativista e Militante do Software Livre
Fundador e Mantenedor do PHP com Rapadura
Programador Web no Projeto e-Jovem
Desenvolvedor na Dsigner ByCreator
Calisthenics é um termo grego = Exercício
protected function destroyFile(Model $record)
{
if (method_exists($record, 'getFileField')) {
$field = $record->getFileField();
$field = $record->$field;
if (!empty($field)) {
list($file, $extension) = explode('.', $field);
$extension = '.' . $extension;
$size = [
'',
'_150x150'
];
foreach ($size as $item) {
$file = $this->uploadPath . $file . $item . $extension;
if (File::exists($file)) {
File::delete($file);
}
}
}
}
}
1
2
3
0
protected function destroyFile(Model $record)
{
if (!method_exists($record, 'getFileField')) {
return null;
}
$field = $record->getFileField();
$field = $record->$field;
if (!empty($field)) {
list($file, $extension) = explode('.', $field);
$extension = '.' . $extension;
$size = [
'',
'_150x150'
];
foreach ($size as $item) {
$file = $this->uploadPath . $file . $item . $extension;
if (File::exists($file)) {
File::delete($file);
}
}
}
}
1
2
0
protected function destroyFile(Model $record)
{
if (!method_exists($record, 'getFileField')) {
return null;
}
$field = $record->getFileField();
$field = $record->$field;
if (empty($field)) {
return null;
}
list($file, $extension) = explode('.', $field);
$extension = '.' . $extension;
$size = [
'',
'_150x150'
];
foreach ($size as $item) {
$file = $this->uploadPath . $file . $item . $extension;
if (File::exists($file)) {
File::delete($file);
}
}
}
1
0
public function authenticate(Request $request)
{
$credentials = array(
'email' => $request->email,
'password' => $request->senha
);
if (Auth::attempt($credentials)) {
$notice = [
'alert' => 'success',
'message' => trans('auth.success')
];
return Redirect::intended(route('dashboard'))
->with('notice', $notice);
} else {
$notice = [
'alert' => 'danger',
'message' => trans('auth.failed')
];
return Redirect::route('login.index')
->with('notice', $notice);
}
}
public function authenticate(Request $request)
{
$credentials = array(
'email' => $request->email,
'password' => $request->senha
);
$notice = [
'alert' => 'danger',
'message' => trans('auth.failed')
];
if (Auth::attempt($credentials)) {
$notice['alert'] = 'success';
$notice['message'] = trans('auth.success');
return Redirect::intended(route('dashboard'))
->with('notice', $notice);
}
return Redirect::route('login.index')
->with('notice', $notice);
}
$this->group->member->setName("Fulano")->getConfig()->invite();
$this->group->member->setName("Fulano")->getConfig()->invite();
$this->group
->addFilter(new Foo())
->addFilter(new Bar());
Exceto para Interface fluente e Query Builder
$this->group->member->setName("Fulano")->getConfig()->invite();
$this->group
->addFilter(new Foo())
->addFilter(new Bar());
$this->group
->where('id', 34)
->select(['name'])
->get();
Exceto para Interface fluente e Query Builder
public function calcNum(Group $group) {...}
public function calcNum(Group $group) {...}
public function totalMembers(Group $group) {...}
public function addMemberAndInviteToGroup(Member $member) {...}
public function addMemberAndInviteToGroup(Member $member) {...}
public function addMember(Member $member) {...}
if ($rjx === true) {...}
if ($rjx === true) {...}
if ($request_ajax === true) {...}
class Group
{
protected $provider;
protected $member;
protected $school;
protected $helper;
protected $view;
protected $request;
}
class Group
{
protected $provider;
protected $member;
protected $school;
}
define('KILL_THE_ENEMY', 1);
define('KILL_THE_BOSS', 5);
class Game
{
private $score = 0;
public function setScore($score)
{
$this->score = $score;
}
public function getScore()
{
return $this->score;
}
}
$player = new Game();
$player->setScore($player->getScore()+KILL_THE_BOSS);
Decisão está sendo tomada fora da classe
<?php
define('KILL_THE_ENEMY', 1);
define('KILL_THE_BOSS', 5);
class Game
{
private $score = 0;
public function addScore($score)
{
$this->score += $score;
}
}
$player = new Game();
$player->addScore(KILL_THE_BOSS);
<?php
define('KILL_THE_ENEMY', 1);
define('KILL_THE_BOSS', 5);
class Game
{
protected $score = 0;
public function addScore($score)
{
$this->score += $score;
}
public function getScore()
{
return $this->score;
}
}
$player = new Game();
$player->addScore(KILL_THE_ENEMY);
$player->addScore(KILL_THE_ENEMY);
$player->addScore(KILL_THE_BOSS);
var_dump($player->getScore());
// int(7)
Seu código reflete o profissional que você é, então, zele para que ele, assim como você, cresça e se desenvolva.
Obrigado!
@doriansneto
dorianneto.com.br
By Alessandro Feitoza
Primeiro passo para mudar sua forma de escrever código!
Evangelist PHP | Community Manager/Founder PHP com Rapadura